diff --git a/.clang-tidy b/.clang-tidy index 541706cca..a96824ca0 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -43,4 +43,3 @@ Checks: > FormatStyle: "file" HeaderFilterRegex: ".*h$" -WarningsAsErrors: "*" diff --git a/.github/workflows/per_commit.yml b/.github/workflows/per_commit.yml new file mode 100644 index 000000000..deffd3c79 --- /dev/null +++ b/.github/workflows/per_commit.yml @@ -0,0 +1,239 @@ +name: "CI" + +on: [push] +jobs: + Ubuntu: + runs-on: ubuntu-latest + outputs: + cache_misses: ${{ env.cache_misses }} + steps: + - uses: actions/checkout@v3 + - name: Install required packages + run: | + sudo apt-get update + sudo apt-get -y install apt-utils + sudo apt-get -y install git gcc g++ cmake python make ninja-build + sudo apt-get -y install tcpdump libgsl-dev libxml2-dev + sudo apt-get -y install curl unzip tar + sudo apt-get -y install ccache + - name: Get timestamp + id: time + run: python3 -c "from datetime import datetime; print('time='+datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))" >> $GITHUB_ENV + - name: Restore ccache + id: ccache + uses: actions/cache@v3 + with: + path: .ccache + key: ubuntu-ci-${{env.time}} + restore-keys: ubuntu-ci- + - name: Setup ccache + run: | + ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache" + ccache --set-config=max_size=400M + ccache --set-config=compression=true + ccache -z + - name: Configure CMake + run: | + ./ns3 configure -d release --enable-asserts --enable-examples --enable-tests --disable-werror -G"Ninja" + - name: Build ns-3 + run: | + ./ns3 build + - name: Print ccache statistics + id: ccache_results + run: | + ccache -s + python3 -c "import re, subprocess;print('cache_misses=%d' % int(re.findall('cache_miss(.*)', subprocess.check_output(['ccache', '--print-stats']).decode())[0]))" >> $GITHUB_ENV + - name: Run tests and examples + if: env.cache_misses != '0' + run: python3 test.py --no-build + + CodeQL: + runs-on: ubuntu-latest + needs: Ubuntu + if: needs.Ubuntu.outputs.cache_misses != '0' + strategy: + fail-fast: false + steps: + - name: Checkout repository + uses: actions/checkout@v3 + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: 'cpp' + - name: Install required packages + run: | + sudo apt-get update + sudo apt-get -y install apt-utils + sudo apt-get -y install git gcc g++ cmake python make ninja-build + sudo apt-get -y install tcpdump libgsl-dev libxml2-dev + sudo apt-get -y install curl unzip tar + sudo apt-get -y install ccache + - name: Get timestamp + id: time + run: python3 -c "from datetime import datetime; print('time='+datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))" >> $GITHUB_ENV + - name: Restore ccache + id: ccache + uses: actions/cache@v3 + with: + path: .ccache + key: ubuntu-ci-${{env.time}} + restore-keys: ubuntu-ci- + - name: Setup ccache + run: | + ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache" + ccache --set-config=max_size=400M + ccache --set-config=compression=true + ccache -z + - name: Configure CMake + run: | + ./ns3 configure -d release --enable-asserts --enable-examples --enable-tests --disable-werror -G"Ninja" + - name: Build ns-3 + run: | + ./ns3 build + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + + Codecov: + runs-on: ubuntu-latest + needs: Ubuntu + if: needs.Ubuntu.outputs.cache_misses != '0' + steps: + - uses: actions/checkout@v3 + - name: Install required packages + run: | + sudo apt-get update + sudo apt-get -y install apt-utils + sudo apt-get -y install git gcc g++ cmake python3 make ninja-build + sudo apt-get -y install tcpdump libgsl-dev libxml2-dev + sudo apt-get -y install curl unzip tar + sudo apt-get -y install ccache + sudo apt-get -y install lcov + - name: Get timestamp + id: time + run: python3 -c "from datetime import datetime; print('time='+datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))" >> $GITHUB_ENV + - name: Restore ccache + id: ccache + uses: actions/cache@v3 + with: + path: .ccache + key: ubuntu-coverage-${{env.time}} + restore-keys: ubuntu-coverage- + - name: Setup ccache + run: | + ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache" + ccache --set-config=max_size=400M + ccache --set-config=compression=true + ccache -z + - name: Configure CMake + run: | + ./ns3 configure --enable-asserts --enable-examples --enable-tests --disable-werror --enable-gcov -G"Ninja" + - name: Build ns-3 + run: | + ./ns3 build + - name: Print ccache statistics + id: ccache_results + run: | + ccache -s + python3 -c "import re, subprocess;print('cache_misses=%d' % int(re.findall('cache_miss(.*)', subprocess.check_output(['ccache', '--print-stats']).decode())[0]))" >> $GITHUB_ENV + - name: Generate coverage data and submit to codecov.io + if: env.cache_misses != '0' + run: | + ./ns3 build coverage_gcc + cd ./build/coverage + bash <(curl -s https://codecov.io/bash) -f ns3.info || echo "Codecov did not collect coverage reports" + + Windows_MinGW: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - uses: actions/checkout@v3 + - uses: msys2/setup-msys2@v2 + - name: Install required msys2/mingw64 packages + run: | + pacman -S --noconfirm unzip + pacman -S --noconfirm tar + pacman -S --noconfirm mingw-w64-x86_64-curl + pacman -S --noconfirm mingw-w64-x86_64-binutils + pacman -S --noconfirm mingw-w64-x86_64-cmake + pacman -S --noconfirm mingw-w64-x86_64-gcc + pacman -S --noconfirm mingw-w64-x86_64-ninja + pacman -S --noconfirm mingw-w64-x86_64-python + pacman -S --noconfirm mingw-w64-x86_64-ccache + pacman -S --noconfirm mingw-w64-x86_64-gsl + pacman -S --noconfirm mingw-w64-x86_64-libxml2 + pacman -S --noconfirm mingw-w64-x86_64-lld + pacman --noconfirm -Scc + - name: Get timestamp + id: time + run: python3 -c "from datetime import datetime; print('time='+datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))" >> $GITHUB_ENV + - name: Restore ccache + id: ccache + uses: actions/cache@v3 + with: + path: .ccache + key: msys2-${{env.time}} + restore-keys: msys2- + - name: Setup ccache + run: | + ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache" + ccache --set-config=max_size=400M + ccache --set-config=compression=true + ccache -z + - name: Configure CMake + run: | + python3 ns3 configure -d release --enable-asserts --enable-examples --enable-tests --disable-werror -G"Ninja" + - name: Build ns-3 + run: | + python3 ns3 build + - name: Print ccache statistics + id: ccache_results + run: | + ccache -s + python3 -c "import re, subprocess;print('cache_misses=%d' % int(re.findall('cache_miss(.*)', subprocess.check_output(['ccache', '--print-stats']).decode())[0]))" >> $GITHUB_ENV + - name: Run tests and examples + if: env.cache_misses != '0' + run: python3 test.py --no-build + + Mac_OS_X: + runs-on: macos-latest + steps: + - uses: actions/checkout@v3 + - name: Install required packages + run: | + brew install ninja cmake ccache libxml2 gsl open-mpi #qt5 + - name: Get timestamp + id: time + run: python3 -c "from datetime import datetime; print('time='+datetime.now().strftime('%Y-%m-%d-%H-%M-%S'))" >> $GITHUB_ENV + - name: Restore ccache + id: ccache + uses: actions/cache@v3 + with: + path: .ccache + key: osx_brew-ci-${{env.time}} + restore-keys: osx_brew-ci- + - name: Setup ccache + run: | + export PATH=/usr/local/bin:$PATH #:/usr/local/opt/qt/bin + ccache --set-config=cache_dir="$GITHUB_WORKSPACE/.ccache" + ccache --set-config=max_size=400M + ccache --set-config=compression=true + ccache -z + - name: Configure CMake + run: | + export PATH=/usr/local/bin:$PATH #:/usr/local/opt/qt/bin + ./ns3 configure -d release --enable-asserts --enable-examples --enable-tests --disable-werror -G"Ninja" + - name: Build ns-3 + run: | + export PATH="$PATH" #:/usr/local/opt/qt/bin + ./ns3 build + - name: Print ccache statistics + id: ccache_results + run: | + ccache -s + python3 -c "import re, subprocess;print('cache_misses=%d' % int(re.findall('cache_miss(.*)', subprocess.check_output(['ccache', '--print-stats']).decode())[0]))" >> $GITHUB_ENV + - name: Run tests and examples + if: env.cache_misses != '0' + run: ./test.py --no-build diff --git a/.gitignore b/.gitignore index 4bef5b43a..ee2d5cb41 100644 --- a/.gitignore +++ b/.gitignore @@ -46,9 +46,6 @@ cmake-build-relwithdebinfo/ cmake-build-minsizerel/ cmake-build-release/ -.vscode/* -!.vscode/launch.json -!.vscode/tasks.json .vs/ # Ignore local cache used by e.g. clangd diff --git a/.vscode/.gitignore b/.vscode/.gitignore new file mode 100644 index 000000000..4b537ac9c --- /dev/null +++ b/.vscode/.gitignore @@ -0,0 +1,5 @@ +* +!.gitignore + +!launch.json +!tasks.json diff --git a/AUTHORS b/AUTHORS index 2c68370b5..7c29fbcb7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -68,6 +68,7 @@ Ankit Deepak (adadeepak8@gmail.com) Christophe Delahaye (christophe.delahaye@orange.com) Sébastien Deronne (sebastien.deronne@gmail.com) Ameya Deshpande (ameyanrd@outlook.com) +Zhiheng Dong (dzh2077@gmail.com) Christoph Döpmann (doepmanc@informatik.hu-berlin.de) Jordan Dorham (dorham1@llnl.gov) Craig Dowell (craigdo@ee.washington.edu) @@ -109,6 +110,7 @@ Frank Helbert (frank@ime.usp.br) Tom Henderson (tomhend@u.washington.edu) Christopher Hepner (hepner@hs-ulm.de) Budiarto Herman (budiarto.herman@magister.fi) +Heun (git-gmb.hpmta@simplelogin.com) Tom Hewer (tomhewer@mac.com) Kristian A. Hiorth (kristahi@ifi.uio.no) Hrishikesh Hiraskar (hrishihirakar@gmail.com) @@ -137,6 +139,7 @@ Ouassim Karrakchou (okarr102@uottawa.ca) Tanmay Kathpalia (tanmay.kathpalia@landisgyr.com) Konstantinos Katsaros (dinos.katsaros@gmail.com) Bhaskar Kataria (www.bhaskar.com7@gmail.com) +Nils Kattenbeck (nils.kattenbeck@rwth-aachen.de) Morteza Kheirkhah (m.kheirkhah@sussex.ac.uk) Jörg Christian Kirchhof (christian.kirchhof@rwth-aachen.de) Ohad Klausner @@ -187,6 +190,7 @@ Faker Moatamri (faker.moatamri@inria.fr) Edvin Močibob (edvin.mocibob@gmail.com) Amir Modarresi (amodarresi@ittc.ku.edu) Akash Mondal (a98mondal@gmail.com) +Lars Moons (lars.moons@student.uantwerpen.be) Mike Moreton (mjvm_ns@hotmail.com) Michele Muccio (michelemuccio@virgilio.it) Esteban Municio (esteban.municio@urjc.es) @@ -214,6 +218,7 @@ Jendaipou Palmei (jendaipoupalmei@gmail.com) Parth Pandya (parthpandyappp@gmail.com) Harsh Patel (thadodaharsh10@gmail.com) Natale Patriciello (natale.patriciello@gmail.com) +Pavinberg (pavin0702@gmail.com) Tommaso Pecorella (tommaso.pecorella@unifi.it) Guangyu Pei (guangyu.pei@boeing.com) Josh Pelkey (jpelkey@gatech.edu) @@ -293,6 +298,7 @@ Adrian S. W. Tam (adrian.sw.tam@gmail.com) Cristiano Tapparello (cristiano.tapparello@rochester.edu) Hajime Tazaki (tazaki@sfc.wide.ad.jp) Wilson Thong (wilsonwk@ee.cityu.edu.hk) +Lars Toenning (lars.toenning@gmail.com) Omer Topal (omer.topal@airties.com) Mauro Tortonesi (mauro.tortonesi@unife.it) Quincy Tse (quincy.tse@gmail.com) diff --git a/CHANGES.md b/CHANGES.md index d71d6da35..044b398d0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,43 +18,43 @@ Changes from ns-3.36 to ns-3.37 ### New API -* Added a new attribute **MaxTbPpduDelay** in HeConfiguration for configuring the maximum delay with which a TB PPDU can arrive at the AP after the first TB PPDU in order to be decoded properly. If the delay is higher than **MaxTbPpduDelay**, the TB PPDU is discarded and treated as interference. -* Added new methods (**ConfigHtOptions**, **ConfigVhtOptions**, **ConfigHeOptions** and **ConfigEhtOptions**) to `WifiHelper` to configure HT/VHT/HE/EHT options listed as attributes of the respective Configuration classes through the wifi helper. -* Added new attributes (**AccessReqInterval**, **AccessReqAc** and **DelayAccessReqUponAccess**) to the MultiUserScheduler to allow a wifi AP to coordinate UL MU transmissions even without DL traffic. -* `WifiNetDevice` has a new **Phys** attribute, which is primarily intended to select a specific PHY object of an 11be multi-link device when using path names. -* `Txop` class (wifi module) has new attributes (**MinCws**, **MaxCws**, **Aifsns** and **TxopLimits**) to set minimum CW, maximum CW, AIFSN and TXOP limit for all the links of a multi-link device. -* `WifiPhyListener::NotifyMaybeCcaBusyStart` has been renamed to `WifiPhyListener::NotifyCcaBusyStart` and has two additional parameters: the channel type that indicates for which subchannel the CCA-BUSY is reported and a vector of CCA-BUSY durations for each 20 MHz subchannel. A duration of zero indicates CCA is IDLE, and the vector of CCA-BUSY durations is not empty if the PHY supports 802.11ax and the operational channel width is larger than 20 MHz. -* Added a new attribute **CcaSensitivity** in WifiPhy for configuring the threshold that corresponds to the minimum received power of a PPDU, that occupies the primary channel, should have to report a CCA-BUSY indication. -* Added a new attribute **SecondaryCcaSensitivityThresholds** in VhtConfiguration for configuring the thresholds that corresponds to the minimum received power of a PPDU, that does not occupy the primary 20 MHz channel, should have to report a CCA-BUSY indication. This is made of a tuple, where the first threshold is used for 20 MHz PPDUs, the second one is used for 40 MHz PPDUs and the third one is used for 80 MHz PPDUs. -* In `src/internet`, several changes were made to enable auto-generated neighbor cache: +* (internet) In `src/internet`, several changes were made to enable auto-generated neighbor caches: * A new helper (NeighborCacheHelper) was added to set up auto-generated neighbor cache. * New NUD_STATE `STATIC_AUTOGENERATED` was added to help the user manage auto-generated entries in Arp cache and Ndisc cache. * Add new callbacks RemoveAddressCallback and AddAddressCallback to dynamically update neighbor cache during addresses are removed/added. * Add NeighborCacheTestSuite to test auto-generated neighbor cache. -* Added two new trace sources to `StaWifiMac`: **LinkSetupCompleted**, which is fired when a link is setup in the context of an 11be ML setup, and **LinkSetupCanceled**, which is fired when the setup of a link is terminated. Both sources provide the ID of the setup link and the MAC address of the corresponding AP. +* (lr-wpan) Adds support for **LrWpanMac** devices association. +* (lr-wpan) Adds support for **LrWpanMac** energy detection (ED) scan. +* (lr-wpan) Adds support for **LrWpanMac** active and passive scan. +* (lr-wpan) Adds support for channel paging to the **LrWpanPhy** (only placeholder, a single modulation/band is currently supported). +* (lr-wpan) Add **LrWpanMac** packet traces and queue limits to Tx queue and Ind Tx queue. +* (propagation) Add O2I Low/High Building Penetration Losses in 3GPP propagation loss model (`ThreeGppPropagationLossModel`) according to **3GPP TR 38.901 7.4.3.1**. Currently, UMa, UMi and RMa scenarios are supported. +* (wifi) Added a new attribute **MaxTbPpduDelay** in HeConfiguration for configuring the maximum delay with which a TB PPDU can arrive at the AP after the first TB PPDU in order to be decoded properly. If the delay is higher than **MaxTbPpduDelay**, the TB PPDU is discarded and treated as interference. +* (wifi) Added new methods (**ConfigHtOptions**, **ConfigVhtOptions**, **ConfigHeOptions** and **ConfigEhtOptions**) to `WifiHelper` to configure HT/VHT/HE/EHT options listed as attributes of the respective Configuration classes through the wifi helper. +* (wifi) Added new attributes (**AccessReqInterval**, **AccessReqAc** and **DelayAccessReqUponAccess**) to the MultiUserScheduler to allow a wifi AP to coordinate UL MU transmissions even without DL traffic. +* `(wifi) WifiNetDevice` has a new **Phys** attribute, which is primarily intended to select a specific PHY object of an 11be multi-link device when using path names. +* (wifi) `Txop` class has new attributes (**MinCws**, **MaxCws**, **Aifsns** and **TxopLimits**) to set minimum CW, maximum CW, AIFSN and TXOP limit for all the links of a multi-link device. +* (wifi) `WifiPhyListener::NotifyMaybeCcaBusyStart` has been renamed to `WifiPhyListener::NotifyCcaBusyStart` and has two additional parameters: the channel type that indicates for which subchannel the CCA-BUSY is reported and a vector of CCA-BUSY durations for each 20 MHz subchannel. A duration of zero indicates CCA is IDLE, and the vector of CCA-BUSY durations is not empty if the PHY supports 802.11ax and the operational channel width is larger than 20 MHz. +* (wifi) Added a new attribute **CcaSensitivity** in WifiPhy for configuring the threshold that corresponds to the minimum received power of a PPDU, that occupies the primary channel, should have to report a CCA-BUSY indication. +* (wifi) Added a new attribute **SecondaryCcaSensitivityThresholds** in VhtConfiguration for configuring the thresholds that corresponds to the minimum received power of a PPDU, that does not occupy the primary 20 MHz channel, should have to report a CCA-BUSY indication. This is made of a tuple, where the first threshold is used for 20 MHz PPDUs, the second one is used for 40 MHz PPDUs and the third one is used for 80 MHz PPDUs. +* (wifi) Added two new trace sources to `StaWifiMac`: **LinkSetupCompleted**, which is fired when a link is setup in the context of an 11be ML setup, and **LinkSetupCanceled**, which is fired when the setup of a link is terminated. Both sources provide the ID of the setup link and the MAC address of the corresponding AP. ### Changes to existing API -* Adds support for channel paging to the **LrWpanPhy** (only placeholder, a single modulation/band is currently supported). -* Adds supporting structures used by **LrWpanMac** (PAN descriptor, Command Payload Header, Capability Field). -* Mac(8|16|48|64)Address address allocation pool is now reset between consecutive runs. -* Adds support for **LrWpanMac** energy detection (ED) scan. -* IPv6 Router Solicitations (RS) are now retransmitted up to 4 times, following RFC 5779. -* Adds support for **LrWpanMac** active and passive scan. -* Add supporting association structures: parameters, callbacks and the pending transaction list to **LrWpanMac**. -* The **TxopTrace** trace source of wifi `QosTxop` now has an additional argument (the third one) indicating the ID of the link the TXOP refers to (for non-MLDs, this value is zero). -* The maximum allowed channel width (in MHz) for a data transmission is passed to the **GetDataTxVector** method of the `WifiRemoteStationManager`. -* The **WifiMacQueueItem** class has been renamed as **WifiMpdu**. -* The **Assoc** and **DeAssoc** trace sources of `StaWifiMac` provide the AP MLD address in case (de)association takes place between a non-AP MLD and an AP MLD. -* Adds support for **LrWpanMac** devices association. -* Pan Id compression is now possible in **LrWpanMac** when transmitting data frames. i.e. When src and dst pan ID are the same, only one PanId is used, making the MAC header 2 bytes smaller. See IEEE 802.15.4-2006 (7.5.6.1). -* Add O2I Low/High Building Penetration Losses in 3GPP propagation loss model (`ThreeGppPropagationLossModel`) according to **3GPP TR 38.901 7.4.3.1**. Currently, UMa, UMi and RMa scenarios are supported. +* (lr-wpan) Replace **LrWpanMac** Tx Queue and Ind Tx Queue pointers for smart pointers. +* (lr-wpan) Adds supporting structures used by **LrWpanMac** (PAN descriptor, Command Payload Header, Capability Field). +* (lr-wpan) Add supporting association structures: parameters, callbacks and the pending transaction list to **LrWpanMac**. +* (wifi) The **TxopTrace** trace source of wifi `QosTxop` now has an additional argument (the third one) indicating the ID of the link the TXOP refers to (for non-MLDs, this value is zero). +* (wifi) The maximum allowed channel width (in MHz) for a data transmission is passed to the **GetDataTxVector** method of the `WifiRemoteStationManager`. +* (wifi) The **WifiMacQueueItem** class has been renamed as **WifiMpdu**. +* (wifi) The **Assoc** and **DeAssoc** trace sources of `StaWifiMac` provide the AP MLD address in case (de)association takes place between a non-AP MLD and an AP MLD. ### Changes to build system * Replaced the Pybindgen python bindings framework with Cppyy. * Enabled precompiled headers (`NS3_PRECOMPILE_HEADERS`) by default when CCache is found. -* Added a `./ns3 show targets` option to list buildable/runnable targets. +* Added the `./ns3 show targets` option to list buildable/runnable targets. +* Added the `./ns3 show (all)` option to list a summary of the current settings. * Replaced `./ns3 --check-config` with `./ns3 show config`. * Replaced `./ns3 --check-profile` with `./ns3 show profile`. * Replaced `./ns3 --check-version` with `./ns3 show version`. @@ -62,17 +62,24 @@ Changes from ns-3.36 to ns-3.37 * Replaced Python-based .ns3rc with a CMake-based version. * Deprecated .ns3rc files will be updated to the new CMake-based format and a backup will be placed alongside it. * Added the `./ns3 configure --filter-module-examples-and-tests='module1;module2'` option, which can be used to filter out examples and tests that do not use the listed modules. +* Deprecated symlinks in the build/ directory in favor of stub headers. +* Added support for faster linkers `lld` and `mold`. These will be used if found. The order of priority is: `mold` > `lld` > default linker. +* Added support for Windows using the Msys2/MinGW64 toolchain (supports both Unix-like Bash shell shipped with Msys2 and native shells such as CMD and PowerShell). +* Added new `./ns3 run` options for profilers: `--memray` and `--heaptrack` for memory profiling of Python scripts and C++ programs, respectively, and `--perf` for performance profiling on Linux. ### Changed behavior -* Lr-wpan: **LrWpanPhy** now change to TRX_OFF after a CSMA-CA failure when the RxOnWhenIdle flag is set to false in the **LrWpanMac**. -* The **Channel** attribute of `WifiNetDevice` is deprecated because it became ambiguous with the introduction of multiple links per device. The **Channel** attribute of `WifiPhy` can be used instead. -* The O2I Low/High Building Penetration Losses will add losses in the pathloss calculation when buildings are present and a UE results to be in O2I state. In order to not consider these losses, they can be disabled by setting BuildingPenetrationLossesEnabled to false. -* Support for four types of UE handover failure are now modeled: +* (internet) IPv6 Router Solicitations (RS) are now retransmitted up to 4 times, following RFC 5779. +* (lr-wpan) **LrWpanPhy** now change to TRX_OFF after a CSMA-CA failure when the RxOnWhenIdle flag is set to false in the **LrWpanMac**. +* (lr-wpan) Pan Id compression is now possible in **LrWpanMac** when transmitting data frames. i.e. When src and dst pan ID are the same, only one PanId is used, making the MAC header 2 bytes smaller. See IEEE 802.15.4-2006 (7.5.6.1). +* (lte) Support for four types of UE handover failure are now modeled: * A HO failure is triggered if eNB cannot allocate non-contention-based preamble. * Handover joining timeout is now handled. * Handover leaving timeout is now handled. * Upon RACH failure during HO, the UE will perform cell selection again. +* (network) Mac(8|16|48|64)Address address allocation pool is now reset between consecutive runs. +* (propagation) The O2I Low/High Building Penetration Losses will add losses in the pathloss calculation when buildings are present and a UE results to be in O2I state. In order to not consider these losses, they can be disabled by setting BuildingPenetrationLossesEnabled to false. +* (wifi) The **Channel** attribute of `WifiNetDevice` is deprecated because it became ambiguous with the introduction of multiple links per device. The **Channel** attribute of `WifiPhy` can be used instead. Changes from ns-3.36 to ns-3.36.1 --------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a7c61dbe..cea53b950 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,8 @@ cmake_minimum_required(VERSION 3.10..3.10) mark_as_advanced(CCACHE) find_program(CCACHE ccache) if(NOT ("${CCACHE}" STREQUAL "CCACHE-NOTFOUND")) - set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) message(STATUS "CCache is enabled.") + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE}) execute_process( COMMAND ${CCACHE} --set-config @@ -66,7 +66,6 @@ option(NS3_NETANIM "Build netanim" OFF) # other options option(NS3_ENABLE_BUILD_VERSION "Embed version info into libraries" OFF) -option(NS3_GNUPLOT "Build with Gnuplot support" OFF) option(NS3_GSL "Build with GSL support" ON) option(NS3_GTK3 "Build with GTK3 support" ON) option(NS3_LINK_TIME_OPTIMIZATION "Build with link-time optimization" OFF) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 901537eb4..46f2b1de4 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -3,50 +3,88 @@ ns-3 RELEASE NOTES This file contains ns-3 release notes (most recent releases first). -All of the ns-3 documentation is accessible from the ns-3 website: - including tutorials: +ns-3 documentation is accessible from the [ns-3 website](https://www.nsnam.org). Consult the file [CHANGES.md](CHANGES.md) for more detailed information about changed API and behavior across ns-3 releases. -Release 3-dev -------------- +In the following, numeric references prefixed by '#' refer to +a [GitLab.com issue tracker](https://gitlab.com/nsnam/ns-3-dev/-/issues) number, +and references prefixed by '!' refer to a +[GitLab.com merge request](https://gitlab.com/nsnam/ns-3-dev/-/merge_requests) number. + +Release 3.37 +------------ + +### Availability + +This release is available from: + + +### Supported platforms + +This release is intended to work on systems with the following minimal +requirements (Note: not all ns-3 features are available on all systems): + +- g++-8 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 + +Python API requires [Cppyy](https://cppyy.readthedocs.io/en/latest/installation.html). ### New user-visible features -- (lr-wpan) !959 - Add PHY channel page support -- (lr-wpan) Adds PAN descriptor, CommandPayload Header and Capability Field -- (wifi) !984 - MultiUserScheduler can request channel access periodically -- (lr-wpan) !991 - Adds MAC ED scan support - (internet) !996 - IPv6 Router Solicitations (RS) are now retransmitted up to 4 times, following RFC 5779. -- (lr-wpan) !997 - Adds MAC ACTIVE and PASSIVE scan support -- (wifi) CCA has been reworked to report the channel type in the CCA-BUSY indication and the per-20 MHz CCA bitmap for 802.11ax. -- (wifi) PPDUs are transmitted on the largest primary channel that is found to be idle (according to the CCA-BUSY indication provided by the PHY) when gaining a TXOP. - (internet) Add auto-generate ARP/NDISC cache, as the outcome of GSoC 2022 project. -- (wifi) Add support for fragmentation of Information Elements. -- (wifi) Implement 802.11be Multi-link discovery and setup +- (lte) LTE handover failure is now handled for joining and leaving timeouts, RACH failure, and preamble allocation failure. +- (lr-wpan) !991 - Adds MAC ED scan support +- (lr-wpan) !959 - Add PHY channel page support +- (lr-wpan) !997 - Adds MAC ACTIVE and PASSIVE scan support - (lr-wpan) !1072 - Adds support for association (network bootstrap) +- (lr-wpan) !1131 - Add support for configurable tx queue and ind tx queue limits. +- (lr-wpan) !1133 - Add a post-rx error model. - (lr-wpan) Adds support for PAN Id compression (IEEE 802.15.4-2006 (7.5.6.1)) +- (lr-wpan) Adds PAN descriptor, CommandPayload Header and Capability Field - (utils) `utils/bench-simulator` has been moved to `utils/bench-scheduler` to better reflect what it actually tests - (utils) `utils/bench-scheduler` has been enhanced to test multiple schedulers. -- (lte) LTE handover failure is now handled for joining and leaving timeouts, RACH failure, and preamble allocation failure. +- (wifi) !984 - MultiUserScheduler can request channel access periodically +- (wifi) CCA has been reworked to report the channel type in the CCA-BUSY indication and the per-20 MHz CCA bitmap for 802.11ax. +- (wifi) PPDUs are transmitted on the largest primary channel that is found to be idle (according to the CCA-BUSY indication provided by the PHY) when gaining a TXOP. +- (wifi) Add support for fragmentation of Information Elements. +- (wifi) Implement 802.11be Multi-link discovery and setup ### Bugs fixed -- (wifi) Fix setting of stations' max supported channel width -- (wifi) Fix setting TX power for HE TB PPDUs in case AP requested using the max TX power -- (wifi) #521 - UL OFDMA support +- (build) #676 Fix missing version defines +- (build) #684 Fix prevents hidden source files from being processed as scratches +- (build) #687 Display how to forward arguments to programs with the ns3 script +- (build) #694 Fix .ns3rc search scope +- (build) #699 Fix the ns3 script behavior for `-h` +- (build) #700 Suppress build chatter for `./ns3 show version` +- (build) #712 Fix build version parsing +- (build) #713 Fix build version requirements checking to allow for custom embedded version +- (build) #732 Fix WSLv1 check that failed in systems that included a `;` in their `/proc/version` output +- (build) #733 Fix installation to optionally include python bindings and uninstallation to remove pkg-config files +- (build) #734 Fix installation to include tap-creator and raw-sock-creator +- (build) Widen the search scope of headers and libraries to better support Bake +- (core) #756 - Fix `CsvReader::GetValueAs()` functions for `char` arguments +- (core) Fix int64x64-cairo.h bool operator +- (general) #758 - Fix warnings about `for` loops with variables that are "too small" to fully represent the data being looped - (lr-wpan) #536 - Fixes PHY not going to TRX_OFF after CSMA-CA failure (RxOnWhenIdle(false)) +- (lr-wpan) #692 - Replace raw pointers for smart pointers in Tx queue and Ind Tx queue. +- (wifi) #521 - UL OFDMA support +- (wifi) #696 - 802.11ax assert failed. cond="seqNumber < SEQNO_SPACE_SIZE && startingSeqNumber < SEQNO_SPACE_SIZE" +- (wifi) #709 Adjust WifiPhy::RxSensitivity with channel width for YansWifiChannel +- (wifi) Fix setting of stations' maximum supported channel width +- (wifi) Fix setting TX power for HE TB PPDUs in case AP requested using the max TX power - (wifi) Only include QoS Null frames for TIDs for which a BA agreement exists in responses to BSRP TFs - (wifi) Notify RX end only for the last received HE TB PPDU - (wifi) Correctly compute the time to RX end to be passed to WifiPhyStateHelper::SwitchToRx() -- (wifi) #709 Adjust WifiPhy::RxSensitivity with channel width for YansWifiChannel - (wifi) Align default TXOP limit for VI and VO to 802.11-2020 -- (wifi) #696 - 802.11ax assert failed. cond="seqNumber < SEQNO_SPACE_SIZE && startingSeqNumber < SEQNO_SPACE_SIZE" - (wifi) Fix acknowledgment in SU format for DL MU PPDUs including PSDUs of different TIDs - (wifi) Fix the TID of QoS Null frames in response to BSRP TF -- (core) #756 - Fix `CsvReader::GetValueAs()` functions for `char` arguments -- #758 - Fix warnings about `for` loops with variables that are "too small" to fully represent the data being looped Release 3.36.1 -------------- diff --git a/VERSION b/VERSION index 1b8ef0972..ef350da80 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3-dev +3.37 diff --git a/bindings/python/ns/_placeholder_ b/bindings/python/ns/_placeholder_ deleted file mode 100644 index e69de29bb..000000000 diff --git a/bindings/python/ns3/_placeholder_ b/bindings/python/ns3/_placeholder_ deleted file mode 100644 index e69de29bb..000000000 diff --git a/bindings/python/ns__init__.py b/bindings/python/ns__init__.py index 5e80cab30..473f05803 100644 --- a/bindings/python/ns__init__.py +++ b/bindings/python/ns__init__.py @@ -1,8 +1,15 @@ import builtins +from copy import copy +from functools import lru_cache +import glob import os.path import sys +import sysconfig import re +DEFAULT_INCLUDE_DIR = sysconfig.get_config_var("INCLUDEDIR") +DEFAULT_LIB_DIR = sysconfig.get_config_var("LIBDIR") + def find_ns3_lock(): # Get the absolute path to this file @@ -11,27 +18,290 @@ def find_ns3_lock(): lock_file = (".lock-ns3_%s_build" % sys.platform) # Move upwards until we reach the directory with the ns3 script + prev_path = None while "ns3" not in os.listdir(path_to_lock): + prev_path = path_to_lock path_to_lock = os.path.dirname(path_to_lock) + if prev_path == path_to_lock: + break # We should be now at the directory that contains a lock if the project is configured if lock_file in os.listdir(path_to_lock): path_to_lock += os.sep + lock_file else: - raise Exception("ns-3 lock file was not found.\n" - "Are you sure %s is inside your ns-3 directory?" % path_to_this_init_file) + path_to_lock = None return path_to_lock -def load_modules(): - # Load NS3_ENABLED_MODULES from the lock file inside the build directory - values = {} +SYSTEM_LIBRARY_DIRECTORIES = (DEFAULT_LIB_DIR, + os.path.dirname(DEFAULT_LIB_DIR) + ) +DYNAMIC_LIBRARY_EXTENSIONS = {"linux": "so", + "win32": "dll", + "darwin": "dylib" + } +LIBRARY_EXTENSION = DYNAMIC_LIBRARY_EXTENSIONS[sys.platform] - exec(open(find_ns3_lock()).read(), {}, values) - suffix = "-" + values["BUILD_PROFILE"] if values["BUILD_PROFILE"] != "release" else "" - required_modules = [module.replace("ns3-", "") for module in values["NS3_ENABLED_MODULES"]] - ns3_output_directory = values["out_dir"] - libraries = {x.split(".")[0]: x for x in os.listdir(os.path.join(ns3_output_directory, "lib"))} + +def trim_library_path(library_path: str) -> str: + trimmed_library_path = os.path.basename(library_path) + + # Remove lib prefix if it exists and extensions + trimmed_library_path = trimmed_library_path.split(".")[0] + if trimmed_library_path[0:3] == "lib": + trimmed_library_path = trimmed_library_path[3:] + return trimmed_library_path + + +@lru_cache(maxsize=None) +def _search_libraries() -> dict: + # Otherwise, search for ns-3 libraries + # Should be the case when ns-3 is installed as a package + env_sep = ";" if sys.platform == "win32" else ":" + + # Search in default directories PATH and LD_LIBRARY_PATH + library_search_paths = os.getenv("PATH", "").split(env_sep) + library_search_paths += os.getenv("LD_LIBRARY_PATH", "").split(env_sep) + if "" in library_search_paths: + library_search_paths.remove("") + del env_sep + + # And the current working directory too + library_search_paths += [os.path.abspath(os.getcwd())] + + # And finally the directories containing this file and its parent directory + library_search_paths += [os.path.abspath(os.path.dirname(__file__))] + library_search_paths += [os.path.dirname(library_search_paths[-1])] + library_search_paths += [os.path.dirname(library_search_paths[-1])] + + # 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) + + # 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) + + del search_path, library_search_paths + + library_map = {} + # Organize libraries into a map + for library in libraries: + library_infix = trim_library_path(library) + + # Then check if a key already exists + if library_infix not in library_map: + library_map[library_infix] = set() + + # Append the directory + library_map[library_infix].add(library) + + # Replace sets with lists + for (key, values) in library_map.items(): + library_map[key] = list(values) + return library_map + + +def search_libraries(library_name: str) -> list: + libraries_map = _search_libraries() + trimmed_library_name = trim_library_path(library_name) + matched_names = list(filter(lambda x: trimmed_library_name in x, libraries_map.keys())) + matched_libraries = [] + + if matched_names: + for match in matched_names: + matched_libraries += libraries_map[match] + return matched_libraries + + +def extract_library_include_dirs(library_name: str, prefix: str) -> list: + library_path = "%s/lib/%s" % (prefix, library_name) + linked_libs = [] + # First discover which 3rd-party libraries are used by the current module + try: + with open(os.path.abspath(library_path), "rb") as f: + linked_libs = re.findall(b"\x00(lib.*?.%b)" % LIBRARY_EXTENSION.encode("utf-8"), f.read()) + except Exception as e: + print("Failed to extract libraries used by {library} with exception:{exception}" + .format(library=library_path, exception=e)) + exit(-1) + + linked_libs_include_dirs = set() + # 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): + # Skip ns-3 modules + if "libns3" in linked_library: + continue + + # Search for the absolute path of the library + linked_library_path = search_libraries(linked_library) + + # Raise error in case the library can't be found + if len(linked_library_path) == 0: + raise Exception( + "Failed to find {library}. Make sure its library directory is in LD_LIBRARY_PATH.".format( + library=linked_library)) + + # Get path with 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 + + # If it is part of the system directories, try to find it + 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) + + # If system_include_dir/library_name exists, we add it too + linked_library_name = linked_library.replace("lib", "").replace("." + LIBRARY_EXTENSION, "") + if os.path.exists(os.path.join(system_include_dir, linked_library_name)): + linked_libs_include_dirs.add(os.path.join(system_include_dir, linked_library_name)) + + # In case it isn't, include new include directories based on the path + def add_parent_dir_recursively(x: str, y: int) -> None: + if y <= 0: + return + parent_dir = os.path.dirname(x) + linked_libs_include_dirs.add(parent_dir) + add_parent_dir_recursively(parent_dir, y - 1) + + add_parent_dir_recursively(linked_library_path, 2) + + for lib_path in list(linked_libs_include_dirs): + 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) + + +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 = {} + + # 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) + else: + libraries = search_libraries("ns3") + + if not libraries: + raise Exception("ns-3 libraries were not found.") + + # 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)) + + # 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("-") + + # 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)) # Try to import Cppyy and warn the user in case it is not found try: @@ -49,30 +319,45 @@ def load_modules(): libcppyy.AddSmartPtrType('Ptr') # Import ns-3 libraries - cppyy.add_library_path("%s/lib" % ns3_output_directory) - cppyy.add_include_path("%s/include" % ns3_output_directory) + prefix = os.path.abspath(prefix) + cppyy.add_library_path("%s/lib" % prefix) + cppyy.add_include_path("%s/include" % prefix) - for module in required_modules: + 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]) + + 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): + if linked_lib_include_dir not in known_include_dirs: + known_include_dirs.add(linked_lib_include_dir) + cppyy.add_include_path(linked_lib_include_dir) + + for module in modules: cppyy.include("ns3/%s-module.h" % module) - for module in required_modules: - library_name = "libns{version}-{module}{suffix}".format( - version=values["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'" - ) - cppyy.load_library(libraries[library_name]) + # After including all headers, we finally load the modules + for library in libraries_to_load: + cppyy.load_library(library) # We expose cppyy to consumers of this module as ns.cppyy setattr(cppyy.gbl.ns3, "cppyy", cppyy) # To maintain compatibility with pybindgen scripts, # we set an attribute per module that just redirects to the upper object - for module in required_modules: + for module in modules: setattr(cppyy.gbl.ns3, module.replace("-", "_"), cppyy.gbl.ns3) # Set up a few tricks @@ -102,6 +387,7 @@ def load_modules(): def Node_del(self: cppyy.gbl.ns3.Node) -> None: cppyy.gbl.ns3.__nodes_pending_deletion.append(self) return None + cppyy.gbl.ns3.Node.__del__ = Node_del # Define ns.cppyy.gbl.addressFromIpv4Address and others @@ -114,14 +400,6 @@ def load_modules(): setattr(cppyy.gbl.ns3, "addressFromIpv4Address", cppyy.gbl.addressFromIpv4Address) setattr(cppyy.gbl.ns3, "addressFromInetSocketAddress", cppyy.gbl.addressFromInetSocketAddress) setattr(cppyy.gbl.ns3, "addressFromPacketSocketAddress", cppyy.gbl.addressFromPacketSocketAddress) - cppyy.cppdef( - """using namespace ns3; CommandLine& getCommandLine(std::string filename){ static CommandLine g_cmd = CommandLine(filename); return g_cmd; };""") - setattr(cppyy.gbl.ns3, "getCommandLine", cppyy.gbl.getCommandLine) - cppyy.cppdef( - """using namespace ns3; template Callback ns3::MakeNullCallback(void);""") - cppyy.cppdef( - """using namespace ns3; Callback null_callback(){ return MakeNullCallback(); };""") - setattr(cppyy.gbl.ns3, "null_callback", cppyy.gbl.null_callback) cppyy.cppdef(""" using namespace ns3; @@ -172,6 +450,7 @@ def load_modules(): except Exception as e: exit(-1) return getattr(cppyy.gbl, func)() + setattr(cppyy.gbl.ns3, "CreateObject", CreateObject) def GetObject(parentObject, aggregatedObject): @@ -198,7 +477,9 @@ def load_modules(): } """ % (aggregatedType, aggregatedType, aggregatedType, aggregatedType) ) - return cppyy.gbl.getAggregatedObject(parentObject, aggregatedObject if aggregatedIsClass else aggregatedObject.__class__) + return cppyy.gbl.getAggregatedObject(parentObject, + aggregatedObject if aggregatedIsClass else aggregatedObject.__class__) + setattr(cppyy.gbl.ns3, "GetObject", GetObject) return cppyy.gbl.ns3 diff --git a/bindings/python/pch/_placeholder_ b/bindings/python/pch/_placeholder_ deleted file mode 100644 index 48cdce852..000000000 --- a/bindings/python/pch/_placeholder_ +++ /dev/null @@ -1 +0,0 @@ -placeholder diff --git a/build-support/cmake-format-modules.txt b/build-support/cmake-format-modules.txt index 706d0011e..963cefa50 100644 --- a/build-support/cmake-format-modules.txt +++ b/build-support/cmake-format-modules.txt @@ -17,6 +17,7 @@ additional_commands: LIBNAME : '1' SOURCE_FILES : '*' HEADER_FILES : '*' + PRIVATE_HEADER_FILES : '*' LIBRARIES_TO_LINK : '*' TEST_SOURCES : '*' DEPRECATED_HEADER_FILES : '*' diff --git a/build-support/cmake-format.txt b/build-support/cmake-format.txt index 8b925366e..58d38a3dd 100644 --- a/build-support/cmake-format.txt +++ b/build-support/cmake-format.txt @@ -17,6 +17,7 @@ additional_commands: LIBNAME : '1' SOURCE_FILES : '*' HEADER_FILES : '*' + PRIVATE_HEADER_FILES : '*' LIBRARIES_TO_LINK : '*' TEST_SOURCES : '*' DEPRECATED_HEADER_FILES : '*' diff --git a/build-support/custom-modules/ns3-compiler-workarounds.cmake b/build-support/custom-modules/ns3-compiler-workarounds.cmake index 8b64ab8db..42e8d9dbe 100644 --- a/build-support/custom-modules/ns3-compiler-workarounds.cmake +++ b/build-support/custom-modules/ns3-compiler-workarounds.cmake @@ -55,17 +55,21 @@ endif() # link it manually. https://en.cppreference.com/w/cpp/filesystem check_cxx_source_compiles( " - # ifdef __cpp_lib_filesystem - #include - namespace fs = std::filesystem; - #else - #include - namespace fs = std::experimental::filesystem; + #ifdef __has_include + #if __has_include() + #include + namespace fs = std::filesystem; + #elif __has_include() + #include + namespace fs = std::experimental::filesystem; + #else + #error \"No support for filesystem library\" + #endif #endif int main() { std::string path = \"/\"; - return !fs::exists (path); + return !fs::exists(path); } " FILESYSTEM_LIBRARY_IS_LINKED diff --git a/build-support/custom-modules/ns3-module-macros.cmake b/build-support/custom-modules/ns3-module-macros.cmake index 963c59b5b..393041939 100644 --- a/build-support/custom-modules/ns3-module-macros.cmake +++ b/build-support/custom-modules/ns3-module-macros.cmake @@ -35,8 +35,14 @@ function(build_lib) # Argument parsing set(options IGNORE_PCH) set(oneValueArgs LIBNAME) - set(multiValueArgs SOURCE_FILES HEADER_FILES LIBRARIES_TO_LINK TEST_SOURCES - DEPRECATED_HEADER_FILES MODULE_ENABLED_FEATURES + set(multiValueArgs + SOURCE_FILES + HEADER_FILES + LIBRARIES_TO_LINK + TEST_SOURCES + DEPRECATED_HEADER_FILES + MODULE_ENABLED_FEATURES + PRIVATE_HEADER_FILES ) cmake_parse_arguments( "BLIB" "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} @@ -119,7 +125,7 @@ function(build_lib) ${lib${BLIB_LIBNAME}} PROPERTIES PUBLIC_HEADER - "${BLIB_HEADER_FILES};${BLIB_DEPRECATED_HEADER_FILES};${config_headers};${CMAKE_HEADER_OUTPUT_DIRECTORY}/${BLIB_LIBNAME}-module.h" + "${BLIB_HEADER_FILES};${BLIB_DEPRECATED_HEADER_FILES};${config_headers};${BLIB_PRIVATE_HEADER_FILES};${CMAKE_HEADER_OUTPUT_DIRECTORY}/${BLIB_LIBNAME}-module.h" RUNTIME_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} # set output # directory for # DLLs @@ -221,8 +227,8 @@ function(build_lib) # Copy all header files to outputfolder/include before each build copy_headers_before_building_lib( - ${BLIB_LIBNAME} ${CMAKE_HEADER_OUTPUT_DIRECTORY} "${BLIB_HEADER_FILES}" - public + ${BLIB_LIBNAME} ${CMAKE_HEADER_OUTPUT_DIRECTORY} + "${BLIB_HEADER_FILES};${BLIB_PRIVATE_HEADER_FILES}" public ) if(BLIB_DEPRECATED_HEADER_FILES) copy_headers_before_building_lib( @@ -231,6 +237,26 @@ function(build_lib) ) endif() + # Build lib examples if requested + set(examples_before ${ns3-execs-clean}) + foreach(example_folder example;examples) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${example_folder}) + if(${ENABLE_EXAMPLES}) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${example_folder}/CMakeLists.txt) + add_subdirectory(${example_folder}) + endif() + endif() + scan_python_examples(${CMAKE_CURRENT_SOURCE_DIR}/${example_folder}) + endif() + endforeach() + set(module_examples ${ns3-execs-clean}) + + # Filter only module examples + foreach(example ${examples_before}) + list(REMOVE_ITEM module_examples ${example}) + endforeach() + unset(examples_before) + # Check if the module tests should be built set(filtered_in ON) if(NS3_FILTER_MODULE_EXAMPLES_AND_TESTS) @@ -285,21 +311,24 @@ function(build_lib) if(${PRECOMPILE_HEADERS_ENABLED} AND (NOT ${BLIB_IGNORE_PCH})) target_precompile_headers(${test${BLIB_LIBNAME}} REUSE_FROM stdlib_pch) endif() + + # Add dependency between tests and examples used as tests + if(${ENABLE_EXAMPLES}) + foreach(source_file ${BLIB_TEST_SOURCES}) + file(READ ${source_file} source_file_contents) + foreach(example_as_test ${module_examples}) + string(FIND "${source_file_contents}" "${example_as_test}" + is_sub_string + ) + if(NOT (${is_sub_string} EQUAL -1)) + add_dependencies(test-runner-examples-as-tests ${example_as_test}) + endif() + endforeach() + endforeach() + endif() endif() endif() - # Build lib examples if requested - foreach(example_folder example;examples) - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${example_folder}) - if(${ENABLE_EXAMPLES}) - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${example_folder}/CMakeLists.txt) - add_subdirectory(${example_folder}) - endif() - endif() - scan_python_examples(${CMAKE_CURRENT_SOURCE_DIR}/${example_folder}) - endif() - endforeach() - # Handle package export install( TARGETS ${lib${BLIB_LIBNAME}} diff --git a/build-support/custom-modules/ns3-versioning.cmake b/build-support/custom-modules/ns3-versioning.cmake index 84b646011..a701ec4ab 100644 --- a/build-support/custom-modules/ns3-versioning.cmake +++ b/build-support/custom-modules/ns3-versioning.cmake @@ -30,8 +30,8 @@ function(check_git_repo_has_ns3_tags HAS_TAGS GIT_VERSION_TAG) endfunction() # Function to generate version fields from an ns-3 git repository -function(check_ns3_closest_tags CLOSEST_TAG VERSION_TAG_DISTANCE - VERSION_COMMIT_HASH VERSION_DIRTY_FLAG +function(check_ns3_closest_tags CLOSEST_TAG VERSION_COMMIT_HASH + VERSION_DIRTY_FLAG VERSION_TAG_DISTANCE ) execute_process( COMMAND ${GIT} describe --tags --dirty --long @@ -61,7 +61,7 @@ function(check_ns3_closest_tags CLOSEST_TAG VERSION_TAG_DISTANCE list(GET TAG_LIST 3 HASH) endif() - set(${VERSION_TAG_DISTANCE} ${DISTANCE} PARENT_SCOPE) + set(${VERSION_TAG_DISTANCE} "${DISTANCE}" PARENT_SCOPE) set(${VERSION_COMMIT_HASH} "${HASH}" PARENT_SCOPE) set(${VERSION_DIRTY_FLAG} 0 PARENT_SCOPE) @@ -100,8 +100,8 @@ function(configure_embedded_version) # If git tags were found, extract the information if(HAS_NS3_TAGS) check_ns3_closest_tags( - NS3_VERSION_CLOSEST_TAG NS3_VERSION_TAG_DISTANCE NS3_VERSION_COMMIT_HASH - NS3_VERSION_DIRTY_FLAG + NS3_VERSION_CLOSEST_TAG NS3_VERSION_COMMIT_HASH NS3_VERSION_DIRTY_FLAG + NS3_VERSION_TAG_DISTANCE ) # Split commit tag (ns-3.[.patch][-RC]) into # (ns;3.[.patch];[-RC]): @@ -131,15 +131,22 @@ function(configure_embedded_version) endif() # Transform list with 1 entry into strings + set(NS3_VERSION_TAG "${NS3_VERSION_TAG}") set(NS3_VERSION_MAJOR "${NS3_VERSION_MAJOR}") set(NS3_VERSION_MINOR "${NS3_VERSION_MINOR}") set(NS3_VERSION_PATCH "${NS3_VERSION_PATCH}") - set(NS3_VERSION_TAG "${NS3_VERSION_TAG}") set(NS3_VERSION_RELEASE_CANDIDATE "${RELEASE_CANDIDATE}") if(${NS3_VERSION_RELEASE_CANDIDATE} STREQUAL " ") set(NS3_VERSION_RELEASE_CANDIDATE \"\") endif() - set(NS3_VERSION_BUILD_PROFILE ${cmakeBuildType}) + + if(${cmakeBuildType} STREQUAL relwithdebinfo) + set(NS3_VERSION_BUILD_PROFILE default) + elseif((${cmakeBuildType} STREQUAL release) AND ${NS3_NATIVE_OPTIMIZATIONS}) + set(NS3_VERSION_BUILD_PROFILE optimized) + else() + set(NS3_VERSION_BUILD_PROFILE ${cmakeBuildType}) + endif() set(version_cache_file_template ${PROJECT_SOURCE_DIR}/build-support/version.cache.in @@ -189,6 +196,16 @@ function(configure_embedded_version) set(NS3_${varname} ${varvalue}) endforeach() set(NS3_VERSION_CLOSEST_TAG ${NS3_CLOSEST_TAG}) + + # We overwrite the build profile from version.cache with the current build + # profile + if(${cmakeBuildType} STREQUAL relwithdebinfo) + set(NS3_VERSION_BUILD_PROFILE default) + elseif((${cmakeBuildType} STREQUAL release) AND ${NS3_NATIVE_OPTIMIZATIONS}) + set(NS3_VERSION_BUILD_PROFILE optimized) + else() + set(NS3_VERSION_BUILD_PROFILE ${cmakeBuildType}) + endif() endif() set(DIRTY) diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index d2457ca31..c1cc2226e 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -293,6 +293,7 @@ macro(clear_global_cached_variables) unset(ns3-contrib-libs CACHE) unset(ns3-example-folders CACHE) unset(ns3-execs CACHE) + unset(ns3-execs-clean CACHE) unset(ns3-execs-py CACHE) unset(ns3-external-libs CACHE) unset(ns3-headers-to-module-map CACHE) @@ -306,6 +307,7 @@ macro(clear_global_cached_variables) ns3-contrib-libs ns3-example-folders ns3-execs + ns3-execs-clean ns3-execs-py ns3-external-libs ns3-headers-to-module-map @@ -434,7 +436,7 @@ macro(process_options) if(${NS3_CLANG_FORMAT}) find_program(CLANG_FORMAT clang-format) if("${CLANG_FORMAT}" STREQUAL "CLANG_FORMAT-NOTFOUND") - message(${HIGHLIGHTED_STATUS} "Proceeding without clang-format") + message(FATAL_ERROR "Clang-format was not found") else() file( GLOB_RECURSE @@ -449,7 +451,7 @@ macro(process_options) scratch/*.h ) add_custom_target( - clang-format COMMAND clang-format -style=file -i + clang-format COMMAND ${CLANG_FORMAT} -style=file -i ${ALL_CXX_SOURCE_FILES} ) unset(ALL_CXX_SOURCE_FILES) @@ -457,13 +459,13 @@ macro(process_options) endif() if(${NS3_CLANG_TIDY}) - find_program(CLANG_TIDY clang-tidy) + find_program( + CLANG_TIDY NAMES clang-tidy clang-tidy-14 clang-tidy-15 clang-tidy-16 + ) if("${CLANG_TIDY}" STREQUAL "CLANG_TIDY-NOTFOUND") - message(${HIGHLIGHTED_STATUS} - "Proceeding without clang-tidy static analysis" - ) + message(FATAL_ERROR "Clang-tidy was not found") else() - set(CMAKE_CXX_CLANG_TIDY "clang-tidy") + set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY}") endif() else() unset(CMAKE_CXX_CLANG_TIDY) @@ -832,6 +834,35 @@ macro(process_options) configure_file( bindings/python/ns__init__.py ${destination_dir}/__init__.py COPYONLY ) + + # And create an install target for the bindings + if(NOT NS3_BINDINGS_INSTALL_DIR) + # If the installation directory for the python bindings is not set, + # suggest the user site-packages directory + execute_process( + COMMAND python3 -m site --user-site + OUTPUT_VARIABLE SUGGESTED_BINDINGS_INSTALL_DIR + ) + string(STRIP "${SUGGESTED_BINDINGS_INSTALL_DIR}" + SUGGESTED_BINDINGS_INSTALL_DIR + ) + message( + ${HIGHLIGHTED_STATUS} + "NS3_BINDINGS_INSTALL_DIR was not set. The python bindings won't be installed with ./ns3 install." + ) + message( + ${HIGHLIGHTED_STATUS} + "Set NS3_BINDINGS_INSTALL_DIR=\"${SUGGESTED_BINDINGS_INSTALL_DIR}\" to install it to the default location." + ) + else() + install(FILES bindings/python/ns__init__.py + DESTINATION ${NS3_BINDINGS_INSTALL_DIR}/ns RENAME __init__.py + ) + add_custom_target( + uninstall_bindings COMMAND rm -R ${NS3_BINDINGS_INSTALL_DIR}/ns + ) + add_dependencies(uninstall uninstall_bindings) + endif() endif() endif() @@ -859,6 +890,7 @@ macro(process_options) endif() if(${ENABLE_TESTS}) + add_custom_target(test-runner-examples-as-tests) add_custom_target(all-test-targets) # Create a custom target to run test.py --no-build Target is also used to @@ -927,20 +959,6 @@ macro(process_options) endif() endif() - if(${NS3_GNUPLOT}) - find_package(Gnuplot-ios) # Not sure what package would contain the correct - # header/library - if(NOT ${GNUPLOT_FOUND}) - message(${HIGHLIGHTED_STATUS} - "GNUPLOT was not found. Continuing without it." - ) - else() - message(STATUS "GNUPLOT was found.") - include_directories(${GNUPLOT_INCLUDE_DIRS}) - link_directories(${GNUPLOT_LIBRARY}) - endif() - endif() - # checking for documentation dependencies and creating targets # First we check for doxygen dependencies @@ -1373,6 +1391,10 @@ function(set_runtime_outputdirectory target_name output_directory target_prefix) set(ns3-execs "${output_directory}${ns3-exec-outputname};${ns3-execs}" CACHE INTERNAL "list of c++ executables" ) + set(ns3-execs-clean "${target_prefix}${target_name};${ns3-execs-clean}" + CACHE INTERNAL + "list of c++ executables without version prefix and build suffix" + ) set_target_properties( ${target_prefix}${target_name} @@ -2012,9 +2034,17 @@ function(find_external_library) set(library_dirs) set(libraries) + # Include parent directories in the search paths to handle Bake cases + get_filename_component(parent_project_dir ${PROJECT_SOURCE_DIR} DIRECTORY) + get_filename_component( + grandparent_project_dir ${parent_project_dir} DIRECTORY + ) + set(project_parent_dirs ${parent_project_dir} ${grandparent_project_dir}) + # Paths and suffixes where libraries will be searched on set(library_search_paths ${search_paths} + ${project_parent_dirs} ${CMAKE_OUTPUT_DIRECTORY} # Search for libraries in ns-3-dev/build ${CMAKE_INSTALL_PREFIX} # Search for libraries in the install directory # (e.g. /usr/) @@ -2126,8 +2156,9 @@ function(find_external_library) endforeach() set(header_search_paths - ${parent_dirs} ${search_paths} + ${parent_dirs} + ${project_parent_dirs} ${CMAKE_OUTPUT_DIRECTORY} # Search for headers in # ns-3-dev/build ${CMAKE_INSTALL_PREFIX} # Search for headers in the install diff --git a/doc/contributing/source/coding-style.rst b/doc/contributing/source/coding-style.rst index 81e3a924b..4ef3ac654 100644 --- a/doc/contributing/source/coding-style.rst +++ b/doc/contributing/source/coding-style.rst @@ -45,8 +45,8 @@ to produce consistent output among themselves. Integration with IDEs ===================== -Clang-format automatically integrates with modern IDEs (e.g., VS Code) that read the -``.clang-format`` file and automatically formats the code on save or on typing. +Clang-format can be integrated with modern IDEs (e.g., VS Code) that are able to +read the ``.clang-format`` file and automatically format the code on save or on typing. Please refer to the documentation of your IDE for more information. Some examples of IDE integration are provided in @@ -63,22 +63,24 @@ and on type by enabling the following settings: "editor.formatOnType": true, } -Manual usage in the terminal -============================ +Clang-format usage in the terminal +================================== -Clang-format can be manually run on the terminal by applying the following commands: +In addition to IDE support, clang-format can be manually run on the terminal. + +To format a file in-place, run the following command: .. sourcecode:: console clang-format -i $FILE -To check that a file is properly formatted, run the following command on the terminal. -If the code is well formatted, the process will exit with code 0; if is not, it will -exit with code of 1 and indicate the lines that should be formatted. +To check that a file is well formatted, run the following command on the terminal. +If the file is not well formatted, clang-format indicates the lines that need to be +formatted. .. sourcecode:: console - clang-format --dry-run --Werror $FILE + clang-format --dry-run $FILE Clang-format Git integration ============================ @@ -104,7 +106,7 @@ C++ comments [example adopted from ... // clang-format on -To exclude the whole file from being formatted, surround the whole file with the +To exclude an entire file from being formatted, surround the whole file with the special comments. check-style-clang-format.py @@ -131,6 +133,10 @@ flags: ``--no-formatting``, ``--no-whitespace`` and ``--no-tabs``. In addition to checking the files, the script can automatically fix detected issues in-place. This mode is enabled by adding the ``--fix`` flag. +The formatting and tabs checks respect clang-format guards, which mark code blocks +that should not be checked. Trailing whitespace is always checked regardless of +clang-format guards. + The complete API of the ``check-style-clang-format.py`` script can be obtained with the following command: @@ -142,11 +148,11 @@ For quick-reference, the most used commands are listed below: .. sourcecode:: console - # Entire codebase (using paths relative to the ns-3 root) + # Entire codebase (using paths relative to the ns-3 main directory) ./utils/check-style-clang-format.py [--fix] [--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/root + /path/to/utils/check-style-clang-format.py [--fix] [--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 @@ -162,6 +168,10 @@ The |ns3| project uses `clang-tidy `_ to statically analyze (lint) C++ code and help developers write better code. Clang-tidy can be easily integrated with modern IDEs or run manually on the command-line. +The list of clang-tidy checks currently enabled in the |ns3| project is saved on the +``.clang-tidy`` file. The full list of clang-tidy checks and their detailed explanations +can be seen in `Clang-tidy checks `_. + Clang-tidy installation ======================= @@ -193,22 +203,31 @@ Please refer to the documentation of your IDE for more information. Some examples of IDE integration are provided in `clang-tidy documentation `_ -Manual usage in the terminal -============================ +Clang-tidy usage +================ -In order to use clang-tidy on the terminal, |ns3| must first be configured by running -the following command on the terminal: +In order to use clang-tidy, |ns3| must first be configured with the flag +``--enable-clang-tidy``. To configure |ns3| with tests, examples and clang-tidy enabled, +run the following command: .. sourcecode:: console - ./ns3 configure --enable-clang-tidy + ./ns3 configure --enable-examples --enable-tests --enable-clang-tidy -Then, clang-tidy can be manually run on the terminal by applying the following commands -in the |ns3| root directory: +Due to the integration of clang-tidy with CMake, clang-tidy can be run while building +|ns3|. In this way, clang-tidy errors will be shown alongside build errors on the terminal. +To build |ns3| and run clang-tidy, run the the following command: .. sourcecode:: console - # Analyze (and fix) single file with clang-tidy + ./ns3 build + +To run clang-tidy without building |ns3|, use the following commands on the ns-3 +main directory: + +.. sourcecode:: console + + # Analyze (and fix) a single file with clang-tidy clang-tidy -p cmake-cache/ [--fix] [--format-style=file] [--quiet] $FILE # Analyze (and fix) multiple files in parallel @@ -217,27 +236,19 @@ in the |ns3| root directory: # Analyze (and fix) the entire ns-3 codebase in parallel run-clang-tidy -p cmake-cache/ [-fix] [-format] [-quiet] -Please note that clang-tidy only analyzes implementation files (i.e., ``*.cc`` files). -Header files are analyzed when they are included by implementation files, using the -``#include "..."`` directive. +When running clang-tidy, please note that: -Integration with CMake -====================== +- Clang-tidy only analyzes implementation files (i.e., ``*.cc`` files). + Header files are analyzed when they are included by implementation files, with the + ``#include "..."`` directive. -CMake provides native integration for clang-tidy. This allows CMake to simultaneously -build |ns3| and scan the codebase with clang-tidy. To enable this process, please -use the following commands on the |ns3| root directory: +- Not all clang-tidy checks provide automatic fixes. For those cases, a manual fix + must be made by the developer. -.. sourcecode:: console +- Enabling clang-tidy will add time to the build process (in the order of minutes). - ./ns3 configure --enable-clang-tidy - ./ns3 build - -Please note that enabling clang-tidy scanning will add time to the build process -(in the order of minutes). - -Disable analysis in specific lines -================================== +Disable clang-tidy analysis in specific lines +============================================= To disable clang-tidy analysis of a particular rule in a specific function, specific clang-tidy comments have to be added to the corresponding function. @@ -262,8 +273,9 @@ following two "special comment" syntaxes: void func(); // NOLINT(modernize-use-override) -To disable ``modernize-use-override`` checking on a block of code, use the -following "special comment" syntax: +To disable a specific clang-tidy check on a block of code, for instance the +``modernize-use-override`` check, surround the code block with the following +"special comments": .. sourcecode:: cpp @@ -273,8 +285,8 @@ following "special comment" syntax: // NOLINTEND(modernize-use-override) -To disable all clang-tidy checks on a block of code, use the following -"special comment" syntax: +To disable all clang-tidy checks on a block of code, surround it with the +following "special comments": .. sourcecode:: cpp @@ -283,8 +295,8 @@ To disable all clang-tidy checks on a block of code, use the following void func2(); // NOLINTEND -To exclude the whole file from being formatted, surround the whole file with the -special comments. +To exclude an entire file from being checked, surround the whole file with the +"special comments". Source code formatting ********************** @@ -428,7 +440,7 @@ Separate each block with a new line. class MyClass { public: - static counter = 0; + static int m_counter = 0; MyClass(int x, int y); @@ -459,8 +471,8 @@ The constructor initializers are always declared one per line, with a trailing c void MyClass::MyClass(int x, int y) - : m_x (x), - m_y (y) + : m_x(x), + m_y(y) { } @@ -492,7 +504,7 @@ declaration: .. sourcecode:: cpp template - void func(T t); + void Func(T t); Naming ====== @@ -592,10 +604,8 @@ and implemented in a source file named ``my-class.cc``. The goal of this naming pattern is to allow a reader to quickly navigate through the |ns3| codebase to locate the source file relevant to a specific type. -Each ``my-class.h`` header should start with the following comments: the -first line ensures that developers who use the emacs editor will be able to -indent your code correctly. The following lines ensure that your code -is licensed under the GPL, that the copyright holders are properly +Each ``my-class.h`` header should start with the following comment to ensure +that your code is licensed under the GPL, that the copyright holders are properly identified (typically, you or your employer), and that the actual author of the code is identified. The latter is purely informational and we use it to try to track the most appropriate person to review a patch or fix a bug. @@ -604,7 +614,6 @@ statement. .. sourcecode:: cpp - /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) YEAR COPYRIGHTHOLDER * @@ -675,7 +684,6 @@ The ``my-class.cc`` file is structured similarly: .. sourcecode:: cpp - /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) YEAR COPYRIGHTHOLDER * @@ -885,57 +893,108 @@ Compilers will typically issue warnings on unused entities (e.g., variables, function parameters). Use the ``[[maybe_unused]]`` attribute to suppress such warnings when the entity may be unused depending on how the code is compiled (e.g., if the entity is only used in a logging statement or -an assert statement). Example (parameter ``p`` is only used for logging): +an assert statement). -.. sourcecode:: cpp +The general guidelines are as follows: - void - TcpSocketBase::CompleteFork(Ptr p [[maybe_unused]], - const TcpHeader& h, - const Address& fromAddress, - const Address& toAddress) - { - NS_LOG_FUNCTION(this << p << h << fromAddress << toAddress); - ... - } +- If a function's or a method's parameter is definitely unused, + prefer to leave it unnamed. In the following example, the second + parameter is unnamed. -In function or method parameters, if the parameter is definitely unused, -it should be left unnamed. Example (second parameter is not used): + .. sourcecode:: cpp -.. sourcecode:: cpp + void + UanMacAloha::RxPacketGood(Ptr pkt, double, UanTxMode txMode) + { + UanHeaderCommon header; + pkt->RemoveHeader(header); + ... + } - void - UanMacAloha::RxPacketGood(Ptr pkt, double, UanTxMode txMode) - { - UanHeaderCommon header; - pkt->RemoveHeader(header); - ... - } + In this case, the parameter is also not referenced by Doxygen; e.g.,: -In this case, the parameter is also not referenced by Doxygen; e.g.,: + .. sourcecode:: cpp -.. sourcecode:: cpp + /** + * Receive packet from lower layer (passed to PHY as callback). + * + * \param pkt Packet being received. + * \param txMode Mode of received packet. + */ + void RxPacketGood(Ptr pkt, double, UanTxMode txMode); - /** - * Receive packet from lower layer (passed to PHY as callback). - * - * \param pkt Packet being received. - * \param txMode Mode of received packet. - */ - void RxPacketGood(Ptr pkt, double, UanTxMode txMode); + The omission is preferred to commenting out unused parameters, such as: -The omission is preferred to commenting out unused parameters, such as: + .. sourcecode:: cpp -.. sourcecode:: cpp + void + UanMacAloha::RxPacketGood(Ptr pkt, double /*sinr*/, UanTxMode txMode) + { + UanHeaderCommon header; + pkt->RemoveHeader(header); + ... + } - void - UanMacAloha::RxPacketGood(Ptr pkt, double /*sinr*/, UanTxMode txMode) - { - UanHeaderCommon header; - pkt->RemoveHeader(header); - ... - } +- If a function's parameter is only used in certain cases (e.g., logging), + or it is part of the function's Doxygen, mark it as ``[[maybe_unused]]``. + .. sourcecode:: cpp + + void + TcpSocketBase::CompleteFork(Ptr p [[maybe_unused]], + const TcpHeader& h, + const Address& fromAddress, + const Address& toAddress) + { + NS_LOG_FUNCTION(this << p << h << fromAddress << toAddress); + + // Remaining code that definitely uses 'h', 'fromAddress' and 'toAddress' + ... + } + +- If a local variable saves the result of a function that must always run, + but whose value may not be used, declare it ``[[maybe_unused]]``. + + .. sourcecode:: cpp + + void + MyFunction() + { + int result [[maybe_unused]] = MandatoryFunction(); + NS_LOG_DEBUG("result = " << result); + } + +- If a local variable saves the result of a function that is only run in + certain cases, prefer to not declare the variable and use the function's + return value directly where needed. This avoids unnecessarily calling the + function if its result is not used. + + .. sourcecode:: cpp + + void + MyFunction() + { + // Prefer to call GetDebugInfo() directly on the log statement + NS_LOG_DEBUG("Debug information: " << GetDebugInfo()); + + // Avoid declaring a local variable with the result of GetDebugInfo() + int debugInfo [[maybe_unused]] = GetDebugInfo(); + NS_LOG_DEBUG("Debug information: " << debugInfo); + } + + If the calculation of the maybe unused variable is complex, consider wrapping + the calculation of its value in a conditional block that is only run if the + variable is used. + + .. sourcecode:: cpp + + if (g_log.IsEnabled(ns3::LOG_DEBUG)) + { + auto debugInfo = GetDebugInfo(); + auto value = DoComplexCalculation(debugInfo); + + NS_LOG_DEBUG("The value is " << value); + } Unnecessary else after return ============================= @@ -978,23 +1037,23 @@ the |ns3| smart pointer class ``Ptr`` should be used in boolean comparisons as f .. sourcecode:: cpp - for Ptr<> p, do not use: use instead: - ======================== ================================= - if (p != 0) {...} if (p) {...} - if (p != NULL) {...} - if (p != nullptr {...} + for Ptr<> p, do not use: use instead: + ======================== ================================= + if (p != nullptr) {...} if (p) {...} + if (p != NULL) {...} + if (p != 0) {...} if (p) {...} - if (p == 0) {...} if (!p) {...} - if (p == NULL) {...} - if (p == nullptr {...} + if (p == nullptr) {...} if (!p) {...} + if (p == NULL) {...} + if (p == 0) {...} - NS_ASSERT... (p != 0, ...) NS_ASSERT... (p, ...) - NS_ABORT... (p != 0, ...) NS_ABORT... (p, ...) + NS_ASSERT... (p != nullptr, ...) NS_ASSERT... (p, ...) + NS_ABORT... (p != nullptr, ...) NS_ABORT... (p, ...) - NS_ASSERT... (p == 0, ...) NS_ASSERT... (!p, ...) - NS_ABORT... (p == 0, ...) NS_ABORT... (!p, ...) + NS_ASSERT... (p == nullptr, ...) NS_ASSERT... (!p, ...) + NS_ABORT... (p == nullptr, ...) NS_ABORT... (!p, ...) - NS_TEST... (p, 0, ...) NS_TEST... (p, nullptr, ...) + NS_TEST... (p, nullptr, ...) NS_TEST... (p, nullptr, ...) C++ standard ============ @@ -1009,16 +1068,10 @@ language support forward as our minimally supported compiler moves forward. Miscellaneous items =================== -- The following emacs mode line should be the first line in a file: - - .. sourcecode:: cpp - - /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ - - ``NS_LOG_COMPONENT_DEFINE("log-component-name");`` statements should be placed within namespace ns3 (for module code) and after the - ``using namespace ns3;``. In examples. - ``NS_OBJECT_ENSURE_REGISTERED()`` should also be placed within namespace ns3. + ``using namespace ns3;``. In examples, + ``NS_OBJECT_ENSURE_REGISTERED()`` should also be placed within namespace ``ns3``. - Pointers and references are left-aligned: @@ -1036,10 +1089,10 @@ Miscellaneous items void MySub(T const& t); // Not OK - Do not include inline implementations in header files; put all - implementation in a .cc file (unless implementation in the header file + implementation in a ``.cc`` file (unless implementation in the header file brings demonstrable and significant performance improvement). -- Do not use ``nil``, ``NULL`` or ``0`` constants; use ``nullptr`` (improves portability) +- Do not use ``NULL``, ``nil`` or ``0`` constants; use ``nullptr`` (improves portability) - Consider whether you want the default constructor, copy constructor, or assignment operator in your class. If not, explicitly mark them as deleted and make the @@ -1047,28 +1100,35 @@ Miscellaneous items .. sourcecode:: cpp - public: - // Explain why these are not supported - ClassName() = delete; - ClassName(const ClassName&) = delete; - ClassName& operator=(const ClassName&) = delete; + class MyClass + { + public: + // Allowed constructors + MyClass(int i); + + // Deleted constructors. + // Explain why they are not supported. + MyClass() = delete; + MyClass(const MyClass&) = delete; + MyClass& operator=(const MyClass&) = delete; + }; - Avoid returning a reference to an internal or local member of an object: .. sourcecode:: cpp - a_type& foo(); // should be avoided, return a pointer or an object. - const a_type& foo(); // same as above + MyType& foo(); // Avoid. Prefer to return a pointer or an object. + const MyType& foo(); // Same as above. This guidance does not apply to the use of references to implement operators. - Expose class members through access functions, rather than direct access to a public object. The access functions are typically named ``Get`` and - ``Set``. For example, a member ``m_delayTime`` might have accessor functions - ``GetDelayTime()`` and ``SetDelayTime()``. + ``Set`` followed by the member's name. For example, a member ``m_delayTime`` + might have accessor functions ``GetDelayTime()`` and ``SetDelayTime()``. - Do not bring the C++ standard library namespace into |ns3| source files by - using the ``using`` directive; i.e., avoid ``using namespace std;``. + using the ``using namespace std;`` directive. - Do not use the C++ ``goto`` statement. @@ -1083,7 +1143,7 @@ of rules that should be observed while developing code. - Prefer to use ``.emplace_back()`` over ``.push_back()`` to optimize performance. - When creating STL smart pointers, prefer to use ``std::make_shared`` or - ``std::make_unique``, instead of creating the pointer with ``new``: + ``std::make_unique``, instead of creating the smart pointer with ``new``. .. sourcecode:: cpp @@ -1091,21 +1151,21 @@ of rules that should be observed while developing code. auto node = std::shared_ptr(new Node()); // Avoid - When looping through containers, prefer to use range-based for loops rather than - index-based loops: + index-based loops. .. sourcecode:: cpp - std::vector myVector = {1, 2, 3}; + std::vector myVector{1, 2, 3}; for (const auto& v : myVector) { ... } // Prefer for (int i = 0; i < myVector.size(); i++) { ... } // Avoid - When looping through containers, prefer to use const-ref syntax over copying - elements: + elements. .. sourcecode:: cpp - std::vector myVector = {1, 2, 3}; + std::vector myVector{1, 2, 3}; for (const auto& v : myVector) { ... } // OK for (auto v : myVector) { ... } // Avoid @@ -1115,21 +1175,23 @@ of rules that should be observed while developing code. .. sourcecode:: cpp - int N_ITEMS = 5; + constexpr int N_ITEMS = 5; + std::vector myVector; - myVector.reserve(N_ITEMS); // Reserve memory required to store all items + myVector.reserve(N_ITEMS); // Reserve memory to store all items + for (int i = 0; i < N_ITEMS; i++) { myVector.emplace_back(i); } - Prefer to initialize STL containers (e.g., ``std::vector``, ``std::map``, etc.) - directly with lists, instead of pushing elements one-by-one. + directly with a braced-init-list, instead of pushing elements one-by-one. .. sourcecode:: cpp // OK - std::vector myVector = {1, 2, 3}; + std::vector myVector{1, 2, 3}; // Avoid std::vector myVector; @@ -1141,6 +1203,20 @@ of rules that should be observed while developing code. - Avoid unnecessary calls to the functions ``.c_str()`` and ``.data()`` of ``std::string``. +- Avoid unnecessarily dereferencing std smart pointers (``std::shared_ptr``, + ``std::unique_ptr``) with calls to their member function ``.get()``. + Prefer to use the std smart pointer directly where needed. + + .. sourcecode:: cpp + + auto ptr = std::make_shared(); + + // OK + if (ptr) { ... } + + // Avoid + if (ptr.get()) { ... } + - Avoid declaring trivial destructors, to optimize performance. - Prefer to use ``static_assert()`` over ``NS_ASSERT()`` when conditions can be diff --git a/doc/contributing/source/conf.py b/doc/contributing/source/conf.py index c5be02179..c11609c0c 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-dev' +version = 'ns-3.37' # The full version, including alpha/beta/rc tags. -release = 'ns-3-dev' +release = 'ns-3.37' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/doxygen.conf b/doc/doxygen.conf index 9007f6097..0fd6387d5 100644 --- a/doc/doxygen.conf +++ b/doc/doxygen.conf @@ -70,7 +70,7 @@ OUTPUT_DIRECTORY = doc # performance problems for the file system. # The default value is: NO. -CREATE_SUBDIRS = NO +CREATE_SUBDIRS = YES # If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII # characters to appear in the names of generated files. If set to NO, non-ASCII @@ -2671,7 +2671,7 @@ DOT_TRANSPARENT = NO # The default value is: NO. # This tag requires that the tag HAVE_DOT is set to YES. -DOT_MULTI_TARGETS = NO +DOT_MULTI_TARGETS = YES # If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page # explaining the meaning of the various boxes and arrows in the dot generated diff --git a/doc/manual/Makefile b/doc/manual/Makefile index 1c6bd19bf..4fff33698 100644 --- a/doc/manual/Makefile +++ b/doc/manual/Makefile @@ -45,6 +45,7 @@ SOURCES = \ source/tracing.rst \ source/troubleshoot.rst \ source/utilities.rst \ + source/windows.rst \ source/working-with-cmake.rst \ source/working-with-git.rst \ source/working-with-gitlab-ci-local.rst \ diff --git a/doc/manual/source/conf.py b/doc/manual/source/conf.py index 46a0f3ba6..dd6f7bd1d 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-dev' +version = u'ns-3.37' # The full version, including alpha/beta/rc tags. -release = u'ns-3-dev' +release = u'ns-3.37' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/manual/source/develop.rst b/doc/manual/source/develop.rst index 81e9faf88..545175eed 100644 --- a/doc/manual/source/develop.rst +++ b/doc/manual/source/develop.rst @@ -17,4 +17,5 @@ This chapter describes the development ecosystem generally used to create new mo documentation profiling working-with-gitlab-ci-local + windows diff --git a/doc/manual/source/profiling.rst b/doc/manual/source/profiling.rst index f6700a766..d27d3df32 100644 --- a/doc/manual/source/profiling.rst +++ b/doc/manual/source/profiling.rst @@ -225,13 +225,13 @@ If you prefer to use the ``ns3`` wrapper, try: .. sourcecode:: console - ~ns-3-dev/$ ./ns3 run "wifi-he-network --simulationTime=0.3 --frequency=5 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=745" --command-template "heaptrack %s" --no-build + ~ns-3-dev/$ ./ns3 run "wifi-he-network --simulationTime=0.3 --frequency=5 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=745" --heaptrack --no-build In both cases, heaptrack will print to the terminal the output file: .. sourcecode:: console - ~ns-3-dev/$ ./ns3 run "wifi-he-network --simulationTime=0.3 --frequency=5 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=745" --command-template "heaptrack %s" --no-build + ~ns-3-dev/$ ./ns3 run "wifi-he-network --simulationTime=0.3 --frequency=5 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=745" --heaptrack --no-build heaptrack output will be written to "~ns-3-dev/heaptrack.ns3-dev-wifi-he-network.210305.zst" starting application, this might take some time... MCS value Channel width GI Throughput @@ -388,6 +388,79 @@ were removed, which translates to a 20% reduction. This resulted in a 1.07x spee test suite with Valgrind (``./test.py -d -g``) and 1.02x speedup without it. +Memray +++++++ + +.. _Memray : https://bloomberg.github.io/memray/ + +`Memray`_ is an utility made by Bloomberg to trace memory allocations of Python programs, +including native code called by them. Along with stack traces, developers can trace down +possible memory leaks and unnecessary allocations. + +Note: Memray is ineffective for profiling the ns-3 python bindings since Cppyy hides away +the calls to the ns-3 module libraries. However, it is still useful for python scripts +in general, for example ones used to parse and consolidate simulation results. + +The ``ns3`` script includes a run option to launch Python programs with Memray. +Memray can produce different types of reports, such as a flamegraph in HTML, or +text reports (``summary`` and ``stats``). + +.. sourcecode:: console + + ~/ns-3-dev/$ ./ns3 run sample-rng-plot.py --memray + Writing profile results into memray.output + Memray WARNING: Correcting symbol for aligned_alloc from 0x7fd97023c890 to 0x7fd97102fce0 + [memray] Successfully generated profile results. + + You can now generate reports from the stored allocation records. + Some example commands to generate reports: + + /usr/bin/python3 -m memray flamegraph memray.output + ~/ns-3-dev$ /usr/bin/python3 -m memray stats memray.output + Total allocations: + 5364235 + + Total memory allocated: + 10.748GB + + Histogram of allocation size: + min: 0.000B + ---------------------------------------------- + < 8.000B : 264149 ||| + < 78.000B : 2051906 ||||||||||||||||||||||| + < 699.000B : 2270941 ||||||||||||||||||||||||| + < 6.064KB : 608993 ||||||| + < 53.836KB : 165307 || + < 477.912KB: 2220 | + < 4.143MB : 511 | + < 36.779MB : 188 | + < 326.492MB: 19 | + <=2.830GB : 1 | + ---------------------------------------------- + max: 2.830GB + + Allocator type distribution: + MALLOC: 4647765 + CALLOC: 435525 + REALLOC: 277736 + POSIX_MEMALIGN: 2686 + MMAP: 523 + + Top 5 largest allocating locations (by size): + - include:/usr/local/lib/python3.10/dist-packages/cppyy/__init__.py:243 -> 8.814GB + - -> 746.999MB + - show:~/.local/lib/python3.10/site-packages/matplotlib/backends/backend_gtk4.py:340 -> 263.338MB + - load_library:/usr/local/lib/python3.10/dist-packages/cppyy/__init__.py:235 -> 245.684MB + - __init__:/usr/lib/python3.10/ctypes/__init__.py:374 -> 225.797MB + + Top 5 largest allocating locations (by number of allocations): + - include:/usr/local/lib/python3.10/dist-packages/cppyy/__init__.py:243 -> 2246145 + - show:~/.local/lib/python3.10/site-packages/matplotlib/backends/backend_gtk4.py:340 -> 1264614 + - -> 1098543 + - __init__:~/.local/lib/python3.10/site-packages/matplotlib/backends/backend_gtk4.py:61 -> 89466 + - run:/usr/lib/python3/dist-packages/gi/overrides/Gio.py:42 -> 79582 + + Performance Profilers ********************* @@ -458,6 +531,63 @@ to the ``perf.data`` output file. ~/ns-3-dev$ ./ns3 run "wifi-he-network --simulationTime=0.3 --frequency=5 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=745" --command-template "perf record -o ./perf.data --call-graph dwarf --event cycles,cache-misses,branch-misses --sample-cpu %s" --no-build +For ease of use, ``ns3`` also provides the ``--perf`` run option, that +include the recommended settings. + +.. sourcecode:: console + + ~/ns-3-dev$ ./ns3 run "wifi-he-network --simulationTime=0.3 --frequency=5 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=745" --perf --no-build + +When running for the first time, you may receive the following error: + +.. sourcecode:: console + + ~/ns-3-dev$ ./ns3 run "wifi-he-network --simulationTime=0.3 --frequency=5 --useRts=1 --minExpectedThroughput=6 --maxExpectedThroughput=745" --perf --no-build + Error: + Access to performance monitoring and observability operations is limited. + Consider adjusting /proc/sys/kernel/perf_event_paranoid setting to open + access to performance monitoring and observability operations for processes + without CAP_PERFMON, CAP_SYS_PTRACE or CAP_SYS_ADMIN Linux capability. + More information can be found at 'Perf events and tool security' document: + https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html + perf_event_paranoid setting is 1: + -1: Allow use of (almost) all events by all users + Ignore mlock limit after perf_event_mlock_kb without CAP_IPC_LOCK + >= 0: Disallow raw and ftrace function tracepoint access + >= 1: Disallow CPU event access + >= 2: Disallow kernel profiling + To make the adjusted perf_event_paranoid setting permanent preserve it + in /etc/sysctl.conf (e.g. kernel.perf_event_paranoid = ) + Command 'build/examples/wireless/ns3-dev-wifi-he-network-default record --call-graph dwarf -a -e cache-misses,branch-misses,cpu-cycles,instructions,context-switches build/examples/wireless/ns3-dev-wifi-he-network-default -n=100' returned non-zero exit status 255. + +This error is related to lacking permissions to access performance events from the kernel and CPU. +As said in the error, permissions can be granted for the current session +by changing the ``perf_event_paranoid`` setting with ``echo 0 > /proc/sys/kernel/perf_event_paranoid``. +This change can be made permanent by changing the setting in ``/etc/sysctl.conf``, but +this is not recommended. Administrative permissions (``sudo su``) are required in both cases. + +After the program finishes, it will print recording statistics. + +.. sourcecode:: console + + MCS value Channel width GI Throughput + 0 20 MHz 3200 ns 6.01067 Mbit/s + 0 20 MHz 1600 ns 5.936 Mbit/s + ... + 11 160 MHz 1600 ns 493.397 Mbit/s + 11 160 MHz 800 ns 534.016 Mbit/s + [ perf record: Woken up 9529 times to write data ] + Warning: + Processed 517638 events and lost 94 chunks! + + Check IO/CPU overload! + + Warning: + 1 out of order events recorded. + [ perf record: Captured and wrote 2898,307 MB perf.data (436509 samples) ] + + +Results saved in ``perf.data`` can be reviewed with the ``perf report`` command. `Hotspot`_ is a GUI for Perf, that makes performance profiling more enjoyable and productive. It can parse the ``perf.data`` and show in diff --git a/doc/manual/source/python.rst b/doc/manual/source/python.rst index eb823efc7..6afc2f4bd 100644 --- a/doc/manual/source/python.rst +++ b/doc/manual/source/python.rst @@ -15,6 +15,8 @@ Python bindings allow the C++ code in |ns3| to be called from Python. This chapter shows you how to create a Python script that can run |ns3| and also the process of creating Python bindings for a C++ |ns3| module. +Python bindings are also needed to run the Pyviz visualizer. + Introduction ************ @@ -25,18 +27,25 @@ Python, to allow integration of |ns3| with other Python tools and workflows. The intent is not to provide a different language choice to author new |ns3| models implemented in Python. +As of ns-3.37 release or later, Python bindings for |ns3| use a tool called Cppyy (https://cppyy.readthedocs.io/en/latest/) to create a Python module from the C++ libraries built by CMake. The Python bindings that Cppyy -uses are built at runtime, by importing the C++ libraries and headers for each ns-3 module. +uses are built at runtime, by importing the C++ libraries and headers for each |ns3| module. This means that even if the C++ API changes, the Python bindings will adapt to them without requiring any preprocessing or scanning. If a user is not interested in Python, no action is needed; the Python bindings -are only built on-demand by Cppyy. +are only built on-demand by Cppyy, and only if the user enables them in the +configuration of |ns3|. -As of ns-3.37, the previous Python bindings framework based on Pybindgen has been -removed due to a lack of active maintainers. The Cppyy frameword that replaced -it may also be removed from future ns-3 releases if new maintainers are not found. +It is also important to note that the current capability is provided on a +lightly maintained basis and not officially supported by the project +(in other words, we are currently looking for a Python bindings maintainer). +The Cppyy framework could be replaced if it becomes too burdensome to +maintain as we are presently doing. + +Prior to ns-3.37, the previous Python bindings framework was based on +`Pybindgen `_. An Example Python Script that Runs |ns3| **************************************** @@ -92,11 +101,32 @@ 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 +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: + +.. sourcecode:: bash + + $ python3 + Python 3.8.10 (default, Jun 22 2022, 20:18:18) + [GCC 9.4.0] on linux + Type "help", "copyright", "credits" or "license" for more information. + >>> import cppyy + >>> + +If not, you may try to install via `pip` or whatever other manager you are +using; e.g.: + +.. sourcecode:: bash + + $ python3 -m pip install --user cppyy + First, we need to enable the build of Python bindings: .. sourcecode:: bash - $ ./ns3 configure + $ ./ns3 configure --enable-python-bindings Other options such as ``--enable-examples`` may be passed to the above command. ns3 contains some options that automatically update the python path to find the ns3 module. @@ -138,7 +168,7 @@ To run your own Python script that calls |ns3| and that has this path, ``/path/t Caveats ******* -Some of the limitations of the Cppyy-based byindings are listed here. +Some of the limitations of the Cppyy-based bindings are listed here. Incomplete Coverage =================== @@ -159,29 +189,105 @@ For example, when handling command-line arguments, we could set additional param # Import the ns-3 C++ modules with Cppyy from ns import ns - # ns.cppyy.cppdef compiles the code defined in the block - # The defined types, values and functions are available in ns.cppyy.gbl - ns.cppyy.cppdef(""" - using namespace ns3; - - CommandLine& GetCommandLine(std::string filename, int& nCsma, bool& verbose) - { - static CommandLine cmd = CommandLine(filename); - cmd.AddValue("nCsma", "Number of extra CSMA nodes/devices", nCsma); - cmd.AddValue("verbose", "Tell echo applications to log if true", verbose); - return cmd; - } - """) - # To pass the addresses of the Python variables to c++, we need to use ctypes - from ctypes import c_int, c_bool - nCsma = c_int(3) + from ctypes import c_bool, c_int, c_double, c_char_p, create_string_buffer verbose = c_bool(True) + nCsma = c_int(3) + throughputKbps = c_double(3.1415) + BUFFLEN = 4096 + outputFileBuffer = create_string_buffer(b"default_output_file.xml", BUFFLEN) + outputFile = c_char_p(outputFileBuffer.raw) - # Pass the addresses of Python variables to C++ - cmd = ns.cppyy.gbl.GetCommandLine(__file__, nCsma, verbose) + # Cppyy will transform the ctype types into the appropriate reference or raw pointers + cmd = ns.CommandLine(__file__) + cmd.AddValue("verbose", "Tell echo applications to log if true", verbose) + cmd.AddValue("nCsma", "Number of extra CSMA nodes/devices", nCsma) + cmd.AddValue("throughputKbps", "Throughput of nodes", throughputKbps) + cmd.AddValue("outputFile", "Output file name", outputFile, BUFFLEN) cmd.Parse(sys.argv) + # Printing values of the different ctypes passed as arguments post parsing + print("Verbose:", verbose.value) + print("nCsma:", nCsma.value) + print("throughputKbps:", throughputKbps.value) + print("outputFile:", outputFile.value) + +Note that the variables are passed as references or raw pointers. Reassigning them on the Python side +(e.g. ``verbose = verbose.value``) can result in the Python garbage collector destroying the object +since its only reference has been overwritten, allowing the garbage collector to reclaim that memory space. +The C++ side will then have a dangling reference to the variable, which can be overwritten with +unexpected values, which can be read later, causing ns-3 to behave erratically due to the memory corruption. + +String values are problematic since Python and C++ string lifetimes are handled differently. +To workaround that, we need to use null-terminated C strings (``char*``) to exchange strings between +the bindings and ns-3 module libraries. However, C strings are particularly dangerous, since +overwriting the null-terminator can also result in memory corruption. When passing a C string, remember +to allocate a large buffer and perform bounds checking whenever possible. The CommandLine::AddValue +variant for ``char*`` performs bounds checking and aborts the execution in case the parsed value +does not fit in the buffer. Make sure to pass the complete size of the buffer, including the null terminator. + +There is an example below demonstrating how the memory corruption could happen in case there was +no bounds checking in CommandLine::AddValue variant for ``char*``. + +.. sourcecode:: python + + from ns import ns + from ctypes import c_char_p, c_char, create_string_buffer, byref, cast + + # The following buffer represent the memory contents + # of a program containing two adjacent C strings + # This could be the result of two subsequent variables + # on the stack or dynamically allocated + memoryContents = create_string_buffer(b"SHORT_STRING_CONTENTS\0"+b"DoNotWriteHere_"*5+b"\0") + lenShortString = len(b"SHORT_STRING_CONTENTS\0") + + # In the next lines, we pick pointers to these two C strings + shortStringBuffer = cast(byref(memoryContents, 0), c_char_p) + victimBuffer = cast(byref(memoryContents, lenShortString), c_char_p) + + cmd = ns.core.CommandLine(__file__) + # in the real implementation, the buffer size of 21+1 bytes containing SHORT_STRING_CONTENTS\0 is passed + cmd.AddValue("shortString", "", shortStringBuffer) + + print("Memory contents before the memory corruption") + print("Full Memory contents", memoryContents.raw) + print("shortStringBuffer contents: ", shortStringBuffer.value) + print("victimBuffer contents: ", victimBuffer.value) + + # The following block should print to the terminal. + # Note that the strings are correctly + # identified due to the null terminator (\x00) + # + # Memory contents before the memory corruption + # Full Memory contents b'SHORT_STRING_CONTENTS\x00DoNotWriteHere_DoNotWriteHere_DoNotWriteHere_DoNotWriteHere_DoNotWriteHere_\x00\x00' + # shortStringBuffer size=21, contents: b'SHORT_STRING_CONTENTS' + # victimBuffer size=75, contents: b'DoNotWriteHere_DoNotWriteHere_DoNotWriteHere_DoNotWriteHere_DoNotWriteHere_' + + # Write a very long string to a small buffer of size lenShortString = 22 + cmd.Parse(["python", "--shortString="+("OkToWrite"*lenShortString)[:lenShortString]+"CORRUPTED_"*3]) + + print("\n\nMemory contents after the memory corruption") + print("Full Memory contents", memoryContents.raw) + print("shortStringBuffer contents: ", shortStringBuffer.value) + print("victimBuffer contents: ", victimBuffer.value) + + # The following block should print to the terminal. + # + # Memory contents after the memory corruption + # Full Memory contents b'OkToWriteOkToWriteOkToCORRUPTED_CORRUPTED_CORRUPTED_\x00oNotWriteHere_DoNotWriteHere_DoNotWriteHere_\x00\x00' + # shortStringBuffer size=52, contents: b'OkToWriteOkToWriteOkToCORRUPTED_CORRUPTED_CORRUPTED_' + # victimBuffer size=30, contents: b'CORRUPTED_CORRUPTED_CORRUPTED_' + # + # Note that shortStringBuffer invaded the victimBuffer since the + # string being written was bigger than the shortStringBuffer. + # + # Since no bounds checks were performed, the adjacent memory got + # overwritten and both buffers are now corrupted. + # + # We also have a memory leak of the final block in the memory + # 'oNotWriteHere_DoNotWriteHere_DoNotWriteHere_\x00\x00', caused + # by the null terminator written at the middle of the victimBuffer. + If you find a segmentation violation, be sure to wait for the stacktrace provided by Cppyy and try to find the root cause of the issue. If you have multiple cores, the number of stacktraces will correspond to the number of threads being executed by Cppyy. To limit them, @@ -190,9 +296,9 @@ define the environment variable `OPENBLAS_NUM_THREADS=1`. Operators ######### -Cppyy may fail to map C++ operators due to the implementation style used by ns-3. +Cppyy may fail to map C++ operators due to the implementation style used by |ns3|. This happens for the fundamental type `Time`. To provide the expected behavior, we -redefine these operators from the Python side during the setup of the ns-3 bindings +redefine these operators from the Python side during the setup of the |ns3| bindings module (`ns-3-dev/bindings/python/ns__init__.py`). .. sourcecode:: python @@ -215,7 +321,7 @@ module (`ns-3-dev/bindings/python/ns__init__.py`). cppyy.gbl.ns3.Time.__lt__ = cppyy.gbl.Time_lt -A different operator used by ns-3 is `operator Address()`, used to +A different operator used by |ns3| is `operator Address()`, used to convert different types of Addresses into the generic type Address. This is not supported by Cppyy and requires explicit conversion. Some helpers have been added to handle the common cases. @@ -262,8 +368,6 @@ That means that the 'ascii' variable above must not be allowed to go out of scop Working with Python Bindings **************************** -Python bindings are built on a module-by-module basis, and can be found in each module's ``bindings`` directory. - Overview ======== diff --git a/doc/manual/source/windows.rst b/doc/manual/source/windows.rst new file mode 100644 index 000000000..aebdeffe2 --- /dev/null +++ b/doc/manual/source/windows.rst @@ -0,0 +1,798 @@ +.. include:: replace.txt +.. highlight:: console + +.. Section Separators: + ---- + **** + ++++ + ==== + ~~~~ + +.. _Windows 10: + +Windows 10 +---------- + +This chapter describes installation steps specific to Windows 10 and its +derivatives (e.g. Home, Pro, Enterprise) using the Msys2/MinGW64 toolchain. + +.. _Windows 10 package prerequisites: + +Windows 10 package prerequisites +******************************** + +The following instructions are relevant to the ns-3.37 release and Windows 10. + +Installation of the Msys2 environment ++++++++++++++++++++++++++++++++++++++ + +.. _Msys2: https://www.msys2.org/ + +The `Msys2`_ includes ports of Unix tools for Windows built with multiple toolchains, +including: MinGW32, MinGW64, Clang64, UCRT. + +The MinGW64 (GCC) toolchain is the one ns-3 was tested. + +The `Msys2`_ installer can be found on their site. +Msys2 will be installed by default in the ``C:\msys64`` directory. + +The next required step is adding the binaries directories from the MinGW64 toolchain and generic Msys2 tools +to the PATH environment variable. This can be accomplished via the GUI (search for system environment variable), +or via the following command (assuming it was installed to the default directory): + +.. sourcecode:: console + + C:\> setx PATH "C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH%;" /m + +Note: if the MinGW64 binary directory doesn't precede the Windows/System32 directory (already in ``%PATH%``), +the documentation build will fail since Windows has a conflicting ``convert`` command (FAT-to-NTFS). Similarly, +the Msys64 binary directory doesn't precede the Windows/System2 directory, running the ``bash`` command will +result in Windows trying to run the Windows Subsystem for Linux (WSL) bash shell. + +Accessing the MinGW64 shell ++++++++++++++++++++++++++++ + +After installing Msys2 and adding the binary directories to the ``PATH``, we can access the Unix-like MinGW64 shell +and use the Pacman package manager. + +The Pacman package manager is similar to the one used by Arch Linux, and can be accessed via one of the Msys2 shells. +In this case, we will be using the MinGW64 shell. We can take this opportunity to update the package cache and packages. + +.. sourcecode:: console + + C:\ns-3-dev\> set MSYSTEM MINGW64 + C:\ns-3-dev\> bash + /c/ns-3-dev/ MINGW64$ pacman -Syu + +Pacman will request you to close the shell and re-open it to proceed after the upgrade. + + +Minimal requirements for C++ (release) +++++++++++++++++++++++++++++++++++++++ + +This is the minimal set of packages needed to run ns-3 C++ programs from a released tarball. + +.. sourcecode:: console + + /c/ns-3-dev/ MINGW64$ pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake \ + mingw-w64-x86_64-ninja mingw-w64-x86_64-grep mingw-w64-x86_64-sed mingw-w64-x86_64-python + + +Netanim animator +++++++++++++++++ + +Qt5 development tools are needed for Netanim animator. Qt4 will also work but we have migrated to qt5. + +.. sourcecode:: console + + /c/ns-3-dev/ MINGW64$ pacman -S mingw-w64-x86_64-qt5 git + + +Support for MPI-based distributed emulation ++++++++++++++++++++++++++++++++++++++++++++ + +The MPI setup requires two parts. + +The first part is the Microsoft MPI SDK required to build the MPI applications, +which is distributed via Msys2. + +.. sourcecode:: console + + /c/ns-3-dev/ MINGW64$ pacman -S mingw-w64-x86_64-msmpi + +.. _Microsoft MPI: https://www.microsoft.com/en-us/download/details.aspx?id=100593 + +The second part is the `Microsoft MPI`_ executors (mpiexec, mpirun) package, +which is distributed as an installable (``msmpisetup.exe``). + +After installing it, the path containing the executors also need to be included to ``PATH`` +environment variable of the Windows and/or the MinGW64 shell, depending on whether +you want to run MPI programs in either shell or both of them. + +.. sourcecode:: console + + C:\ns-3-dev\> setx PATH "%PATH%;C:\Program Files\Microsoft MPI\Bin" /m + C:\ns-3-dev\> set MSYSTEM MINGW64 + C:\ns-3-dev\> bash + /c/ns-3-dev/ MINGW64$ echo "export PATH=$PATH:/c/Program\ Files/Microsoft\ MPI/Bin" >> ~/.bashrc + +Debugging ++++++++++ + +GDB is installed along with the mingw-w64-x86_64-toolchain package. + +Support for utils/check-style.py code style check program ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + +.. sourcecode:: console + + /c/ns-3-dev/ MINGW64$ pacman -S mingw-w64-x86_64-uncrustify + + +Doxygen and related inline documentation +++++++++++++++++++++++++++++++++++++++++ + +To build the Doxygen-based documentation, we need doxygen and a Latex toolchain. +Getting Doxygen from Msys2 is straightforward. + +.. sourcecode:: console + + /c/ns-3-dev/ MINGW64$ pacman -S mingw-w64-x86_64-imagemagick mingw-w64-x86_64-doxygen mingw-w64-x86_64-graphviz + +For unknown reasons, the texlive packages in Msys2 are broken, +so we recommend manually installing the official Texlive. + +.. _Texlive for Windows: https://tug.org/texlive/windows.html + +Start by installing `Texlive for Windows`_. It can be installed either via the network installer or +directly from the ISO with all optional packages. + +To install it with the network installer, start by creating a texlive folder and downloading the +texlive configuration profile below. You can change the installation directory (starting with +``C:/texlive/2022``). + +.. sourcecode:: raw + + selected_scheme scheme-custom + TEXDIR C:/texlive/2022 + TEXMFCONFIG ~/.texlive2022/texmf-config + TEXMFHOME ~/texmf + TEXMFLOCAL C:/texlive/texmf-local + TEXMFSYSCONFIG C:/texlive/2022/texmf-config + TEXMFSYSVAR C:/texlive/2022/texmf-var + TEXMFVAR ~/.texlive2022/texmf-var + binary_win32 1 + collection-basic 1 + collection-bibtexextra 1 + collection-binextra 1 + collection-context 1 + collection-fontsrecommended 1 + collection-fontutils 1 + collection-games 1 + collection-humanities 1 + collection-langenglish 1 + collection-latex 1 + collection-latexextra 1 + collection-latexrecommended 1 + collection-luatex 1 + collection-mathscience 1 + collection-metapost 1 + collection-music 1 + collection-pictures 1 + collection-plaingeneric 1 + collection-pstricks 1 + collection-publishers 1 + collection-texworks 1 + collection-wintools 1 + collection-xetex 1 + instopt_adjustpath 1 + instopt_adjustrepo 1 + instopt_letter 0 + instopt_portable 0 + instopt_write18_restricted 1 + tlpdbopt_autobackup 1 + tlpdbopt_backupdir tlpkg/backups + tlpdbopt_create_formats 1 + tlpdbopt_desktop_integration 1 + tlpdbopt_file_assocs 1 + tlpdbopt_generate_updmap 0 + tlpdbopt_install_docfiles 0 + tlpdbopt_install_srcfiles 0 + tlpdbopt_post_code 1 + tlpdbopt_sys_bin /usr/local/bin + tlpdbopt_sys_info /usr/local/share/info + tlpdbopt_sys_man /usr/local/share/man + tlpdbopt_w32_multi_user 0 + + +Then, download Texlive's web installer and unpack it to the texlive directory, +and run the installer. + +.. sourcecode:: console + + ~$ wget https://linorg.usp.br/CTAN/systems/texlive/tlnet/install-tl.zip + ~$ python3 -c "import shutil; shutil.unpack_archive('install-tl.zip', './')" + ~$ cd install-tl-* + ~/install-tl-20220923$ .\install-tl-windows.bat --no-gui --lang en -profile ..\texlive.profile + +After the installation finishes, add the installation directory to the PATH environment variable. + +.. sourcecode:: console + + setx PATH "%PATH%;C:\texlive\2022\bin\win32" /m + C:\ns-3-dev\> set MSYSTEM MINGW64 + C:\ns-3-dev\> bash + /c/ns-3-dev/ MINGW64$ echo "export PATH=$PATH:/c/texlive/2022/bin/win32" >> ~/.bashrc + +The ns-3 manual, models and tutorial +++++++++++++++++++++++++++++++++++++ + +These documents are written in reStructuredText for Sphinx (doc/tutorial, doc/manual, doc/models). +The figures are typically written in dia. + +The documents can be generated into multiple formats, one of them being pdf, +which requires the same Latex setup for doxygen. + +Sphinx can be installed via Msys2's package manager: + +.. sourcecode:: console + + /c/ns-3-dev/ MINGW64$ pacman -S mingw-w64-x86_64-python-sphinx + +.. _Dia: https://sourceforge.net/projects/dia-installer/ + +`Dia`_ on the other hand needs to be downloaded and installed manually. +After installing it, or unzipping the package (example below), add Dia/bin to the PATH. + +.. sourcecode:: console + + C:\ns-3-dev\> setx PATH "%PATH%;C:\dia_0.97.2_win32\bin" /m + C:\ns-3-dev\> set MSYSTEM MINGW64 + C:\ns-3-dev\> bash + /c/ns-3-dev/ MINGW64$ echo "export PATH=$PATH:/c/dia_0.97.2_win32/bin" >> ~/.bashrc + +GNU Scientific Library (GSL) +++++++++++++++++++++++++++++ + +GSL is used to provide more accurate WiFi error models and can be installed with: + +.. sourcecode:: console + + /c/ns-3-dev/ MINGW64$ pacman -S mingw-w64-x86_64-gsl + +Database support for statistics framework ++++++++++++++++++++++++++++++++++++++++++ + +SQLite3 is installed along with the mingw-w64-x86_64-toolchain package. + + +Xml-based version of the config store ++++++++++++++++++++++++++++++++++++++ + +Requires libxml2 >= version 2.7, which can be installed with the following. + +.. sourcecode:: console + + /c/ns-3-dev/ MINGW64$ pacman -S mingw-w64-x86_64-libxml2 + +Support for openflow module ++++++++++++++++++++++++++++ + +Requires some boost libraries that can be installed with the following. + +.. sourcecode:: console + + /c/ns-3-dev/ MINGW64$ pacman -S mingw-w64-x86_64-boost + +Windows 10 Docker container +*************************** + +Docker containers are not as useful for Windows, since only Windows hosts can use them, +however we add directions on how to use the Windows container and how to update the Docker +image for reference. + +First, gather all dependencies previously mentioned to cover all supported features. +Install them to a base directory for the container (e.g. ``C:\tools``). + +Save the following Dockerfile to the base directory. + +.. sourcecode:: docker + + # It is really unfortunate we need a 16 GB base image just to get the installers working, but such is life + FROM mcr.microsoft.com/windows:20H2 + + # Copy the current host directory to the container + COPY .\\ C:/tools + WORKDIR C:\\tools + + # Create temporary dir + RUN mkdir C:\\tools\\temp + + # Export environment variables + RUN setx PATH "C:\\tools\\msys64\\mingw64\\bin;C:\\tools\\msys64\\usr\\bin;%PATH%" /m + RUN setx PATH "%PATH%;C:\\Program Files\\Microsoft MPI\\bin;C:\\tools\\dia\bin;C:\tools\texlive\2022\bin\win32" /m + RUN setx MSYSTEM "MINGW64" /m + + # Install Msys2 + RUN .\\msys2-x86_64-20220503.exe in --confirm-command --accept-messages --root C:\\tools\\msys64 + + # Update base packages + RUN C:\\tools\\msys64\\usr\\bin\\pacman -Syyuu --noconfirm + + # Install base packages + RUN bash -c "echo export PATH=$PATH:/c/Program\ Files/Microsoft\ MPI/Bin >> /c/tools/msys64/home/$USER/.bashrc" && \ + bash -c "echo export PATH=$PATH:/c/tools/dia/bin >> /c/tools/msys64/home/$USER/.bashrc" && \ + bash -c "echo export PATH=$PATH:/c/tools/texlive/2022/bin/win32 >> /c/tools/msys64/home/$USER/.bashrc" && \ + bash -c "pacman -S mingw-w64-x86_64-toolchain \ + mingw-w64-x86_64-cmake \ + mingw-w64-x86_64-ninja \ + mingw-w64-x86_64-grep \ + mingw-w64-x86_64-sed \ + mingw-w64-x86_64-qt5 \ + git \ + mingw-w64-x86_64-msmpi \ + mingw-w64-x86_64-uncrustify \ + mingw-w64-x86_64-imagemagick \ + mingw-w64-x86_64-doxygen \ + mingw-w64-x86_64-graphviz \ + mingw-w64-x86_64-python-sphinx \ + mingw-w64-x86_64-gsl \ + mingw-w64-x86_64-libxml2 \ + mingw-w64-x86_64-boost \ + --noconfirm" + + # Install Microsoft MPI + RUN .\\msmpisetup.exe -unattend -force -full -verbose + + # Install TexLive + RUN .\\install-tl-20220526\\install-tl-windows.bat --no-gui --lang en -profile .\\texlive.profile + + # Move working directory to temp and start cmd + WORKDIR C:\\tools\\temp + ENTRYPOINT ["cmd"] + +Now you should be able to run ``docker build -t username/image .``. + +After building the container image, you should be able to use it: + +.. sourcecode:: console + + $ docker run -it username/image + C:\tools\temp$ git clone https://gitlab.com/nsnam/ns-3-dev + C:\tools\temp$ cd ns-3-dev + C:\tools\temp\ns-3-dev$ python ns3 configure --enable-tests --enable-examples + C:\tools\temp\ns-3-dev$ python ns3 build + C:\tools\temp\ns-3-dev$ python test.py + +If testing succeeds, the container image can then be pushed to the Docker Hub using +``docker push username/image``. + + +Windows 10 Vagrant +****************** + +.. _VirtualBox: https://www.virtualbox.org/ +.. _Vagrant: https://www.vagrantup.com/ +.. _virtual machine: https://www.redhat.com/en/topics/virtualization/what-is-a-virtual-machine +.. _boxes available: https://app.vagrantup.com/boxes/search + +As an alternative to manually setting up all dependencies required by ns-3, +one can use a pre-packaged `virtual machine`_. There are many ways to do that, +but for automation, the most used certainly is `Vagrant`_. + +Vagrant supports multiple virtual machine providers, is available in all platforms and is +fairly straightforward to use and configure. + +There are many `boxes available`_ offering guests operating systems such as BSD, Mac, Linux and Windows. + +Using the pre-packaged Vagrant box +++++++++++++++++++++++++++++++++++ + +The provider for the ns-3 Vagrant box is `VirtualBox`_. + +The reference Windows virtual machine can be downloaded via the following Vagrant command + +.. sourcecode:: console + + ~/mingw64_test $ vagrant init gabrielcarvfer/ns3_win10_mingw64 + +After that, a Vagrantfile will be created in the current directory (in this case, mingw64_test). + +The file can be modified to adjust the number of processors and memory available to the virtual machine (VM). + +.. sourcecode:: console + + ~/mingw64_test $ cat Vagrantfile + # -*- mode: ruby -*- + # vi: set ft=ruby : + + # All Vagrant configuration is done below. The "2" in Vagrant.configure + # configures the configuration version (we support older styles for + # backwards compatibility). Please don't change it unless you know what + # you're doing. + Vagrant.configure("2") do |config| + # The most common configuration options are documented and commented below. + # For a complete reference, please see the online documentation at + # https://docs.vagrantup.com. + + # Every Vagrant development environment requires a box. You can search for + # boxes at https://vagrantcloud.com/search. + config.vm.box = "gabrielcarvfer/ns3_win10_mingw64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + # NOTE: This will enable public access to the opened port + # config.vm.network "forwarded_port", guest: 80, host: 8080 + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine and only allow access + # via 127.0.0.1 to disable public access + # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1" + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + # config.vm.provider "virtualbox" do |vb| + # # Display the VirtualBox GUI when booting the machine + # vb.gui = true + # + # # Customize the amount of memory on the VM: + # vb.memory = "1024" + # end + # + # View the documentation for the provider you are using for more + # information on available options. + + # Enable provisioning with a shell script. Additional provisioners such as + # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the + # documentation for more information about their specific syntax and use. + # config.vm.provision "shell", inline: <<-SHELL + # apt-get update + # apt-get install -y apache2 + # SHELL + end + +We can uncomment the virtualbox provider block and change vCPUs and RAM. +It is recommended never to match the number of vCPUs to the number of thread of the machine, +or the host operating system can become unresponsive. +For compilation workloads, it is recommended to allocate 1-2 GB of RAM per vCPU. + +.. _user Vagrantfile: + +.. sourcecode:: console + + ~/mingw64_test/ $ cat Vagrantfile + # -*- mode: ruby -*- + # vi: set ft=ruby : + Vagrant.configure("2") do |config| + config.vm.box = "gabrielcarvfer/ns3_win10_mingw64" + config.vm.provider "virtualbox" do |vb| + vb.cpus = "8" + vb.memory = "8096" # 8GB of RAM + end + end + +After changing the settings, we can start the VM and login via ssh. The default password is "vagrant". + +.. sourcecode:: console + + ~/mingw64_test/ $ vagrant up + ~/mingw64_test/ $ vagrant ssh + C:\Users\vagrant> + + +We are now logged into the machine and ready to work. If you prefer to update the tools, get into the +MinGW64 shell and run pacman. + +.. sourcecode:: console + + C:\Users\vagrant\> set MSYSTEM MINGW64 + C:\Users\vagrant\> bash + /c/Users/vagrant/ MINGW64$ pacman -Syu + /c/Users/vagrant/ MINGW64$ exit + C:\Users\vagrant\> + +At this point, we can clone ns-3 locally: + +.. sourcecode:: console + + C:\Users\vagrant> git clone `https://gitlab.com/nsnam/ns-3-dev` + C:\Users\vagrant> cd ns-3-dev + C:\Users\vagrant\ns-3-dev> python3 ns3 configure --enable-tests --enable-examples --enable-mpi + C:\Users\vagrant\ns-3-dev> python3 test.py + +We can also access the ~/mingw64_test/ from the host machine, where the Vagrantfile resides, by accessing +the synchronized folder C:\vagrant. +If the Vagrantfile is in the host ns-3-dev directory, we can continue working on it. + +.. sourcecode:: console + + C:\Users\vagrant> cd C:\vagrant + C:\vagrant\> python3 ns3 configure --enable-tests --enable-examples --enable-mpi + C:\vagrant\> python3 test.py + +If all the PATH variables were set for the MinGW64 shell, we can also use it instead of the +default CMD shell. + +.. sourcecode:: console + + C:\vagrant\> set MSYSTEM=MINGW64 + C:\vagrant\> bash + /c/vagrant/ MINGW64$ ./ns3 clean + /c/vagrant/ MINGW64$ ./ns3 configure --enable-tests --enable-examples --enable-mpi + /c/vagrant/ MINGW64$ ./test.py + +To stop the Vagrant machine, we should close the SSH session then halt. + +.. sourcecode:: console + + /c/vagrant/ MINGW64$ exit + C:\vagrant\> exit + ~/mingw64_test/ vagrant halt + +To destroy the machine (e.g. to restore the default settings), use the following. + +.. sourcecode:: console + + vagrant destroy + +Packaging a new Vagrant box ++++++++++++++++++++++++++++ + +**BEWARE: DO NOT CHANGE THE SETTINGS MENTIONED ON A REAL MACHINE** + +**THE SETTINGS ARE MEANT FOR A DISPOSABLE VIRTUAL MACHINE** + +.. _Windows 10 ISO: https://www.microsoft.com/pt-br/software-download/windows10ISO + +Start by downloading the `Windows 10 ISO`_. + +Then install `VirtualBox`_. + +Configure a VirtualBox VM and use the Windows 10 ISO file as the install source. + +During the installation, create a local user named "vagrant" and set its password to "vagrant". + +Check for any Windows updates and install them. + +The following commands assume administrative permissions and a PowerShell shell. + +Install the VirtualBox guest extensions +======================================= + +On the VirtualBox GUI, click on ``Devices->Insert Guest Additions CD Image...`` +to download the VirtualBox guest extensions ISO and mount it as a CD drive on the guest VM. + +Run the installer to enable USB-passthrough, folder syncing and others. + +After installing, unmount the drive by removing it from the VM. Click on ``Settings->Storage``, +select the guest drive and remove it clicking the button with an red ``x``. + +Install the OpenSSH server +========================== + +Open PowerShell and run the following to install OpenSSH server, +then set it to start automatically and open the firewall ports. + +.. sourcecode:: console + + Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 + Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 + Start-Service sshd + Set-Service -Name sshd -StartupType 'Automatic' + if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) { + Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..." + New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 + } else { + Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists." + } + +Enable essential services and disable unnecessary ones +====================================================== + +Ensure the following services are set to **automatic** from the Services panel(services.msc): + + - Base Filtering Engine + - Remote Procedure Call (RPC) + - DCOM Server Process Launcher + - RPC Endpoint Mapper + - Windows Firewall + +Ensure the following services are set to **disabled** from the Services panel(services.msc): + + - Windows Update + - Windows Update Remediation + - Windows Search + +The same can be accomplished via the command-line with the following commands: + +.. sourcecode:: console + + Set-Service -Name BFE -StartupType 'Automatic' + Set-Service -Name RpcSs -StartupType 'Automatic' + Set-Service -Name DcomLaunch -StartupType 'Automatic' + Set-Service -Name RpcEptMapper -StartupType 'Automatic' + Set-Service -Name mpssvc -StartupType 'Automatic' + Set-Service -Name wuauserv -StartupType 'Disabled' + Set-Service -Name WaaSMedicSvc -StartupType 'Disabled' + Set-Service -Name WSearch -StartupType 'Disabled' + +Install the packages you need +============================= + +In this step we install all the software required by ns-3, as listed in the Section `Windows 10 package prerequisites`_. + +Disable Windows Defender +======================== + +After installing everything, it should be safe to disable the Windows security. + +Enter in the Windows Security settings and disable "anti-tamper protection". +It rollbacks changes to security settings periodically. + +Enter in the Group Policy Editor (gpedit.msc) and disable: + + - Realtime protection + - Behavior monitoring + - Scanning of archives, removable drives, network files, scripts + - Windows defender + + +The same can be accomplished with the following command-line commands. + +.. sourcecode:: console + + Set-MpPreference -DisableArchiveScanning 1 -ErrorAction SilentlyContinue + Set-MpPreference -DisableBehaviorMonitoring 1 -ErrorAction SilentlyContinue + Set-MpPreference -DisableIntrusionPreventionSystem 1 -ErrorAction SilentlyContinue + Set-MpPreference -DisableIOAVProtection 1 -ErrorAction SilentlyContinue + Set-MpPreference -DisableRemovableDriveScanning 1 -ErrorAction SilentlyContinue + Set-MpPreference -DisableBlockAtFirstSeen 1 -ErrorAction SilentlyContinue + Set-MpPreference -DisableScanningMappedNetworkDrivesForFullScan 1 -ErrorAction SilentlyContinue + Set-MpPreference -DisableScanningNetworkFiles 1 -ErrorAction SilentlyContinue + Set-MpPreference -DisableScriptScanning 1 -ErrorAction SilentlyContinue + Set-MpPreference -DisableRealtimeMonitoring 1 -ErrorAction SilentlyContinue + Set-Service -Name WdNisSvc -StartupType 'Disabled' + Set-Service -Name WinDefend -StartupType 'Disabled' + Set-Service -Name Sense -StartupType 'Disabled' + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection" -Name SpyNetReporting -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Defender\Real-Time Protection" -Name SubmitSamplesConsent -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Defender\Features" -Name TamperProtection -Value 4 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Defender" -Name DisableAntiSpyware -Value 1 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name DisableAntiSpyware -Value 1 + +Note: the previous commands were an excerpt from the complete script in: +https://github.com/jeremybeaume/tools/blob/master/disable-defender.ps1 + +Turn off UAC notifications +========================== + +The UAC notifications are the popups where you can give your OK to elevation to administrative privileges. +It can be disabled via User Account Control Settings, or via the following commands. + +.. sourcecode:: console + + reg ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f + + +Change the strong password security Policy +========================================== + +Open the Local Security Policy management window. Under Security Settings/Account Policy/Password Policy, +disable the option saying "Password must meet complexity requirements". + + +Testing +======= + +After you reach this point, reboot your machine then log back in. + +Test if all your packages are working as expected. + +In the case of ns-3, try to enable all supported features, run the test.py and test-ns3.py suites. + +If everything works, then try to log in via SSH. + +If everything works, shut down the machine and prepare for packaging. + +The network interface configured should be a NAT. Other interfaces won't work correctly. + +Default Vagrantfile +=================== + +Vagrant can package VirtualBox VMs into Vagrant boxes without much more work. +However, it still needs one more file to do that: the default Vagrantfile. + +This file will be used by Vagrant to configure the VM later on and how to connect to it. + +.. sourcecode:: ruby + + # -*- mode: ruby -*- + # vi: set ft=ruby : + + Vagrant.configure("2") do |config| + config.vm.box = "BOX_FILE.box" # name of the box + config.vm.communicator = "winssh" # indicate that we are talking to a windows box via ssh + config.vm.guest = :windows # indicate that the guest is a windows machine + config.vm.network :forwarded_port, guest: 3389, host: 3389, id: "rdp", auto_correct: true + config.ssh.password = "vagrant" # give the default password, so that it stops trying to use a .ssh key-pair + config.ssh.insert_key = false # let the user use a written password + config.ssh.keys_only = false + config.winssh.shell = "cmd" # select the default shell (could be cmd or powershell) + config.vm.provider :virtualbox do |v, override| + #v.gui = true # do not show the VirtualBox GUI if unset or set to false + v.customize ["modifyvm", :id, "--memory", 8096] # the default settings for the VM are 8GB of RAM + v.customize ["modifyvm", :id, "--cpus", 8] # the default settings for the VM are 8 vCPUs + v.customize ["modifyvm", :id, "--vram", 128] # 128 MB or vGPU RAM + v.customize ["modifyvm", :id, "--clipboard", "bidirectional"] + v.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ] + end + end + +This Vagrantfile will be baked into the Vagrant box, and can be modified by the `user Vagrantfile`_. +After writing the Vagrantfile, we can call the following command. + +.. sourcecode:: console + + vagrant package --vagrantfile Vagrantfile --base VIRTUALBOX_VM_NAME --output BOX_FILE.box + +It will take an awful long time depending on your drive. + +After it finishes, we can add the box to test it. + +.. sourcecode:: console + + vagrant box add BOX_NAME BOX_FILE + vagrant up BOX_NAME + vagrant ssh + +If it can connect to the box, you are ready to upload it to the Vagrant servers. + +Publishing the Vagrant box +========================== + +Create an account in https://app.vagrantup.com/ or log in with yours. +In the dashboard, you can create a new box named BOX_NAME or select an existing one to update. + +After you select your box, click to add a provider. Pick Virtualbox. +Calculate the MD5 hash of your BOX_FILE.box and fill the field then click to proceed. + +Upload the box. + +Now you should be able to download your box from the Vagrant servers via the the following command. + +.. sourcecode:: console + + vagrant init yourUserName/BOX_NAME + vagrant up + vagrant ssh + +More information on Windows packaging to Vagrant boxes is available here: + + - https://www.vagrantup.com/docs/boxes/base + - https://www.vagrantup.com/docs/vagrantfile/machine_settings + - https://www.vagrantup.com/docs/vagrantfile/ssh_settings + - https://www.vagrantup.com/docs/vagrantfile/winssh_settings + - https://github.com/pghalliday/windows-vagrant-boxes diff --git a/doc/manual/source/working-with-cmake.rst b/doc/manual/source/working-with-cmake.rst index 57fb63cd6..196336e45 100644 --- a/doc/manual/source/working-with-cmake.rst +++ b/doc/manual/source/working-with-cmake.rst @@ -2317,8 +2317,6 @@ values are being used. So we need to check the template. #cmakedefine01 HAVE_STDLIB_H #cmakedefine01 HAVE_GETENV #cmakedefine01 HAVE_SIGNAL_H - #cmakedefine HAVE_PTHREAD_H - #cmakedefine HAVE_RT /* * #cmakedefine turns into: diff --git a/doc/models/source/conf.py b/doc/models/source/conf.py index 63294ce75..743da8a87 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-dev' +version = u'ns-3.37' # The full version, including alpha/beta/rc tags. -release = u'ns-3-dev' +release = u'ns-3.37' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/tutorial/source/conf.py b/doc/tutorial/source/conf.py index 129370698..d83551bd3 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-dev' +version = u'ns-3.37' # The full version, including alpha/beta/rc tags. -release = u'ns-3-dev' +release = u'ns-3.37' # 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 0cb0751d7..054b26a91 100644 --- a/doc/tutorial/source/getting-started.rst +++ b/doc/tutorial/source/getting-started.rst @@ -70,7 +70,7 @@ 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.36.1), the following tools +As of the most recent |ns3| release (ns-3.37), the following tools are needed to get started with |ns3|: ============ =========================================================== @@ -124,22 +124,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.36.1.tar.bz2 - $ tar xjf ns-allinone-3.36.1.tar.bz2 + $ wget https://www.nsnam.org/release/ns-allinone-3.37.tar.bz2 + $ tar xjf ns-allinone-3.37.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.36.1``, you should see a number of files and directories +``ns-allinone-3.37``, you should see a number of files and directories .. sourcecode:: text - $ cd ns-allinone-3.36.1 + $ cd ns-allinone-3.37 $ ls - bake constants.py ns-3.36.1 README.md - build.py netanim-3.108 pybindgen-0.22.1 util.py + bake build.py constants.py netanim-3.108 ns-3.37 README.md util.py You are now ready to build the base |ns3| distribution and may skip ahead to the section on building |ns3|. @@ -189,7 +188,7 @@ release number: .. sourcecode:: console - $ python3 download.py -n ns-3.36.1 + $ python3 download.py -n ns-3.37 After this step, the additional repositories of |ns3|, bake, pybindgen, and netanim will be downloaded to the ``ns-3-allinone`` directory. @@ -258,16 +257,15 @@ distribution of your choice. There are a few configuration targets available: -1. ``ns-3.36.1``: the module corresponding to the release; it will download - components similar to the release tarball. +1. ``ns-3.37``: the code corresponding to the release 2. ``ns-3-dev``: a similar module but using the development code tree -3. ``ns-allinone-3.36.1``: the module that includes other optional features +3. ``ns-allinone-3.37``: 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. The current development snapshot (unreleased) of |ns3| may be found -at https://gitlab.com/nsnam/ns-3-dev.git. The +and cloned from https://gitlab.com/nsnam/ns-3-dev.git. The developers attempt to keep these repositories in consistent, working states but they are in a development area with unreleased code present, so you may want to consider staying with an official release if you do not need newly- @@ -278,7 +276,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.36.1``. +this tutorial example with ``ns-3.37``. 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. @@ -294,8 +292,9 @@ environment variables: .. sourcecode:: console $ export BAKE_HOME=`pwd` - $ export PATH=$PATH:$BAKE_HOME:$BAKE_HOME/build/bin - $ export PYTHONPATH=$PYTHONPATH:$BAKE_HOME:$BAKE_HOME/build/lib + $ export PATH=$PATH:$BAKE_HOME/build/bin + $ export PYTHONPATH=$BAKE_HOME/build/lib + $ export LD_LIBRARY_PATH=$BAKE_HOME/build/lib This will put the bake.py program into the shell's path, and will allow other programs to find executables and libraries created by bake. Although @@ -306,7 +305,7 @@ Step into the workspace directory and type the following into your shell: .. sourcecode:: console - $ ./bake.py configure -e ns-3.36.1 + $ ./bake.py configure -e ns-allinone-3.37 Next, we'll ask bake to check whether we have enough tools to download various components. Type: @@ -321,7 +320,6 @@ You should see something like the following: > Python - OK > GNU C++ compiler - OK - > Mercurial - OK > Git - OK > Tar tool - OK > Unzip tool - OK @@ -330,11 +328,9 @@ You should see something like the following: > patch tool - OK > Path searched for tools: /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin ... -In particular, download tools such as Git and Mercurial -are our principal concerns at this point, since they allow us to fetch -the code. Please install missing tools at this stage, in the usual +Please install missing tools at this stage, in the usual way for your system (if you are able to), or contact your system -administrator as needed to install these tools. You can also +administrator as needed to install these tools. Next, try to download the software: @@ -346,23 +342,20 @@ should yield something like: .. sourcecode:: text - >> Searching for system dependency setuptools - OK - >> Searching for system dependency libgoocanvas2 - OK - >> Searching for system dependency gi-cairo - OK - >> Searching for system dependency pygobject - OK - >> Searching for system dependency pygraphviz - OK - >> Searching for system dependency python-dev - OK - >> Searching for system dependency qt - OK - >> Searching for system dependency g++ - OK - >> Searching for system dependency cxxfilt - OK - >> Searching for system dependency setuptools - OK + >> Searching for system dependency libxml2-dev - OK >> Searching for system dependency gi-cairo - OK >> Searching for system dependency gir-bindings - OK >> Searching for system dependency pygobject - OK + >> Searching for system dependency pygraphviz - OK + >> Searching for system dependency python3-dev - OK + >> Searching for system dependency qt - OK + >> Searching for system dependency g++ - OK >> Searching for system dependency cmake - OK >> Downloading netanim-3.108 - OK - >> Downloading pybindgen-0.22.1 (target directory:pybindgen) - OK - >> Downloading ns-3.36.1 (target directory:ns-3.36.1) - OK + >> Downloading click-ns-3.37 - OK + >> Downloading BRITE - OK + >> Downloading openflow-dev - OK + >> Downloading ns-3.37 (target directory:ns-3.37) - OK The above suggests that three sources have been downloaded. Check the ``source`` directory now and type ``ls``; one should see: @@ -371,7 +364,7 @@ The above suggests that three sources have been downloaded. Check the $ cd source $ ls - netanim-3.108 ns-3.36.1 pybindgen + BRITE click-ns-3.37 netanim-3.108 ns-3.37 openflow-dev You are now ready to build the |ns3| distribution. @@ -401,7 +394,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.36.1`` under your ``~/workspace`` directory. +``ns-allinone-3.37`` under your ``~/workspace`` directory. Type the following: .. sourcecode:: console @@ -417,8 +410,7 @@ are not necessary for your work, if you wish. You will see lots of compiler output messages displayed as the build script builds the various pieces you downloaded. First, the script will -attempt to build the netanim animator, then the pybindgen bindings generator, -and finally |ns3|. +attempt to build the netanim animator, and then |ns3|. Building with bake ++++++++++++++++++ @@ -434,25 +426,11 @@ and you should see something like: .. sourcecode:: text - >> Building pybindgen-0.22.1 - OK >> Building netanim-3.108 - OK - >> Building ns-3.36.1 - OK + >> Building ns-3.37 - OK There may be failures to build all components, but the build will proceed -anyway if the component is optional. For example, a recent portability issue -has been that castxml may not build via the bake build tool on all -platforms; in this case, the line will show something like:: - - >> Building castxml - Problem - > Problem: Optional dependency, module "castxml" failed - This may reduce the functionality of the final build. - However, bake will continue since "castxml" is not an essential dependency. - For more information call bake with -v or -vvv, for full verbose mode. - -However, castxml is only needed if one wants to generate updated Python -bindings, and most users do not need to do so (or to do so until they are -more involved with ns-3 changes), so such warnings might be safely ignored -for now. +anyway if the component is optional. If there happens to be a failure, please have a look at what the following command tells you; it may give a hint as to a missing dependency: @@ -989,7 +967,7 @@ confusing to newcomers, and when done poorly it leads to subtle build errors. The solutions above are the way to go. Building with CMake -+++++++++++++++++++++++ ++++++++++++++++++++ The ns3 wrapper script calls CMake directly, mapping Waf-like options to the verbose settings used by CMake. Calling ``./ns3`` will execute @@ -1064,13 +1042,41 @@ Corresponds to: Note: the command above would fail if ``./ns3 build`` was not executed first, since the examples won't be built by the test-runner target. +On Windows, the Msys2/MinGW64/bin directory path must be on the PATH environment variable, +otherwise the dll's required by the C++ runtime will not be found, resulting in crashes +without any explicit reasoning. + +Note: The ns-3 script adds only the ns-3 lib directory path to the PATH, +ensuring the ns-3 dlls will be found by running programs. If you are using CMake directly or +an IDE, make sure to also include the path to ns-3-dev/build/lib in the PATH variable. + +.. _setx : https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/setx/ + +If you are using one of Windows's terminals (CMD, PowerShell or Terminal), you can use the `setx`_ +command to change environment variables permanently or `set` to set them temporarily for that shell: + +.. sourcecode:: console + + C:\\Windows\\system32>echo %PATH% + C:\\Windows\\system32;C:\\Windows;D:\\tools\\msys64\\mingw64\\bin; + + C:\\Windows\\system32>setx PATH "%PATH%;D:\\tools\\msys64\\usr\\bin;" /m + + C:\\Windows\\system32>echo %PATH% + C:\\Windows\\system32;C:\\Windows;D:\\tools\\msys64\\mingw64\\bin; + D:\\tools\\msys64\\usr\\bin; + +Note: running on an administrator terminal will change the system PATH, +while the user terminal will change the user PATH, unless the `/m` flag is added. + + Building with IDEs ++++++++++++++++++ With CMake, IDE integration is much easier. We list the steps on how to use ns-3 with a few IDEs. -Microsoft Visual Code -===================== +Microsoft Visual Studio Code +============================ Start by downloading `VS Code `_. @@ -1078,38 +1084,38 @@ Then install it and then install the CMake and C++ plugins. This can be done accessing the extensions' menu button on the left. -.. figure:: figures/vscode/install_cmake_tools.png +.. figure:: ../figures/vscode/install_cmake_tools.png -.. figure:: figures/vscode/install_cpp_tools.png +.. figure:: ../figures/vscode/install_cpp_tools.png It will take a while, but it will locate the available toolchains for you to use. After that, open the ns-3-dev folder. It should run CMake automatically and preconfigure it. -.. figure:: figures/vscode/open_project.png +.. figure:: ../figures/vscode/open_project.png After this happens, you can choose ns-3 features by opening the CMake cache and toggling them on or off. -.. figure:: figures/vscode/open_cmake_cache.png +.. figure:: ../figures/vscode/open_cmake_cache.png -.. figure:: figures/vscode/configure_ns3.png +.. figure:: ../figures/vscode/configure_ns3.png Just as an example, here is how to enable examples -.. figure:: figures/vscode/enable_examples_and_save_to_reload_cache.png +.. figure:: ../figures/vscode/enable_examples_and_save_to_reload_cache.png After saving the cache, CMake will run, refreshing the cache. Then VsCode will update its list of targets on the left side of the screen in the CMake menu. After selecting a target on the left side menu, there are options to build, run or debug it. -.. figure:: figures/vscode/select_target_build_and_debug.png +.. figure:: ../figures/vscode/select_target_build_and_debug.png Any of them will automatically build the selected target. If you choose run or debug, the executable targets will be executed. You can open the source files you want, put some breakpoints and then click debug to visually debug programs. -.. figure:: figures/vscode/debugging.png +.. figure:: ../figures/vscode/debugging.png JetBrains CLion =============== @@ -1120,30 +1126,30 @@ Start by downloading `CLion `_. The following image contains the toolchain configuration window for CLion running on Windows (only WSLv2 is currently supported). -.. figure:: figures/clion/toolchains.png +.. figure:: ../figures/clion/toolchains.png CLion uses Makefiles for your platform as the default generator. Here you can choose a better generator like `ninja` by setting the cmake options flag to `-G Ninja`. You can also set options to enable examples (`-DNS3_EXAMPLES=ON`) and tests (`-DNS3_TESTS=ON`). -.. figure:: figures/clion/cmake_configuration.png +.. figure:: ../figures/clion/cmake_configuration.png To refresh the CMake cache, triggering the discovery of new targets (libraries, executables and/or modules), you can either configure to re-run CMake automatically after editing CMake files (pretty slow and easily triggered) or reload it manually. The following image shows how to trigger the CMake cache refresh. -.. figure:: figures/clion/reload_cache.png +.. figure:: ../figures/clion/reload_cache.png After configuring the project, the available targets are listed in a drop-down list on the top right corner. Select the target you want and then click the hammer symbol to build, as shown in the image below. -.. figure:: figures/clion/build_targets.png +.. figure:: ../figures/clion/build_targets.png If you have selected and executable target, you can click either the play button to execute the program; the bug to debug the program; the play button with a chip, to run Valgrind and analyze memory usage, leaks and so on. -.. figure:: figures/clion/run_target.png +.. figure:: ../figures/clion/run_target.png Code::Blocks ============ @@ -1168,30 +1174,30 @@ This is a Code::Blocks project file that can be opened by the IDE. When you first open the IDE, you will be greeted by a window asking you to select the compiler you want. -.. figure:: figures/codeblocks/compiler_detection.png +.. figure:: ../figures/codeblocks/compiler_detection.png After that you will get into the landing page where you can open the project. -.. figure:: figures/codeblocks/landing.png +.. figure:: ../figures/codeblocks/landing.png Loading it will take a while. -.. figure:: figures/codeblocks/open_project.png +.. figure:: ../figures/codeblocks/open_project.png After that we can select a target in the top menu (where it says "all") and click to build, run or debug. We can also set breakpoints on the source code. -.. figure:: figures/codeblocks/breakpoint_and_debug.png +.. figure:: ../figures/codeblocks/breakpoint_and_debug.png After clicking to build, the build commands of the underlying build system will be printed in the tab at the bottom. If you clicked to debug, the program will start automatically and stop at the first breakpoint. -.. figure:: figures/codeblocks/build_finished_breakpoint_waiting.png +.. figure:: ../figures/codeblocks/build_finished_breakpoint_waiting.png You can inspect memory and the current stack enabling those views in Debug->Debugging Windows->Watches and Call Stack. Using the debugging buttons, you can advance line by line, continue until the next breakpoint. -.. figure:: figures/codeblocks/debug_watches.png +.. figure:: ../figures/codeblocks/debug_watches.png Note: as Code::Blocks doesn't natively support CMake projects, it doesn't refresh the CMake cache, which means you will need to close the project, run the ``./ns3`` command to refresh the CMake caches after adding/removing @@ -1204,7 +1210,7 @@ Start by installing `XCode `_. Then open it for the first time and accept the license. Then open Xcode->Preferences->Locations and select the command-line tools location. -.. figure:: figures/xcode/select_command_line.png +.. figure:: ../figures/xcode/select_command_line.png XCode does not support CMake project natively, but we can use the corresponding CMake generator to generate a project in order to use it. The generator name depends on the operating @@ -1225,27 +1231,27 @@ There will be a NS3.xcodeproj file inside the cache folder used during configura Loading the project will take a while, and you will be greeted with the following prompt. Select to automatically create the schemes. -.. figure:: figures/xcode/create_schemes.png +.. figure:: ../figures/xcode/create_schemes.png After that we can select a target in the top menu and click to run, which will build and run (if executable, or debug if build with debugging symbols). -.. figure:: figures/xcode/target_dropdown.png +.. figure:: ../figures/xcode/target_dropdown.png After clicking to build, the build will start and progress is shown in the top bar. -.. figure:: figures/xcode/select_target_and_build.png +.. figure:: ../figures/xcode/select_target_and_build.png Before debugging starts, Xcode will request for permissions to attach to the process (as an attacker could pretend to be a debugging tool and steal data from other processes). -.. figure:: figures/xcode/debug_permission_to_attach.png +.. figure:: ../figures/xcode/debug_permission_to_attach.png After attaching, we are greeted with profiling information and call stack on the left panel, source code, breakpoint and warnings on the central panel. At the bottom there are the memory watches panel in the left and the output panel on the right, which is also used to read the command line. -.. figure:: figures/xcode/profiling_stack_watches_output.png +.. figure:: ../figures/xcode/profiling_stack_watches_output.png Note: as XCode doesn't natively support CMake projects, it doesn't refresh the CMake cache, which means you diff --git a/doc/tutorial/source/quick-start.rst b/doc/tutorial/source/quick-start.rst index 97ba7e0de..6c022d907 100644 --- a/doc/tutorial/source/quick-start.rst +++ b/doc/tutorial/source/quick-start.rst @@ -39,7 +39,10 @@ We focus in this chapter only on getting |ns3| up and running on a system supported by a recent C++ compiler and Python runtime support. For Linux, use either g++ or clang++ compilers. For macOS, use clang++ -(available in Xcode or Xcode Command Line Tools). For Windows, we recommend +(available in Xcode or Xcode Command Line Tools). For Windows, Msys2 tools +with the MinGW64 toolchain can be used (since ns-3.37) for most use +cases. For releases earlier than ns-3.37, or for use of emulation modes +or Python bindings, we recommend to either use a Linux virtual machine, or the Windows Subsystem for Linux. Downloading ns-3 @@ -61,13 +64,13 @@ Downloading the Latest Release :: - $ tar xjf ns-allinone-3.36.1.tar.bz2 + $ tar xjf ns-allinone-3.37.tar.bz2 3) Change into the |ns3| directory directly; e.g. :: - $ cd ns-allinone-3.36.1/ns-3.36.1 + $ cd ns-allinone-3.37/ns-3.37 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. @@ -89,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.36.1 as of this +If instead you want to try the most recent release (version 3.37 as of this writing), you can checkout a branch corresponding to that git tag: :: - $ git checkout -b ns-3.36.1-branch ns-3.36.1 + $ git checkout -b ns-3.37-branch ns-3.37 Building and testing ns-3 ************************* diff --git a/doc/tutorial/source/tracing.rst b/doc/tutorial/source/tracing.rst index 293e7ad67..4683bed12 100644 --- a/doc/tutorial/source/tracing.rst +++ b/doc/tutorial/source/tracing.rst @@ -2078,7 +2078,7 @@ generate some pretty pictures: You should now have a graph of the congestion window versus time sitting in the file "cwnd.png" that looks like: -.. figure:: figures/cwnd.png +.. figure:: ../figures/cwnd.png Using Mid-Level Helpers +++++++++++++++++++++++ diff --git a/examples/channel-models/three-gpp-v2v-channel-example.cc b/examples/channel-models/three-gpp-v2v-channel-example.cc index 38c2d65fe..346a69327 100644 --- a/examples/channel-models/three-gpp-v2v-channel-example.cc +++ b/examples/channel-models/three-gpp-v2v-channel-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020, University of Padova, Dep. of Information Engineering, SIGNET lab * @@ -147,7 +146,7 @@ ComputeSnr(const ComputeSnrParams& params) } /** - * Generates a GNU-plottable file representig the buildings deployed in the + * Generates a GNU-plottable file representing the buildings deployed in the * scenario * \param filename the name of the output file */ @@ -155,7 +154,7 @@ void PrintGnuplottableBuildingListToFile(std::string filename) { std::ofstream outFile; - outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + outFile.open(filename, std::ios_base::out | std::ios_base::trunc); if (!outFile.is_open()) { NS_LOG_ERROR("Can't open file " << filename); diff --git a/examples/energy/energy-model-example.cc b/examples/energy/energy-model-example.cc index 5f016369d..54eb780a6 100644 --- a/examples/energy/energy-model-example.cc +++ b/examples/energy/energy-model-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle. * diff --git a/examples/energy/energy-model-with-harvesting-example.cc b/examples/energy/energy-model-with-harvesting-example.cc index f95e9822e..67f1b2ec8 100644 --- a/examples/energy/energy-model-with-harvesting-example.cc +++ b/examples/energy/energy-model-with-harvesting-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2014 Wireless Communications and Networking Group (WCNG), * University of Rochester, Rochester, NY, USA. diff --git a/examples/error-model/simple-error-model.cc b/examples/error-model/simple-error-model.cc index 9023f0821..1f260ab04 100644 --- a/examples/error-model/simple-error-model.cc +++ b/examples/error-model/simple-error-model.cc @@ -1,4 +1,3 @@ -/* -*- 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/ipv6/fragmentation-ipv6-PMTU.cc b/examples/ipv6/fragmentation-ipv6-PMTU.cc index 38b9d0382..4b941bfde 100644 --- a/examples/ipv6/fragmentation-ipv6-PMTU.cc +++ b/examples/ipv6/fragmentation-ipv6-PMTU.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008-2009 Strasbourg University * Copyright (c) 2013 Universita' di Firenze diff --git a/examples/ipv6/fragmentation-ipv6-two-MTU.cc b/examples/ipv6/fragmentation-ipv6-two-MTU.cc index 6206103a5..df797b4e8 100644 --- a/examples/ipv6/fragmentation-ipv6-two-MTU.cc +++ b/examples/ipv6/fragmentation-ipv6-two-MTU.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008-2009 Strasbourg University * Copyright (c) 2013 Universita' di Firenze diff --git a/examples/ipv6/fragmentation-ipv6.cc b/examples/ipv6/fragmentation-ipv6.cc index a86d9f9ea..b216a4be4 100644 --- a/examples/ipv6/fragmentation-ipv6.cc +++ b/examples/ipv6/fragmentation-ipv6.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008-2009 Strasbourg University * diff --git a/examples/ipv6/icmpv6-redirect.cc b/examples/ipv6/icmpv6-redirect.cc index 010b6b967..83d01989b 100644 --- a/examples/ipv6/icmpv6-redirect.cc +++ b/examples/ipv6/icmpv6-redirect.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 Strasbourg University * diff --git a/examples/ipv6/loose-routing-ipv6.cc b/examples/ipv6/loose-routing-ipv6.cc index 82a46306c..1bd6048f3 100644 --- a/examples/ipv6/loose-routing-ipv6.cc +++ b/examples/ipv6/loose-routing-ipv6.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 Strasbourg University * diff --git a/examples/ipv6/ping6.cc b/examples/ipv6/ping6.cc index e4f54d043..95d262e13 100644 --- a/examples/ipv6/ping6.cc +++ b/examples/ipv6/ping6.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008-2009 Strasbourg University * diff --git a/examples/ipv6/radvd-two-prefix.cc b/examples/ipv6/radvd-two-prefix.cc index 03d6d6cd6..71c9a4e8a 100644 --- a/examples/ipv6/radvd-two-prefix.cc +++ b/examples/ipv6/radvd-two-prefix.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 Strasbourg University * diff --git a/examples/ipv6/radvd.cc b/examples/ipv6/radvd.cc index 69cca0431..0ce2443ec 100644 --- a/examples/ipv6/radvd.cc +++ b/examples/ipv6/radvd.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 Strasbourg University * diff --git a/examples/ipv6/test-ipv6.cc b/examples/ipv6/test-ipv6.cc index 5b50ff1b8..a168bcf07 100644 --- a/examples/ipv6/test-ipv6.cc +++ b/examples/ipv6/test-ipv6.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 Louis Pasteur University / Telecom Bretagne * diff --git a/examples/ipv6/wsn-ping6.cc b/examples/ipv6/wsn-ping6.cc index 170c74e98..23c88ebad 100644 --- a/examples/ipv6/wsn-ping6.cc +++ b/examples/ipv6/wsn-ping6.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2014 Universita' di Firenze * diff --git a/examples/matrix-topology/matrix-topology.cc b/examples/matrix-topology/matrix-topology.cc index f47fb0fbc..6d050123c 100644 --- a/examples/matrix-topology/matrix-topology.cc +++ b/examples/matrix-topology/matrix-topology.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 Egemen K. Cetinkaya, Justin P. Rohrer, and Amit Dandekar * @@ -273,11 +272,11 @@ main(int argc, char* argv[]) AsciiTraceHelper ascii; p2p.EnableAsciiAll(ascii.CreateFileStream(tr_name)); - // p2p.EnablePcapAll (pcap_name.c_str()); + // p2p.EnablePcapAll(pcap_name); // Ptr flowmon; // FlowMonitorHelper flowmonHelper; - // flowmon = flowmonHelper.InstallAll (); + // flowmon = flowmonHelper.InstallAll(); // Configure animator with default settings @@ -286,7 +285,7 @@ main(int argc, char* argv[]) Simulator::Stop(Seconds(SimTime)); Simulator::Run(); - // flowmon->SerializeToXmlFile (flow_name.c_str(), true, true); + // flowmon->SerializeToXmlFile(flow_name, true, true); Simulator::Destroy(); // ---------- End of Simulation Monitoring --------------------------------- @@ -300,10 +299,10 @@ std::vector> readNxNMatrix(std::string adj_mat_file_name) { std::ifstream adj_mat_file; - adj_mat_file.open(adj_mat_file_name.c_str(), std::ios::in); + adj_mat_file.open(adj_mat_file_name, std::ios::in); if (adj_mat_file.fail()) { - NS_FATAL_ERROR("File " << adj_mat_file_name.c_str() << " not found"); + NS_FATAL_ERROR("File " << adj_mat_file_name << " not found"); } std::vector> array; int i = 0; @@ -365,10 +364,10 @@ std::vector> readCordinatesFile(std::string node_coordinates_file_name) { std::ifstream node_coordinates_file; - node_coordinates_file.open(node_coordinates_file_name.c_str(), std::ios::in); + node_coordinates_file.open(node_coordinates_file_name, std::ios::in); if (node_coordinates_file.fail()) { - NS_FATAL_ERROR("File " << node_coordinates_file_name.c_str() << " not found"); + NS_FATAL_ERROR("File " << node_coordinates_file_name << " not found"); } std::vector> coord_array; int m = 0; diff --git a/examples/naming/object-names.cc b/examples/naming/object-names.cc index 707f893dd..f26d8a82a 100644 --- a/examples/naming/object-names.cc +++ b/examples/naming/object-names.cc @@ -1,4 +1,3 @@ -/* -*- 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/realtime/realtime-udp-echo.cc b/examples/realtime/realtime-udp-echo.cc index 88916f74f..5b3da0783 100644 --- a/examples/realtime/realtime-udp-echo.cc +++ b/examples/realtime/realtime-udp-echo.cc @@ -1,4 +1,3 @@ -/* -*- 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/routing/dynamic-global-routing.cc b/examples/routing/dynamic-global-routing.cc index 99434c225..9e2744726 100644 --- a/examples/routing/dynamic-global-routing.cc +++ b/examples/routing/dynamic-global-routing.cc @@ -1,4 +1,3 @@ -/* -*- 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/routing/global-injection-slash32.cc b/examples/routing/global-injection-slash32.cc index c0ad22943..ff48313f3 100644 --- a/examples/routing/global-injection-slash32.cc +++ b/examples/routing/global-injection-slash32.cc @@ -1,4 +1,3 @@ -/* -*- 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/routing/global-routing-multi-switch-plus-router.cc b/examples/routing/global-routing-multi-switch-plus-router.cc index 71c911862..b76a19147 100644 --- a/examples/routing/global-routing-multi-switch-plus-router.cc +++ b/examples/routing/global-routing-multi-switch-plus-router.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 - Chip Webb * diff --git a/examples/routing/global-routing-slash32.cc b/examples/routing/global-routing-slash32.cc index c3cf7a937..55ee91d06 100644 --- a/examples/routing/global-routing-slash32.cc +++ b/examples/routing/global-routing-slash32.cc @@ -1,4 +1,3 @@ -/* -*- 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/routing/manet-routing-compare.cc b/examples/routing/manet-routing-compare.cc index 5db68e23f..bac711faf 100644 --- a/examples/routing/manet-routing-compare.cc +++ b/examples/routing/manet-routing-compare.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 University of Kansas * @@ -188,7 +187,7 @@ RoutingExperiment::CheckThroughput() double kbs = (bytesTotal * 8.0) / 1000; bytesTotal = 0; - std::ofstream out(m_CSVfileName.c_str(), std::ios::app); + std::ofstream out(m_CSVfileName, std::ios::app); out << (Simulator::Now()).GetSeconds() << "," << kbs << "," << packetsReceived << "," << m_nSinks << "," << m_protocolName << "," << m_txp << "" << std::endl; @@ -228,7 +227,7 @@ main(int argc, char* argv[]) std::string CSVfileName = experiment.CommandSetup(argc, argv); // blank out the last output file and write the column headers - std::ofstream out(CSVfileName.c_str()); + std::ofstream out(CSVfileName); out << "SimulationSecond," << "ReceiveRate," << "PacketsReceived," @@ -297,7 +296,7 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) NetDeviceContainer adhocDevices = wifi.Install(wifiPhy, wifiMac, adhocNodes); MobilityHelper mobilityAdhoc; - [[maybe_unused]] int64_t streamIndex = 0; // used to get consistent mobility across scenarios + int64_t streamIndex = 0; // used to get consistent mobility across scenarios ObjectFactory pos; pos.SetTypeId("ns3::RandomRectanglePositionAllocator"); @@ -402,19 +401,19 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) ss4 << rate; std::string sRate = ss4.str(); - // NS_LOG_INFO ("Configure Tracing."); + // NS_LOG_INFO("Configure Tracing."); // tr_name = tr_name + "_" + m_protocolName +"_" + nodes + "nodes_" + sNodeSpeed + "speed_" + // sNodePause + "pause_" + sRate + "rate"; // AsciiTraceHelper ascii; - // Ptr osw = ascii.CreateFileStream ( (tr_name + ".tr").c_str()); - // wifiPhy.EnableAsciiAll (osw); + // Ptr osw = ascii.CreateFileStream(tr_name + ".tr"); + // wifiPhy.EnableAsciiAll(osw); AsciiTraceHelper ascii; MobilityHelper::EnableAsciiAll(ascii.CreateFileStream(tr_name + ".mob")); // Ptr flowmon; // FlowMonitorHelper flowmonHelper; - // flowmon = flowmonHelper.InstallAll (); + // flowmon = flowmonHelper.InstallAll(); NS_LOG_INFO("Run Simulation."); @@ -423,7 +422,7 @@ RoutingExperiment::Run(int nSinks, double txp, std::string CSVfileName) Simulator::Stop(Seconds(TotalTime)); Simulator::Run(); - // flowmon->SerializeToXmlFile ((tr_name + ".flowmon").c_str(), false, false); + // flowmon->SerializeToXmlFile(tr_name + ".flowmon", false, false); Simulator::Destroy(); } diff --git a/examples/routing/mixed-global-routing.cc b/examples/routing/mixed-global-routing.cc index 0bd822420..9a14011b7 100644 --- a/examples/routing/mixed-global-routing.cc +++ b/examples/routing/mixed-global-routing.cc @@ -1,4 +1,3 @@ -/* -*- 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/routing/rip-simple-network.cc b/examples/routing/rip-simple-network.cc index b202b6c73..0f95ed6a8 100644 --- a/examples/routing/rip-simple-network.cc +++ b/examples/routing/rip-simple-network.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2016 Universita' di Firenze, Italy * diff --git a/examples/routing/ripng-simple-network.cc b/examples/routing/ripng-simple-network.cc index e55975b37..64178e02f 100644 --- a/examples/routing/ripng-simple-network.cc +++ b/examples/routing/ripng-simple-network.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2014 Universita' di Firenze, Italy * diff --git a/examples/routing/simple-alternate-routing.cc b/examples/routing/simple-alternate-routing.cc index 102692132..4273d4fc6 100644 --- a/examples/routing/simple-alternate-routing.cc +++ b/examples/routing/simple-alternate-routing.cc @@ -1,4 +1,3 @@ -/* -*- 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/routing/simple-global-routing.cc b/examples/routing/simple-global-routing.cc index 0de09dfd8..9efd8cca8 100644 --- a/examples/routing/simple-global-routing.cc +++ b/examples/routing/simple-global-routing.cc @@ -1,4 +1,3 @@ -/* -*- 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/routing/simple-multicast-flooding.cc b/examples/routing/simple-multicast-flooding.cc index a332dab30..9f6c81428 100644 --- a/examples/routing/simple-multicast-flooding.cc +++ b/examples/routing/simple-multicast-flooding.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2013 Universita' di Firenze * Copyright (c) 2019 Caliola Engineering, LLC : RFC 6621 multicast packet de-duplication diff --git a/examples/routing/simple-routing-ping6.cc b/examples/routing/simple-routing-ping6.cc index 555e40da4..4ea404e45 100644 --- a/examples/routing/simple-routing-ping6.cc +++ b/examples/routing/simple-routing-ping6.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008-2009 Strasbourg University * diff --git a/examples/routing/static-routing-slash32.cc b/examples/routing/static-routing-slash32.cc index bb1ac1010..bd4188d3d 100644 --- a/examples/routing/static-routing-slash32.cc +++ b/examples/routing/static-routing-slash32.cc @@ -1,4 +1,3 @@ -/* -*- 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/socket/socket-bound-static-routing.cc b/examples/socket/socket-bound-static-routing.cc index 3892c8623..c34e596cd 100644 --- a/examples/socket/socket-bound-static-routing.cc +++ b/examples/socket/socket-bound-static-routing.cc @@ -1,4 +1,3 @@ -/* -*- 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/socket/socket-bound-tcp-static-routing.cc b/examples/socket/socket-bound-tcp-static-routing.cc index f3687b2ab..dc88e4366 100644 --- a/examples/socket/socket-bound-tcp-static-routing.cc +++ b/examples/socket/socket-bound-tcp-static-routing.cc @@ -1,4 +1,3 @@ -/* -*- 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/socket/socket-options-ipv4.cc b/examples/socket/socket-options-ipv4.cc index e5d31b017..417eaee9e 100644 --- a/examples/socket/socket-options-ipv4.cc +++ b/examples/socket/socket-options-ipv4.cc @@ -1,4 +1,3 @@ -/* -*- 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/socket/socket-options-ipv6.cc b/examples/socket/socket-options-ipv6.cc index 3dc0e0d17..dd2609a39 100644 --- a/examples/socket/socket-options-ipv6.cc +++ b/examples/socket/socket-options-ipv6.cc @@ -1,4 +1,3 @@ -/* -*- 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/stats/wifi-example-apps.cc b/examples/stats/wifi-example-apps.cc index 4d868b164..9d07a8b34 100644 --- a/examples/stats/wifi-example-apps.cc +++ b/examples/stats/wifi-example-apps.cc @@ -1,4 +1,3 @@ -/* -*- 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/stats/wifi-example-apps.h b/examples/stats/wifi-example-apps.h index 026aeae05..2e8e1488e 100644 --- a/examples/stats/wifi-example-apps.h +++ b/examples/stats/wifi-example-apps.h @@ -1,4 +1,3 @@ -/* -*- 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/stats/wifi-example-sim.cc b/examples/stats/wifi-example-sim.cc index b482909cb..6fbe90632 100644 --- a/examples/stats/wifi-example-sim.cc +++ b/examples/stats/wifi-example-sim.cc @@ -1,4 +1,3 @@ -/* -*- 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/tcp/dctcp-example.cc b/examples/tcp/dctcp-example.cc index 65be2c708..0d5e147e2 100644 --- a/examples/tcp/dctcp-example.cc +++ b/examples/tcp/dctcp-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2017-20 NITK Surathkal * Copyright (c) 2020 Tom Henderson (better alignment with experiment) diff --git a/examples/tcp/star.cc b/examples/tcp/star.cc index b2c842a86..d680e5a76 100644 --- a/examples/tcp/star.cc +++ b/examples/tcp/star.cc @@ -1,4 +1,3 @@ -/* -*- 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/tcp/tcp-bbr-example.cc b/examples/tcp/tcp-bbr-example.cc index 8f7b44040..6c027a5e4 100644 --- a/examples/tcp/tcp-bbr-example.cc +++ b/examples/tcp/tcp-bbr-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2018-20 NITK Surathkal * diff --git a/examples/tcp/tcp-bulk-send.cc b/examples/tcp/tcp-bulk-send.cc index 5404b3fae..427ff9901 100644 --- a/examples/tcp/tcp-bulk-send.cc +++ b/examples/tcp/tcp-bulk-send.cc @@ -1,4 +1,3 @@ -/* -*- 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/tcp/tcp-large-transfer.cc b/examples/tcp/tcp-large-transfer.cc index e3ee16527..98ecbb8b7 100644 --- a/examples/tcp/tcp-large-transfer.cc +++ b/examples/tcp/tcp-large-transfer.cc @@ -1,4 +1,3 @@ -/* -*- 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/tcp/tcp-linux-reno.cc b/examples/tcp/tcp-linux-reno.cc index 6d354739b..e617b6aee 100644 --- a/examples/tcp/tcp-linux-reno.cc +++ b/examples/tcp/tcp-linux-reno.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2019 NITK Surathkal * @@ -61,7 +60,7 @@ CheckQueueSize(Ptr queue) // Check queue size every 1/100 of a second Simulator::Schedule(Seconds(0.001), &CheckQueueSize, queue); - std::ofstream fPlotQueue(std::stringstream(dir + "queue-size.dat").str().c_str(), + std::ofstream fPlotQueue(std::stringstream(dir + "queue-size.dat").str(), std::ios::out | std::ios::app); fPlotQueue << Simulator::Now().GetSeconds() << " " << qSize << std::endl; fPlotQueue.close(); @@ -232,7 +231,7 @@ main(int argc, char* argv[]) // Create directories to store dat files struct stat buffer; - [[maybe_unused]] int retVal; + int retVal [[maybe_unused]]; if ((stat(dir.c_str(), &buffer)) == 0) { std::string dirToRemove = "rm -rf " + dir; diff --git a/examples/tcp/tcp-pacing.cc b/examples/tcp/tcp-pacing.cc index 31ff04e53..8ad772eee 100644 --- a/examples/tcp/tcp-pacing.cc +++ b/examples/tcp/tcp-pacing.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 NITK Surathkal * diff --git a/examples/tcp/tcp-pcap-nanosec-example.cc b/examples/tcp/tcp-pcap-nanosec-example.cc index b31cbd2b8..eed95060a 100644 --- a/examples/tcp/tcp-pcap-nanosec-example.cc +++ b/examples/tcp/tcp-pcap-nanosec-example.cc @@ -1,4 +1,3 @@ -/* -*- 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/tcp/tcp-star-server.cc b/examples/tcp/tcp-star-server.cc index 2c86f89e1..b406431be 100644 --- a/examples/tcp/tcp-star-server.cc +++ b/examples/tcp/tcp-star-server.cc @@ -1,4 +1,3 @@ -/* -*- 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/tcp/tcp-validation.cc b/examples/tcp/tcp-validation.cc index e8868a58b..6c71e3751 100644 --- a/examples/tcp/tcp-validation.cc +++ b/examples/tcp/tcp-validation.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2019 Cable Television Laboratories, Inc. * Copyright (c) 2020 Tom Henderson (adapted for DCTCP testing) @@ -844,29 +843,28 @@ main(int argc, char* argv[]) std::ofstream queueLengthOfStream; if (g_validate == "") { - pingOfStream.open(pingTraceFile.c_str(), std::ofstream::out); - firstTcpRttOfStream.open(firstTcpRttTraceFile.c_str(), std::ofstream::out); - firstTcpCwndOfStream.open(firstTcpCwndTraceFile.c_str(), std::ofstream::out); - firstTcpThroughputOfStream.open(firstTcpThroughputTraceFile.c_str(), std::ofstream::out); + pingOfStream.open(pingTraceFile, std::ofstream::out); + firstTcpRttOfStream.open(firstTcpRttTraceFile, std::ofstream::out); + firstTcpCwndOfStream.open(firstTcpCwndTraceFile, std::ofstream::out); + firstTcpThroughputOfStream.open(firstTcpThroughputTraceFile, std::ofstream::out); if (firstTcpType == "dctcp") { - firstTcpDctcpOfStream.open(firstDctcpTraceFile.c_str(), std::ofstream::out); + firstTcpDctcpOfStream.open(firstDctcpTraceFile, std::ofstream::out); } if (enableSecondTcp) { - secondTcpRttOfStream.open(secondTcpRttTraceFile.c_str(), std::ofstream::out); - secondTcpCwndOfStream.open(secondTcpCwndTraceFile.c_str(), std::ofstream::out); - secondTcpThroughputOfStream.open(secondTcpThroughputTraceFile.c_str(), - std::ofstream::out); + secondTcpRttOfStream.open(secondTcpRttTraceFile, std::ofstream::out); + secondTcpCwndOfStream.open(secondTcpCwndTraceFile, std::ofstream::out); + secondTcpThroughputOfStream.open(secondTcpThroughputTraceFile, std::ofstream::out); if (secondTcpType == "dctcp") { - secondTcpDctcpOfStream.open(secondDctcpTraceFile.c_str(), std::ofstream::out); + secondTcpDctcpOfStream.open(secondDctcpTraceFile, std::ofstream::out); } } - queueDropOfStream.open(queueDropTraceFile.c_str(), std::ofstream::out); - queueMarkOfStream.open(queueMarkTraceFile.c_str(), std::ofstream::out); - queueMarksFrequencyOfStream.open(queueMarksFrequencyTraceFile.c_str(), std::ofstream::out); - queueLengthOfStream.open(queueLengthTraceFile.c_str(), std::ofstream::out); + queueDropOfStream.open(queueDropTraceFile, std::ofstream::out); + queueMarkOfStream.open(queueMarkTraceFile, std::ofstream::out); + queueMarksFrequencyOfStream.open(queueMarksFrequencyTraceFile, std::ofstream::out); + queueLengthOfStream.open(queueLengthTraceFile, std::ofstream::out); } //////////////////////////////////////////////////////////// diff --git a/examples/tcp/tcp-variants-comparison.cc b/examples/tcp/tcp-variants-comparison.cc index 6d0354e6c..e987a7b08 100644 --- a/examples/tcp/tcp-variants-comparison.cc +++ b/examples/tcp/tcp-variants-comparison.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2013 ResiliNets, ITTC, University of Kansas * @@ -29,7 +28,7 @@ * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI), * US Department of Defense (DoD), and ITTC at The University of Kansas. * - * “TCP Westwood(+) Protocol Implementation in ns-3” + * "TCP Westwood(+) Protocol Implementation in ns-3" * Siddharth Gangadhar, Trúc Anh Ngọc Nguyễn , Greeshma Umapathi, and James P.G. Sterbenz, * ICST SIMUTools Workshop on ns-3 (WNS3), Cannes, France, March 2013 */ @@ -190,7 +189,7 @@ RtoTracer(std::string context, Time oldval, Time newval) * \param nextTx Next sequence number. */ static void -NextTxTracer(std::string context, [[maybe_unused]] SequenceNumber32 old, SequenceNumber32 nextTx) +NextTxTracer(std::string context, SequenceNumber32 old [[maybe_unused]], SequenceNumber32 nextTx) { uint32_t nodeId = GetNodeIdFromContext(context); @@ -206,7 +205,7 @@ NextTxTracer(std::string context, [[maybe_unused]] SequenceNumber32 old, Sequenc * \param inFlight In flight value. */ static void -InFlightTracer(std::string context, [[maybe_unused]] uint32_t old, uint32_t inFlight) +InFlightTracer(std::string context, uint32_t old [[maybe_unused]], uint32_t inFlight) { uint32_t nodeId = GetNodeIdFromContext(context); @@ -222,7 +221,7 @@ InFlightTracer(std::string context, [[maybe_unused]] uint32_t old, uint32_t inFl * \param nextRx Next sequence number. */ static void -NextRxTracer(std::string context, [[maybe_unused]] SequenceNumber32 old, SequenceNumber32 nextRx) +NextRxTracer(std::string context, SequenceNumber32 old [[maybe_unused]], SequenceNumber32 nextRx) { uint32_t nodeId = GetNodeIdFromContext(context); @@ -553,13 +552,13 @@ main(int argc, char* argv[]) { std::ofstream ascii; Ptr ascii_wrap; - ascii.open((prefix_file_name + "-ascii").c_str()); + ascii.open(prefix_file_name + "-ascii"); ascii_wrap = new OutputStreamWrapper(prefix_file_name + "-ascii", std::ios::out); stack.EnableAsciiIpv4All(ascii_wrap); for (uint16_t index = 0; index < num_flows; index++) { - std::string flowString(""); + std::string flowString; if (num_flows > 1) { flowString = "-flow" + std::to_string(index); diff --git a/examples/traffic-control/cobalt-vs-codel.cc b/examples/traffic-control/cobalt-vs-codel.cc index b71006986..ac098d8af 100644 --- a/examples/traffic-control/cobalt-vs-codel.cc +++ b/examples/traffic-control/cobalt-vs-codel.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2019 NITK Surathkal * diff --git a/examples/traffic-control/queue-discs-benchmark.cc b/examples/traffic-control/queue-discs-benchmark.cc index 3d4d5999d..dab856d7a 100644 --- a/examples/traffic-control/queue-discs-benchmark.cc +++ b/examples/traffic-control/queue-discs-benchmark.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 Universita' degli Studi di Napoli Federico II * diff --git a/examples/traffic-control/red-vs-fengadaptive.cc b/examples/traffic-control/red-vs-fengadaptive.cc index 07a4ab537..22011da7c 100644 --- a/examples/traffic-control/red-vs-fengadaptive.cc +++ b/examples/traffic-control/red-vs-fengadaptive.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2016 NITK Surathkal * diff --git a/examples/traffic-control/red-vs-nlred.cc b/examples/traffic-control/red-vs-nlred.cc index c34342423..05a3403a1 100644 --- a/examples/traffic-control/red-vs-nlred.cc +++ b/examples/traffic-control/red-vs-nlred.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2016 NITK Surathkal * diff --git a/examples/traffic-control/tbf-example.cc b/examples/traffic-control/tbf-example.cc index d5dfe3c6d..1344ae739 100644 --- a/examples/traffic-control/tbf-example.cc +++ b/examples/traffic-control/tbf-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 Universita' degli Studi di Napoli "Federico II" * 2017 Kungliga Tekniska Högskolan diff --git a/examples/traffic-control/traffic-control.cc b/examples/traffic-control/traffic-control.cc index 4206ec535..85fe47b14 100644 --- a/examples/traffic-control/traffic-control.cc +++ b/examples/traffic-control/traffic-control.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 Universita' degli Studi di Napoli "Federico II" * diff --git a/examples/tutorial/fifth.cc b/examples/tutorial/fifth.cc index 53b175489..c1b6153ad 100644 --- a/examples/tutorial/fifth.cc +++ b/examples/tutorial/fifth.cc @@ -1,4 +1,3 @@ -/* -*- 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/tutorial/first.cc b/examples/tutorial/first.cc index 6638ffc71..89c88891d 100644 --- a/examples/tutorial/first.cc +++ b/examples/tutorial/first.cc @@ -1,4 +1,3 @@ -/* -*- 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/tutorial/fourth.cc b/examples/tutorial/fourth.cc index 42aa6b65b..460e373a4 100644 --- a/examples/tutorial/fourth.cc +++ b/examples/tutorial/fourth.cc @@ -1,4 +1,3 @@ -/* -*- 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/tutorial/hello-simulator.cc b/examples/tutorial/hello-simulator.cc index 9d18aa066..86ae3aa3a 100644 --- a/examples/tutorial/hello-simulator.cc +++ b/examples/tutorial/hello-simulator.cc @@ -1,4 +1,3 @@ -/* -*- 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/tutorial/second.cc b/examples/tutorial/second.cc index 2d82a6fa0..a732ea4bd 100644 --- a/examples/tutorial/second.cc +++ b/examples/tutorial/second.cc @@ -1,4 +1,3 @@ -/* -*- 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/tutorial/second.py b/examples/tutorial/second.py index 3d7f24e18..0eb60e4e5 100644 --- a/examples/tutorial/second.py +++ b/examples/tutorial/second.py @@ -26,37 +26,26 @@ import sys # // point-to-point | | | | # // ================ # // LAN 10.1.2.0 -ns.cppyy.cppdef(""" -using namespace ns3; -CommandLine& GetCommandLine(std::string filename, int& nCsma, bool& verbose) -{ - static CommandLine cmd = CommandLine(filename); - cmd.AddValue("nCsma", "Number of extra CSMA nodes/devices", nCsma); - cmd.AddValue("verbose", "Tell echo applications to log if true", verbose); - return cmd; -} -""") from ctypes import c_int, c_bool nCsma = c_int(3) verbose = c_bool(True) -cmd = ns.cppyy.gbl.GetCommandLine(__file__, nCsma, verbose) +cmd = ns.CommandLine(__file__) +cmd.AddValue("nCsma", "Number of extra CSMA nodes/devices", nCsma) +cmd.AddValue("verbose", "Tell echo applications to log if true", verbose) cmd.Parse(sys.argv) -nCsma = nCsma.value -verbose = verbose.value - -if verbose == "True": +if verbose.value: ns.core.LogComponentEnable("UdpEchoClientApplication", ns.core.LOG_LEVEL_INFO) ns.core.LogComponentEnable("UdpEchoServerApplication", ns.core.LOG_LEVEL_INFO) -nCsma = 1 if nCsma == 0 else nCsma +nCsma.value = 1 if nCsma.value == 0 else nCsma.value p2pNodes = ns.network.NodeContainer() p2pNodes.Create(2) csmaNodes = ns.network.NodeContainer() csmaNodes.Add(p2pNodes.Get(1)) -csmaNodes.Create(nCsma) +csmaNodes.Create(nCsma.value) pointToPoint = ns.point_to_point.PointToPointHelper() pointToPoint.SetDeviceAttribute("DataRate", ns.core.StringValue("5Mbps")) @@ -83,11 +72,11 @@ csmaInterfaces = address.Assign(csmaDevices) echoServer = ns.applications.UdpEchoServerHelper(9) -serverApps = echoServer.Install(csmaNodes.Get(nCsma)) +serverApps = echoServer.Install(csmaNodes.Get(nCsma.value)) serverApps.Start(ns.core.Seconds(1.0)) serverApps.Stop(ns.core.Seconds(10.0)) -echoClient = ns.applications.UdpEchoClientHelper(ns.addressFromIpv4Address(csmaInterfaces.GetAddress(nCsma)), 9) +echoClient = ns.applications.UdpEchoClientHelper(ns.addressFromIpv4Address(csmaInterfaces.GetAddress(nCsma.value)), 9) echoClient.SetAttribute("MaxPackets", ns.core.UintegerValue(1)) echoClient.SetAttribute("Interval", ns.core.TimeValue(ns.core.Seconds (1.0))) echoClient.SetAttribute("PacketSize", ns.core.UintegerValue(1024)) diff --git a/examples/tutorial/seventh.cc b/examples/tutorial/seventh.cc index f09393e5e..0f35e8271 100644 --- a/examples/tutorial/seventh.cc +++ b/examples/tutorial/seventh.cc @@ -1,4 +1,3 @@ -/* -*- 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/tutorial/sixth.cc b/examples/tutorial/sixth.cc index 831be67df..4fa7629c9 100644 --- a/examples/tutorial/sixth.cc +++ b/examples/tutorial/sixth.cc @@ -1,4 +1,3 @@ -/* -*- 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/tutorial/third.cc b/examples/tutorial/third.cc index 3ff5d1d08..8356fdd39 100644 --- a/examples/tutorial/third.cc +++ b/examples/tutorial/third.cc @@ -1,4 +1,3 @@ -/* -*- 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/tutorial/third.py b/examples/tutorial/third.py index 622162af6..d24402371 100644 --- a/examples/tutorial/third.py +++ b/examples/tutorial/third.py @@ -30,30 +30,28 @@ import sys # // ================ # // LAN 10.1.2.0 -cmd = ns.getCommandLine(__file__) -nCsma ="3" -verbose = "True" -nWifi = "3" -tracing = "False" +from ctypes import c_bool, c_int +nCsma = c_int(3) +verbose = c_bool(True) +nWifi = c_int(3) +tracing = c_bool(False) -cmd.AddValue("nCsma", "Number of extra CSMA nodes/devices", ns.null_callback(), nCsma) -cmd.AddValue("nWifi", "Number of wifi STA devices", ns.null_callback(), nWifi) -cmd.AddValue("verbose", "Tell echo applications to log if true", ns.null_callback(), verbose) -cmd.AddValue("tracing", "Enable pcap tracing", ns.null_callback(), tracing) +cmd = ns.CommandLine(__file__) +cmd.AddValue("nCsma", "Number of extra CSMA nodes/devices", nCsma) +cmd.AddValue("nWifi", "Number of wifi STA devices", nWifi) +cmd.AddValue("verbose", "Tell echo applications to log if true", verbose) +cmd.AddValue("tracing", "Enable pcap tracing", tracing) cmd.Parse(sys.argv) -nCsma = int(nCsma) -nWifi = int(nWifi) - # The underlying restriction of 18 is due to the grid position # allocator's configuration; the grid layout will exceed the # bounding box if more than 18 nodes are provided. -if nWifi > 18: +if nWifi.value > 18: print("nWifi should be 18 or less; otherwise grid layout exceeds the bounding box") sys.exit(1) -if verbose == "True": +if verbose.value: ns.core.LogComponentEnable("UdpEchoClientApplication", ns.core.LOG_LEVEL_INFO) ns.core.LogComponentEnable("UdpEchoServerApplication", ns.core.LOG_LEVEL_INFO) @@ -68,7 +66,7 @@ p2pDevices = pointToPoint.Install(p2pNodes) csmaNodes = ns.network.NodeContainer() csmaNodes.Add(p2pNodes.Get(1)) -csmaNodes.Create(nCsma) +csmaNodes.Create(nCsma.value) csma = ns.csma.CsmaHelper() csma.SetChannelAttribute("DataRate", ns.core.StringValue("100Mbps")) @@ -77,7 +75,7 @@ csma.SetChannelAttribute("Delay", ns.core.TimeValue(ns.core.NanoSeconds(6560))) csmaDevices = csma.Install(csmaNodes) wifiStaNodes = ns.network.NodeContainer() -wifiStaNodes.Create(nWifi) +wifiStaNodes.Create(nWifi.value) wifiApNode = p2pNodes.Get(0) channel = ns.wifi.YansWifiChannelHelper.Default() @@ -124,16 +122,16 @@ address.Assign(apDevices) echoServer = ns.applications.UdpEchoServerHelper(9) -serverApps = echoServer.Install(csmaNodes.Get(nCsma)) +serverApps = echoServer.Install(csmaNodes.Get(nCsma.value)) serverApps.Start(ns.core.Seconds(1.0)) serverApps.Stop(ns.core.Seconds(10.0)) -echoClient = ns.applications.UdpEchoClientHelper(ns.addressFromIpv4Address(csmaInterfaces.GetAddress(nCsma)), 9) +echoClient = ns.applications.UdpEchoClientHelper(ns.addressFromIpv4Address(csmaInterfaces.GetAddress(nCsma.value)), 9) echoClient.SetAttribute("MaxPackets", ns.core.UintegerValue(1)) echoClient.SetAttribute("Interval", ns.core.TimeValue(ns.core.Seconds (1.0))) echoClient.SetAttribute("PacketSize", ns.core.UintegerValue(1024)) -clientApps = echoClient.Install(wifiStaNodes.Get (nWifi - 1)) +clientApps = echoClient.Install(wifiStaNodes.Get (nWifi.value - 1)) clientApps.Start(ns.core.Seconds(2.0)) clientApps.Stop(ns.core.Seconds(10.0)) @@ -141,7 +139,7 @@ ns.internet.Ipv4GlobalRoutingHelper.PopulateRoutingTables() ns.core.Simulator.Stop(ns.core.Seconds(10.0)) -if tracing == "True": +if tracing.value: phy.SetPcapDataLinkType(phy.DLT_IEEE802_11_RADIO) pointToPoint.EnablePcapAll ("third") phy.EnablePcap ("third", apDevices.Get (0)) diff --git a/examples/tutorial/tutorial-app.cc b/examples/tutorial/tutorial-app.cc index 4a85f024f..821cc0e9c 100644 --- a/examples/tutorial/tutorial-app.cc +++ b/examples/tutorial/tutorial-app.cc @@ -1,4 +1,3 @@ -/* -*- 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/tutorial/tutorial-app.h b/examples/tutorial/tutorial-app.h index 5fa402d92..e6352d2cf 100644 --- a/examples/tutorial/tutorial-app.h +++ b/examples/tutorial/tutorial-app.h @@ -1,4 +1,3 @@ -/* -*- 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/udp-client-server/udp-client-server.cc b/examples/udp-client-server/udp-client-server.cc index 767a0e000..44c14a9c9 100644 --- a/examples/udp-client-server/udp-client-server.cc +++ b/examples/udp-client-server/udp-client-server.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/examples/udp-client-server/udp-trace-client-server.cc b/examples/udp-client-server/udp-trace-client-server.cc index a000d723b..03e922e33 100644 --- a/examples/udp-client-server/udp-trace-client-server.cc +++ b/examples/udp-client-server/udp-trace-client-server.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/examples/udp/udp-echo.cc b/examples/udp/udp-echo.cc index 2110f17d4..e5e2ec6d8 100644 --- a/examples/udp/udp-echo.cc +++ b/examples/udp/udp-echo.cc @@ -1,4 +1,3 @@ -/* -*- 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/wireless/mixed-wired-wireless.cc b/examples/wireless/mixed-wired-wireless.cc index 2b67a94f2..1760457f6 100644 --- a/examples/wireless/mixed-wired-wireless.cc +++ b/examples/wireless/mixed-wired-wireless.cc @@ -1,4 +1,3 @@ -/* -*- 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/wireless/mixed-wired-wireless.py b/examples/wireless/mixed-wired-wireless.py index 71b3d452e..c17f39d1a 100644 --- a/examples/wireless/mixed-wired-wireless.py +++ b/examples/wireless/mixed-wired-wireless.py @@ -68,12 +68,12 @@ def main(argv): # First, we initialize a few local variables that control some # simulation parameters. # - - cmd = ns.getCommandLine(__file__) - cmd.backboneNodes = "10" - cmd.infraNodes = "2" - cmd.lanNodes = "2" - cmd.stopTime = "20" + from ctypes import c_int, c_double + backboneNodes = c_int(10) + infraNodes = c_int(2) + lanNodes = c_int(2) + stopTime = c_double(20) + cmd = ns.CommandLine(__file__) # # Simulation defaults are typically set next, before command line @@ -88,10 +88,10 @@ def main(argv): # "--backboneNodes=20" # - cmd.AddValue("backboneNodes", "number of backbone nodes", ns.null_callback(), cmd.backboneNodes) - cmd.AddValue("infraNodes", "number of leaf nodes", ns.null_callback(), cmd.infraNodes) - cmd.AddValue("lanNodes", "number of LAN nodes", ns.null_callback(), cmd.lanNodes) - cmd.AddValue("stopTime", "simulation stop time(seconds)", ns.null_callback(), cmd.stopTime) + 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) # # The system global variables and the local values added to the argument @@ -99,12 +99,7 @@ def main(argv): # cmd.Parse(argv) - backboneNodes = int(cmd.backboneNodes) - infraNodes = int(cmd.infraNodes) - lanNodes = int(cmd.lanNodes) - stopTime = int(cmd.stopTime) - - if (stopTime < 10): + if (stopTime.value < 10): print ("Use a simulation stop time >= 10 seconds") exit(1) # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # / @@ -118,7 +113,7 @@ def main(argv): # Later we'll create the rest of the nodes we'll need. # backbone = ns.network.NodeContainer() - backbone.Create(backboneNodes) + backbone.Create(backboneNodes.value) # # Create the backbone wifi net devices and install them into the nodes in # our container @@ -179,7 +174,7 @@ def main(argv): # the "172.16 address space ipAddrs.SetBase(ns.network.Ipv4Address("172.16.0.0"), ns.network.Ipv4Mask("255.255.255.0")) - for i in range(backboneNodes): + for i in range(backboneNodes.value): print ("Configuring local area network for backbone node ", i) # # Create a container to manage the nodes of the LAN. We need @@ -187,7 +182,7 @@ def main(argv): # with all of the nodes including new and existing nodes # newLanNodes = ns.network.NodeContainer() - newLanNodes.Create(lanNodes - 1) + newLanNodes.Create(lanNodes.value - 1) # Now, create the container with all nodes on this link lan = ns.network.NodeContainer(ns.network.NodeContainer(backbone.Get(i)), newLanNodes) # @@ -236,7 +231,7 @@ def main(argv): # the "10.0" address space ipAddrs.SetBase(ns.network.Ipv4Address("10.0.0.0"), ns.network.Ipv4Mask("255.255.255.0")) tempRef = [] # list of references to be held to prevent garbage collection - for i in range(backboneNodes): + for i in range(backboneNodes.value): print ("Configuring wireless network for backbone node ", i) # # Create a container to manage the nodes of the LAN. We need @@ -244,7 +239,7 @@ def main(argv): # with all of the nodes including new and existing nodes # stas = ns.network.NodeContainer() - stas.Create(infraNodes - 1) + stas.Create(infraNodes.value - 1) # Now, create the container with all nodes on this link infra = ns.network.NodeContainer(ns.network.NodeContainer(backbone.Get(i)), stas) # @@ -313,8 +308,8 @@ def main(argv): print ("Create Applications.") port = 9 # Discard port(RFC 863) - appSource = ns.network.NodeList.GetNode(backboneNodes) - lastNodeIndex = backboneNodes + backboneNodes*(lanNodes - 1) + backboneNodes*(infraNodes - 1) - 1 + appSource = ns.network.NodeList.GetNode(backboneNodes.value) + lastNodeIndex = backboneNodes.value + backboneNodes.value*(lanNodes.value - 1) + backboneNodes.value*(infraNodes.value - 1) - 1 appSink = ns.network.NodeList.GetNode(lastNodeIndex) ns.cppyy.cppdef(""" @@ -329,7 +324,7 @@ def main(argv): onoff = ns.applications.OnOffHelper("ns3::UdpSocketFactory", genericAddress) apps = onoff.Install(ns.network.NodeContainer(appSource)) apps.Start(ns.core.Seconds(3)) - apps.Stop(ns.core.Seconds(stopTime - 1)) + apps.Stop(ns.core.Seconds(stopTime.value - 1)) # Create a packet sink to receive these packets sink = ns.applications.PacketSinkHelper("ns3::UdpSocketFactory", @@ -374,7 +369,7 @@ def main(argv): # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # print ("Run Simulation.") - ns.core.Simulator.Stop(ns.core.Seconds(stopTime)) + ns.core.Simulator.Stop(ns.core.Seconds(stopTime.value)) ns.core.Simulator.Run() ns.core.Simulator.Destroy() diff --git a/examples/wireless/wifi-80211e-txop.cc b/examples/wireless/wifi-80211e-txop.cc index c42f55e71..08c1a243c 100644 --- a/examples/wireless/wifi-80211e-txop.cc +++ b/examples/wireless/wifi-80211e-txop.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2016 Sébastien Deronne * diff --git a/examples/wireless/wifi-80211n-mimo.cc b/examples/wireless/wifi-80211n-mimo.cc index 348143887..473d73977 100644 --- a/examples/wireless/wifi-80211n-mimo.cc +++ b/examples/wireless/wifi-80211n-mimo.cc @@ -1,4 +1,3 @@ -/* -*- 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/wireless/wifi-adhoc.cc b/examples/wireless/wifi-adhoc.cc index dd8a2b99d..ca38694c3 100644 --- a/examples/wireless/wifi-adhoc.cc +++ b/examples/wireless/wifi-adhoc.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2005,2006,2007 INRIA * diff --git a/examples/wireless/wifi-aggregation.cc b/examples/wireless/wifi-aggregation.cc index 117873f0d..73d58abae 100644 --- a/examples/wireless/wifi-aggregation.cc +++ b/examples/wireless/wifi-aggregation.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2016 Sébastien Deronne * diff --git a/examples/wireless/wifi-ap.cc b/examples/wireless/wifi-ap.cc index 26a243146..888f336ca 100644 --- a/examples/wireless/wifi-ap.cc +++ b/examples/wireless/wifi-ap.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2005,2006,2007 INRIA * diff --git a/examples/wireless/wifi-backward-compatibility.cc b/examples/wireless/wifi-backward-compatibility.cc index 30de8618a..510c10d3d 100644 --- a/examples/wireless/wifi-backward-compatibility.cc +++ b/examples/wireless/wifi-backward-compatibility.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2017 * diff --git a/examples/wireless/wifi-blockack.cc b/examples/wireless/wifi-blockack.cc index c5dd31f21..3ac509d31 100644 --- a/examples/wireless/wifi-blockack.cc +++ b/examples/wireless/wifi-blockack.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 MIRKO BANCHI * diff --git a/examples/wireless/wifi-clear-channel-cmu.cc b/examples/wireless/wifi-clear-channel-cmu.cc index 0d2ebb708..c564f731e 100644 --- a/examples/wireless/wifi-clear-channel-cmu.cc +++ b/examples/wireless/wifi-clear-channel-cmu.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 The Boeing Company * diff --git a/examples/wireless/wifi-dsss-validation.cc b/examples/wireless/wifi-dsss-validation.cc index 78b6262e1..23dcea37f 100644 --- a/examples/wireless/wifi-dsss-validation.cc +++ b/examples/wireless/wifi-dsss-validation.cc @@ -1,4 +1,3 @@ -/* -*- 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/wireless/wifi-error-models-comparison.cc b/examples/wireless/wifi-error-models-comparison.cc index 4c277acd1..01259408b 100644 --- a/examples/wireless/wifi-error-models-comparison.cc +++ b/examples/wireless/wifi-error-models-comparison.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 University of Washington * diff --git a/examples/wireless/wifi-he-network.cc b/examples/wireless/wifi-he-network.cc index 6daab0fb5..bc821d12b 100644 --- a/examples/wireless/wifi-he-network.cc +++ b/examples/wireless/wifi-he-network.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2016 SEBASTIEN DERONNE * diff --git a/examples/wireless/wifi-hidden-terminal.cc b/examples/wireless/wifi-hidden-terminal.cc index e5db32264..fe4b80c24 100644 --- a/examples/wireless/wifi-hidden-terminal.cc +++ b/examples/wireless/wifi-hidden-terminal.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 IITP RAS * diff --git a/examples/wireless/wifi-ht-network.cc b/examples/wireless/wifi-ht-network.cc index f4df8196b..f68d8043b 100644 --- a/examples/wireless/wifi-ht-network.cc +++ b/examples/wireless/wifi-ht-network.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 MIRKO BANCHI * diff --git a/examples/wireless/wifi-mixed-network.cc b/examples/wireless/wifi-mixed-network.cc index 5eb6a046a..22432c8ef 100644 --- a/examples/wireless/wifi-mixed-network.cc +++ b/examples/wireless/wifi-mixed-network.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2016 Sébastien Deronne * diff --git a/examples/wireless/wifi-multi-tos.cc b/examples/wireless/wifi-multi-tos.cc index e98b08233..efdb9d879 100644 --- a/examples/wireless/wifi-multi-tos.cc +++ b/examples/wireless/wifi-multi-tos.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2016 * diff --git a/examples/wireless/wifi-multirate.cc b/examples/wireless/wifi-multirate.cc index 7499c8b37..b68a26035 100644 --- a/examples/wireless/wifi-multirate.cc +++ b/examples/wireless/wifi-multirate.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -702,7 +701,7 @@ main(int argc, char* argv[]) // for commandline input experiment.CommandSetup(argc, argv); - std::ofstream outfile((experiment.GetOutputFileName() + ".plt").c_str()); + std::ofstream outfile(experiment.GetOutputFileName() + ".plt"); MobilityHelper mobility; Gnuplot gnuplot; diff --git a/examples/wireless/wifi-ofdm-eht-validation.cc b/examples/wireless/wifi-ofdm-eht-validation.cc index b221901c1..267ef7469 100644 --- a/examples/wireless/wifi-ofdm-eht-validation.cc +++ b/examples/wireless/wifi-ofdm-eht-validation.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2021 DERONNE SOFTWARE ENGINEERING * diff --git a/examples/wireless/wifi-ofdm-he-validation.cc b/examples/wireless/wifi-ofdm-he-validation.cc index 45def1e10..24a71353b 100644 --- a/examples/wireless/wifi-ofdm-he-validation.cc +++ b/examples/wireless/wifi-ofdm-he-validation.cc @@ -1,4 +1,3 @@ -/* -*- 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/wireless/wifi-ofdm-ht-validation.cc b/examples/wireless/wifi-ofdm-ht-validation.cc index 1a94abcd9..92a431d24 100644 --- a/examples/wireless/wifi-ofdm-ht-validation.cc +++ b/examples/wireless/wifi-ofdm-ht-validation.cc @@ -1,4 +1,3 @@ -/* -*- 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/wireless/wifi-ofdm-validation.cc b/examples/wireless/wifi-ofdm-validation.cc index 24c28888d..6eb1d212a 100644 --- a/examples/wireless/wifi-ofdm-validation.cc +++ b/examples/wireless/wifi-ofdm-validation.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 The Boeing Company * diff --git a/examples/wireless/wifi-ofdm-vht-validation.cc b/examples/wireless/wifi-ofdm-vht-validation.cc index a6f6fc5ce..8e2bded0f 100644 --- a/examples/wireless/wifi-ofdm-vht-validation.cc +++ b/examples/wireless/wifi-ofdm-vht-validation.cc @@ -1,4 +1,3 @@ -/* -*- 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/wireless/wifi-power-adaptation-distance.cc b/examples/wireless/wifi-power-adaptation-distance.cc index bdd39f785..08e28624f 100644 --- a/examples/wireless/wifi-power-adaptation-distance.cc +++ b/examples/wireless/wifi-power-adaptation-distance.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2014 Universidad de la República - Uruguay * @@ -559,7 +558,7 @@ main(int argc, char* argv[]) Simulator::Stop(Seconds(simuTime)); Simulator::Run(); - std::ofstream outfile(("throughput-" + outputFileName + ".plt").c_str()); + std::ofstream outfile("throughput-" + outputFileName + ".plt"); Gnuplot gnuplot = Gnuplot("throughput-" + outputFileName + ".eps", "Throughput"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Throughput (Mb/s)"); @@ -570,7 +569,7 @@ main(int argc, char* argv[]) if (manager == "ns3::ParfWifiManager" || manager == "ns3::AparfWifiManager" || manager == "ns3::RrpaaWifiManager") { - std::ofstream outfile2(("power-" + outputFileName + ".plt").c_str()); + std::ofstream outfile2("power-" + outputFileName + ".plt"); gnuplot = Gnuplot("power-" + outputFileName + ".eps", "Average Transmit Power"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Power (mW)"); diff --git a/examples/wireless/wifi-power-adaptation-interference.cc b/examples/wireless/wifi-power-adaptation-interference.cc index fdace6f8f..b7a8a5baf 100644 --- a/examples/wireless/wifi-power-adaptation-interference.cc +++ b/examples/wireless/wifi-power-adaptation-interference.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2014 Universidad de la República - Uruguay * @@ -712,7 +711,7 @@ main(int argc, char* argv[]) } // Plots for AP0 - std::ofstream outfileTh0(("throughput-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfileTh0("throughput-" + outputFileName + "-0.plt"); Gnuplot gnuplot = Gnuplot("throughput-" + outputFileName + "-0.eps", "Throughput"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Throughput (Mb/s)"); @@ -723,7 +722,7 @@ main(int argc, char* argv[]) if (manager == "ns3::ParfWifiManager" || manager == "ns3::AparfWifiManager" || manager == "ns3::RrpaaWifiManager") { - std::ofstream outfilePower0(("power-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfilePower0("power-" + outputFileName + "-0.plt"); gnuplot = Gnuplot("power-" + outputFileName + "-0.eps", "Average Transmit Power"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Power (mW)"); @@ -732,7 +731,7 @@ main(int argc, char* argv[]) gnuplot.GenerateOutput(outfilePower0); } - std::ofstream outfileTx0(("tx-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfileTx0("tx-" + outputFileName + "-0.plt"); gnuplot = Gnuplot("tx-" + outputFileName + "-0.eps", "Time in TX State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -740,7 +739,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp0.GetTxDatafile()); gnuplot.GenerateOutput(outfileTx0); - std::ofstream outfileRx0(("rx-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfileRx0("rx-" + outputFileName + "-0.plt"); gnuplot = Gnuplot("rx-" + outputFileName + "-0.eps", "Time in RX State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -748,7 +747,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp0.GetRxDatafile()); gnuplot.GenerateOutput(outfileRx0); - std::ofstream outfileBusy0(("busy-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfileBusy0("busy-" + outputFileName + "-0.plt"); gnuplot = Gnuplot("busy-" + outputFileName + "-0.eps", "Time in Busy State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -756,7 +755,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp0.GetBusyDatafile()); gnuplot.GenerateOutput(outfileBusy0); - std::ofstream outfileIdle0(("idle-" + outputFileName + "-0.plt").c_str()); + std::ofstream outfileIdle0("idle-" + outputFileName + "-0.plt"); gnuplot = Gnuplot("idle-" + outputFileName + "-0.eps", "Time in Idle State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -765,7 +764,7 @@ main(int argc, char* argv[]) gnuplot.GenerateOutput(outfileIdle0); // Plots for AP1 - std::ofstream outfileTh1(("throughput-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfileTh1("throughput-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("throughput-" + outputFileName + "-1.eps", "Throughput"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Throughput (Mb/s)"); @@ -776,7 +775,7 @@ main(int argc, char* argv[]) if (manager == "ns3::ParfWifiManager" || manager == "ns3::AparfWifiManager" || manager == "ns3::RrpaaWifiManager") { - std::ofstream outfilePower1(("power-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfilePower1("power-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("power-" + outputFileName + "-1.eps", "Average Transmit Power"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Power (mW)"); @@ -785,7 +784,7 @@ main(int argc, char* argv[]) gnuplot.GenerateOutput(outfilePower1); } - std::ofstream outfileTx1(("tx-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfileTx1("tx-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("tx-" + outputFileName + "-1.eps", "Time in TX State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -793,7 +792,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp1.GetTxDatafile()); gnuplot.GenerateOutput(outfileTx1); - std::ofstream outfileRx1(("rx-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfileRx1("rx-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("rx-" + outputFileName + "-1.eps", "Time in RX State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -801,7 +800,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp1.GetRxDatafile()); gnuplot.GenerateOutput(outfileRx1); - std::ofstream outfileBusy1(("busy-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfileBusy1("busy-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("busy-" + outputFileName + "-1.eps", "Time in Busy State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); @@ -809,7 +808,7 @@ main(int argc, char* argv[]) gnuplot.AddDataset(statisticsAp1.GetBusyDatafile()); gnuplot.GenerateOutput(outfileBusy1); - std::ofstream outfileIdle1(("idle-" + outputFileName + "-1.plt").c_str()); + std::ofstream outfileIdle1("idle-" + outputFileName + "-1.plt"); gnuplot = Gnuplot("idle-" + outputFileName + "-1.eps", "Time in Idle State"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Percent"); diff --git a/examples/wireless/wifi-rate-adaptation-distance.cc b/examples/wireless/wifi-rate-adaptation-distance.cc index 2485dd099..14d2eef4e 100644 --- a/examples/wireless/wifi-rate-adaptation-distance.cc +++ b/examples/wireless/wifi-rate-adaptation-distance.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2014 Universidad de la República - Uruguay * @@ -367,7 +366,7 @@ main(int argc, char* argv[]) Simulator::Stop(Seconds(simuTime)); Simulator::Run(); - std::ofstream outfile(("throughput-" + outputFileName + ".plt").c_str()); + std::ofstream outfile("throughput-" + outputFileName + ".plt"); Gnuplot gnuplot = Gnuplot("throughput-" + outputFileName + ".eps", "Throughput"); gnuplot.SetTerminal("post eps color enhanced"); gnuplot.SetLegend("Time (seconds)", "Throughput (Mb/s)"); diff --git a/examples/wireless/wifi-simple-adhoc-grid.cc b/examples/wireless/wifi-simple-adhoc-grid.cc index 45fcc9a9a..e63530dd4 100644 --- a/examples/wireless/wifi-simple-adhoc-grid.cc +++ b/examples/wireless/wifi-simple-adhoc-grid.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 University of Washington * diff --git a/examples/wireless/wifi-simple-adhoc.cc b/examples/wireless/wifi-simple-adhoc.cc index fc0aee7d2..a7f880e47 100644 --- a/examples/wireless/wifi-simple-adhoc.cc +++ b/examples/wireless/wifi-simple-adhoc.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 The Boeing Company * diff --git a/examples/wireless/wifi-simple-ht-hidden-stations.cc b/examples/wireless/wifi-simple-ht-hidden-stations.cc index 49cb4ce08..a52169032 100644 --- a/examples/wireless/wifi-simple-ht-hidden-stations.cc +++ b/examples/wireless/wifi-simple-ht-hidden-stations.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 Sébastien Deronne * diff --git a/examples/wireless/wifi-simple-infra.cc b/examples/wireless/wifi-simple-infra.cc index d3eb5c8d8..c66c4a915 100644 --- a/examples/wireless/wifi-simple-infra.cc +++ b/examples/wireless/wifi-simple-infra.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 The Boeing Company * diff --git a/examples/wireless/wifi-simple-interference.cc b/examples/wireless/wifi-simple-interference.cc index b6a831ade..575efbd8f 100644 --- a/examples/wireless/wifi-simple-interference.cc +++ b/examples/wireless/wifi-simple-interference.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 The Boeing Company * diff --git a/examples/wireless/wifi-sleep.cc b/examples/wireless/wifi-sleep.cc index b38f2304e..cc3a5260e 100644 --- a/examples/wireless/wifi-sleep.cc +++ b/examples/wireless/wifi-sleep.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 The Boeing Company * 2014 Universita' degli Studi di Napoli "Federico II" @@ -80,7 +79,7 @@ RemainingEnergyTrace(double oldValue, double newValue) std::stringstream ss; ss << "energy_" << node << ".log"; - static std::fstream f(ss.str().c_str(), std::ios::out); + static std::fstream f(ss.str(), std::ios::out); f << Simulator::Now().GetSeconds() << " remaining energy=" << newValue << std::endl; } @@ -101,7 +100,7 @@ PhyStateTrace(std::string context, Time start, Time duration, WifiPhyState state std::stringstream ss; ss << "state_" << node << ".log"; - static std::fstream f(ss.str().c_str(), std::ios::out); + static std::fstream f(ss.str(), std::ios::out); f << Simulator::Now().GetSeconds() << " state=" << state << " start=" << start << " duration=" << duration << std::endl; diff --git a/examples/wireless/wifi-spatial-reuse.cc b/examples/wireless/wifi-spatial-reuse.cc index 759cffbff..9bd4ad4a5 100644 --- a/examples/wireless/wifi-spatial-reuse.cc +++ b/examples/wireless/wifi-spatial-reuse.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2019 University of Washington * @@ -109,7 +108,7 @@ ContextToNodeId(std::string context) { std::string sub = context.substr(10); uint32_t pos = sub.find("/Device"); - return atoi(sub.substr(0, pos).c_str()); + return std::stoi(sub.substr(0, pos)); } void diff --git a/examples/wireless/wifi-spectrum-per-example.cc b/examples/wireless/wifi-spectrum-per-example.cc index 99485a42e..aed4d655f 100644 --- a/examples/wireless/wifi-spectrum-per-example.cc +++ b/examples/wireless/wifi-spectrum-per-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 MIRKO BANCHI * Copyright (c) 2015 University of Washington diff --git a/examples/wireless/wifi-spectrum-per-interference.cc b/examples/wireless/wifi-spectrum-per-interference.cc index 393265a99..0964f3fec 100644 --- a/examples/wireless/wifi-spectrum-per-interference.cc +++ b/examples/wireless/wifi-spectrum-per-interference.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 MIRKO BANCHI * Copyright (c) 2015 University of Washington diff --git a/examples/wireless/wifi-spectrum-saturation-example.cc b/examples/wireless/wifi-spectrum-saturation-example.cc index aa9e99f16..306d16ce5 100644 --- a/examples/wireless/wifi-spectrum-saturation-example.cc +++ b/examples/wireless/wifi-spectrum-saturation-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 MIRKO BANCHI * Copyright (c) 2015 University of Washington diff --git a/examples/wireless/wifi-tcp.cc b/examples/wireless/wifi-tcp.cc index 34fe9a063..125e8f476 100644 --- a/examples/wireless/wifi-tcp.cc +++ b/examples/wireless/wifi-tcp.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015, IMDEA Networks Institute * diff --git a/examples/wireless/wifi-timing-attributes.cc b/examples/wireless/wifi-timing-attributes.cc index 5d06d3241..48d135054 100644 --- a/examples/wireless/wifi-timing-attributes.cc +++ b/examples/wireless/wifi-timing-attributes.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 * diff --git a/examples/wireless/wifi-txop-aggregation.cc b/examples/wireless/wifi-txop-aggregation.cc index e0117cc48..0c2d6d6fd 100644 --- a/examples/wireless/wifi-txop-aggregation.cc +++ b/examples/wireless/wifi-txop-aggregation.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2016 Sébastien Deronne * diff --git a/examples/wireless/wifi-vht-network.cc b/examples/wireless/wifi-vht-network.cc index d5ca3e5ff..1167cebbf 100644 --- a/examples/wireless/wifi-vht-network.cc +++ b/examples/wireless/wifi-vht-network.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 SEBASTIEN DERONNE * diff --git a/examples/wireless/wifi-wired-bridging.cc b/examples/wireless/wifi-wired-bridging.cc index 5564f1597..5408f5573 100644 --- a/examples/wireless/wifi-wired-bridging.cc +++ b/examples/wireless/wifi-wired-bridging.cc @@ -1,4 +1,3 @@ -/* -*- 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/ns3 b/ns3 index 59aa79bdd..8f399bd62 100755 --- a/ns3 +++ b/ns3 @@ -30,7 +30,7 @@ def exit_handler(dry_run): return if print_buffer == "": return - print_buffer = print_buffer.replace('\\','/').replace('//','/').replace('/', os.sep) + print_buffer = print_buffer.replace('\\', '/').replace('//', '/').replace('/', os.sep) if dry_run: print("The following commands would be executed:") elif run_verbose: @@ -110,7 +110,7 @@ def parse_args(argv): parser_configure.add_argument('-d', '--build-profile', help='Build profile', dest='build_profile', - choices=["debug", "default", "release", "optimized"], + choices=["debug", "default", "release", "optimized", "minsizerel"], action="store", type=str, default=None) parser_configure.add_argument('-G', @@ -246,6 +246,15 @@ def parse_args(argv): parser_run.add_argument('-g', '--valgrind', help='Change the default command template to run programs with valgrind', action="store_true", default=None) + parser_run.add_argument('--memray', + help='Use Memray memory profiler for Python scripts. Output will be saved to memray.output', + action="store_true", default=None) + parser_run.add_argument('--heaptrack', + help='Use Heaptrack memory profiler for C++', + action="store_true", default=None) + parser_run.add_argument('--perf', + help='Use Linux\'s perf to profile a program', + action="store_true", default=None) parser_run.add_argument('--vis', '--visualize', help='Modify --run arguments to enable the visualizer', action="store_true", dest="visualize", default=None) @@ -411,8 +420,10 @@ def print_and_buffer(message): def clean_cmake_artifacts(dry_run=False): print_and_buffer("rm -R %s" % os.path.relpath(out_dir, ns3_path)) - if not dry_run: + if out_dir == ns3_path: + raise Exception("The output directory and the ns-3 directory are the same. " + "Deleting it can cause data loss.") shutil.rmtree(out_dir, ignore_errors=True) cmake_cache_files = glob.glob("%s/**/CMakeCache.txt" % ns3_path, recursive=True) @@ -420,6 +431,9 @@ def clean_cmake_artifacts(dry_run=False): dirname = os.path.dirname(cmake_cache_file) print_and_buffer("rm -R %s" % os.path.relpath(dirname, ns3_path)) if not dry_run: + if dirname == ns3_path: + raise Exception("The CMake cache directory and the ns-3 directory are the same. " + "Deleting it can cause data loss.") shutil.rmtree(dirname, ignore_errors=True) if os.path.exists(lock_file): @@ -539,18 +553,21 @@ def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_gener # Build type if args.build_profile is not None: args.build_profile = args.build_profile.lower() - if args.build_profile not in ["debug", "default", "release", "optimized"]: + if args.build_profile not in ["debug", "default", "release", "optimized", "minsizerel", "relwithdebinfo"]: raise Exception("Unknown build type") else: if args.build_profile == "debug": cmake_args.extend( "-DCMAKE_BUILD_TYPE=debug -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=ON".split()) - elif args.build_profile == "default": + elif args.build_profile in ["default", "relwithdebinfo"]: cmake_args.extend( "-DCMAKE_BUILD_TYPE=default -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=OFF".split()) + elif args.build_profile in ["release", "optimized"]: + cmake_args.extend( + "-DCMAKE_BUILD_TYPE=release -DNS3_ASSERT=OFF -DNS3_LOG=OFF -DNS3_WARNINGS_AS_ERRORS=OFF".split()) else: cmake_args.extend( - "-DCMAKE_BUILD_TYPE=release -DNS3_ASSERT=OFF -DNS3_LOG=OFF -DNS3_WARNINGS_AS_ERRORS=OFF".split() + "-DCMAKE_BUILD_TYPE=minsizerel -DNS3_ASSERT=OFF -DNS3_LOG=OFF -DNS3_WARNINGS_AS_ERRORS=OFF".split() ) cmake_args.append("-DNS3_NATIVE_OPTIMIZATIONS=%s" % on_off((args.build_profile == "optimized"))) @@ -652,7 +669,7 @@ def update_scratches_list(current_cmake_cache_folder): def refresh_cmake(current_cmake_cache_folder, output): - ret = subprocess.run([shutil.which("cmake"), ".."], cwd=current_cmake_cache_folder, stdout=output) + ret = subprocess.run([check_program_installed("cmake"), ".."], cwd=current_cmake_cache_folder, stdout=output) if ret.returncode != 0: exit(ret.returncode) update_scratches_list(current_cmake_cache_folder) @@ -708,17 +725,16 @@ def get_program_shortcuts(build_profile, ns3_version): # Add an additional 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] - ns3_program_map[shortcut_path.replace("\\","/")+".exe"] = [program] - + ns3_program_map[shortcut_path.replace("\\", "/")] = [program] + ns3_program_map[shortcut_path + ".exe"] = [program] + ns3_program_map[shortcut_path.replace("\\", "/") + ".exe"] = [program] if source_shortcut: cc_shortcut_path = shortcut_path + ".cc" ns3_program_map[cc_shortcut_path] = [program] if sys.platform == "win32": ns3_program_map[cc_shortcut_path] = [program] - ns3_program_map[cc_shortcut_path.replace("\\","/")] = [program] + ns3_program_map[cc_shortcut_path.replace("\\", "/")] = [program] # Store longest shortcut path for collisions if cc_shortcut_path not in longest_shortcut_map: @@ -953,6 +969,7 @@ def build_step(args, non_executable_targets = ["assemble-introspected-command-line", "check-version", "cmake-format", + "coverage_gcc", "docs", "doxygen", "doxygen-no-build", @@ -1003,6 +1020,23 @@ def build_step(args, ) +def check_program_installed(program_name: str) -> str: + program_path = shutil.which(program_name) + if program_path is None: + print("Executable '{program}' was not found".format(program=program_name.capitalize())) + exit(-1) + return program_path + + +def check_module_installed(module_name: str): + import importlib + try: + importlib.import_module(module_name) + except ImportError: + print("Python module '{module}' was not found".format(module=module_name)) + exit(-1) + + def run_step(args, target_to_run, target_args): libdir = "%s/lib" % out_dir @@ -1033,24 +1067,42 @@ def run_step(args, target_to_run, target_args): target_args = [target_to_run] + target_args target_to_run = "python3" + # running with memray? + if args.memray: + check_module_installed("memray") + target_args = ["-m", "memray", "run", "-o", "memray.output", "--native"] + target_args + # running from ns-3-dev (ns3_path) or cwd if args.cwd: working_dir = args.cwd + # running with heaptrack? + if args.heaptrack: + debugging_software.append(check_program_installed("heaptrack")) + # running valgrind? if args.valgrind: - debugging_software.extend([shutil.which("valgrind"), "--leak-check=full", "--show-leak-kinds=all"]) + debugging_software.extend( + [check_program_installed("valgrind"), "--leak-check=full", "--show-leak-kinds=all"]) # running gdb? if args.gdb: gdb_eval_command = [] if os.getenv("gdb_eval"): gdb_eval_command.append("--eval-command=quit") - debugging_software.extend([shutil.which("gdb"), *gdb_eval_command, "--args"]) + debugging_software.extend([check_program_installed("gdb"), *gdb_eval_command, "--args"]) # running lldb? if args.lldb: - debugging_software.extend([shutil.which("lldb"), "--"]) + debugging_software.extend([check_program_installed("lldb"), "--"]) + + # running with perf? + if args.perf: + debugging_software.extend([ + check_program_installed("perf"), + "record", "--call-graph", "dwarf", "-a", "-e", + "cache-misses,branch-misses,cpu-cycles,stalled-cycles-frontend,stalled-cycles-backend,context-switches" + ]) # running with the visualizer? if args.visualize: @@ -1059,6 +1111,7 @@ def run_step(args, target_to_run, target_args): # running with command template? if args.command_template: commands = (args.command_template % target_to_run).split() + check_program_installed(commands[0]) target_to_run = commands[0] target_args = commands[1:] + target_args @@ -1086,10 +1139,10 @@ def run_step(args, target_to_run, target_args): try: subprocess.run(program_arguments, env=proc_env, cwd=working_dir, shell=use_shell, check=True) except subprocess.CalledProcessError as e: - # Replace full path to binary to relative path - e.cmd[0] = os.path.relpath(target_to_run, ns3_path) # Replace list of arguments with a single string e.cmd = " ".join(e.cmd) + # Replace full path to binary to relative path + e.cmd = e.cmd.replace(os.path.abspath(target_to_run), os.path.relpath(target_to_run, ns3_path)) # Print error message and forward the return code print(e) exit(e.returncode) @@ -1117,7 +1170,7 @@ def non_ambiguous_program_target_list(programs: dict) -> list: def print_targets_list(ns3_modules: list, ns3_programs: dict) -> None: - def list_to_table(l: list) -> str: + def list_to_table(targets_list: list) -> str: # Set column width and check how much is space is left at the end columnwidth = 30 try: @@ -1127,10 +1180,10 @@ def print_targets_list(ns3_modules: list, ns3_programs: dict) -> None: dead_space = terminal_width % columnwidth # Filter the targets with names longer than the column width - large_items = list(filter(lambda x: len(x) >= columnwidth, l)) + large_items = list(filter(lambda x: len(x) >= columnwidth, targets_list)) # Then filter the targets with names shorter than the column width - small_items = sorted(list(set(l) - set(large_items))) + small_items = sorted(list(set(targets_list) - set(large_items))) prev_new_line = 0 output = "\n" diff --git a/scratch/.gitignore b/scratch/.gitignore index fc504faed..7d959a29d 100644 --- a/scratch/.gitignore +++ b/scratch/.gitignore @@ -1,5 +1,7 @@ # Ignore everything on scratch by default, except the provided examples /* +!.gitignore + !subdir/ !scratch-simulator.cc !CMakeLists.txt diff --git a/scratch/scratch-simulator.cc b/scratch/scratch-simulator.cc index 8a4b44bfd..838d378ca 100644 --- a/scratch/scratch-simulator.cc +++ b/scratch/scratch-simulator.cc @@ -1,4 +1,3 @@ -/* -*- 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/scratch/subdir/scratch-subdir-additional-header.cc b/scratch/subdir/scratch-subdir-additional-header.cc index e77868fcc..69efcd490 100644 --- a/scratch/subdir/scratch-subdir-additional-header.cc +++ b/scratch/subdir/scratch-subdir-additional-header.cc @@ -1,4 +1,3 @@ -/* -*- 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/scratch/subdir/scratch-subdir-additional-header.h b/scratch/subdir/scratch-subdir-additional-header.h index fe3873e8c..c6a7c8948 100644 --- a/scratch/subdir/scratch-subdir-additional-header.h +++ b/scratch/subdir/scratch-subdir-additional-header.h @@ -1,4 +1,3 @@ -/* -*- 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/scratch/subdir/scratch-subdir.cc b/scratch/subdir/scratch-subdir.cc index d4fb601d7..23373d010 100644 --- a/scratch/subdir/scratch-subdir.cc +++ b/scratch/subdir/scratch-subdir.cc @@ -1,4 +1,3 @@ -/* -*- 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/src/antenna/model/angles.cc b/src/antenna/model/angles.cc index 3c9405cb7..7b4bf5122 100644 --- a/src/antenna/model/angles.cc +++ b/src/antenna/model/angles.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011, 2012 CTTC * diff --git a/src/antenna/model/angles.h b/src/antenna/model/angles.h index b1a3d66e4..94dcfe283 100644 --- a/src/antenna/model/angles.h +++ b/src/antenna/model/angles.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011, 2012 CTTC * diff --git a/src/antenna/model/antenna-model.cc b/src/antenna/model/antenna-model.cc index bc02dd708..a34da756b 100644 --- a/src/antenna/model/antenna-model.cc +++ b/src/antenna/model/antenna-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 CTTC * diff --git a/src/antenna/model/antenna-model.h b/src/antenna/model/antenna-model.h index c462fa4c6..788bbf39d 100644 --- a/src/antenna/model/antenna-model.h +++ b/src/antenna/model/antenna-model.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 CTTC * diff --git a/src/antenna/model/cosine-antenna-model.cc b/src/antenna/model/cosine-antenna-model.cc index 5178cce2b..4a4515dd2 100644 --- a/src/antenna/model/cosine-antenna-model.cc +++ b/src/antenna/model/cosine-antenna-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 CTTC * diff --git a/src/antenna/model/cosine-antenna-model.h b/src/antenna/model/cosine-antenna-model.h index 4104a6e06..825b2fce6 100644 --- a/src/antenna/model/cosine-antenna-model.h +++ b/src/antenna/model/cosine-antenna-model.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 CTTC * diff --git a/src/antenna/model/isotropic-antenna-model.cc b/src/antenna/model/isotropic-antenna-model.cc index d6211228e..20914194e 100644 --- a/src/antenna/model/isotropic-antenna-model.cc +++ b/src/antenna/model/isotropic-antenna-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 CTTC * diff --git a/src/antenna/model/isotropic-antenna-model.h b/src/antenna/model/isotropic-antenna-model.h index e4054e31f..f8e976eb8 100644 --- a/src/antenna/model/isotropic-antenna-model.h +++ b/src/antenna/model/isotropic-antenna-model.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 CTTC * diff --git a/src/antenna/model/parabolic-antenna-model.cc b/src/antenna/model/parabolic-antenna-model.cc index e572d0693..54316b9b5 100644 --- a/src/antenna/model/parabolic-antenna-model.cc +++ b/src/antenna/model/parabolic-antenna-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2012 CTTC * diff --git a/src/antenna/model/parabolic-antenna-model.h b/src/antenna/model/parabolic-antenna-model.h index ff0dc2dcb..720b51673 100644 --- a/src/antenna/model/parabolic-antenna-model.h +++ b/src/antenna/model/parabolic-antenna-model.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2012 CTTC * diff --git a/src/antenna/model/phased-array-model.cc b/src/antenna/model/phased-array-model.cc index 0b716da36..1bf4aeadd 100644 --- a/src/antenna/model/phased-array-model.cc +++ b/src/antenna/model/phased-array-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 University of Padova, Dep. of Information Engineering, SIGNET lab. * diff --git a/src/antenna/model/phased-array-model.h b/src/antenna/model/phased-array-model.h index b42cc2ebe..544608902 100644 --- a/src/antenna/model/phased-array-model.h +++ b/src/antenna/model/phased-array-model.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 University of Padova, Dep. of Information Engineering, SIGNET lab. * diff --git a/src/antenna/model/three-gpp-antenna-model.cc b/src/antenna/model/three-gpp-antenna-model.cc index c5e33c3a0..a218b7fe8 100644 --- a/src/antenna/model/three-gpp-antenna-model.cc +++ b/src/antenna/model/three-gpp-antenna-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 University of Padova, Dep. of Information Engineering, SIGNET lab. * diff --git a/src/antenna/model/three-gpp-antenna-model.h b/src/antenna/model/three-gpp-antenna-model.h index e2dc023b4..aa2b89e44 100644 --- a/src/antenna/model/three-gpp-antenna-model.h +++ b/src/antenna/model/three-gpp-antenna-model.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 University of Padova, Dep. of Information Engineering, SIGNET lab. * diff --git a/src/antenna/model/uniform-planar-array.cc b/src/antenna/model/uniform-planar-array.cc index 60c1e2858..abd187838 100644 --- a/src/antenna/model/uniform-planar-array.cc +++ b/src/antenna/model/uniform-planar-array.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 University of Padova, Dep. of Information Engineering, SIGNET lab. * diff --git a/src/antenna/model/uniform-planar-array.h b/src/antenna/model/uniform-planar-array.h index 03c304163..02e79551f 100644 --- a/src/antenna/model/uniform-planar-array.h +++ b/src/antenna/model/uniform-planar-array.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 University of Padova, Dep. of Information Engineering, SIGNET lab. * diff --git a/src/antenna/test/test-angles.cc b/src/antenna/test/test-angles.cc index a85533a3c..5ce7639f0 100644 --- a/src/antenna/test/test-angles.cc +++ b/src/antenna/test/test-angles.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 CTTC * diff --git a/src/antenna/test/test-cosine-antenna.cc b/src/antenna/test/test-cosine-antenna.cc index 4fc7208ae..7a14d330c 100644 --- a/src/antenna/test/test-cosine-antenna.cc +++ b/src/antenna/test/test-cosine-antenna.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 CTTC * diff --git a/src/antenna/test/test-degrees-radians.cc b/src/antenna/test/test-degrees-radians.cc index db1ea526b..f693698cf 100644 --- a/src/antenna/test/test-degrees-radians.cc +++ b/src/antenna/test/test-degrees-radians.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 CTTC * diff --git a/src/antenna/test/test-isotropic-antenna.cc b/src/antenna/test/test-isotropic-antenna.cc index d4aa90489..28c04e5be 100644 --- a/src/antenna/test/test-isotropic-antenna.cc +++ b/src/antenna/test/test-isotropic-antenna.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 CTTC * diff --git a/src/antenna/test/test-parabolic-antenna.cc b/src/antenna/test/test-parabolic-antenna.cc index 447b79901..431345c86 100644 --- a/src/antenna/test/test-parabolic-antenna.cc +++ b/src/antenna/test/test-parabolic-antenna.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011,12 CTTC * diff --git a/src/antenna/test/test-uniform-planar-array.cc b/src/antenna/test/test-uniform-planar-array.cc index 7b91192b7..83b24cf0e 100644 --- a/src/antenna/test/test-uniform-planar-array.cc +++ b/src/antenna/test/test-uniform-planar-array.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 University of Padova, Dep. of Information Engineering, SIGNET lab. * diff --git a/src/aodv/doc/aodv.h b/src/aodv/doc/aodv.h index ba3c91d6e..b73eb5764 100644 --- a/src/aodv/doc/aodv.h +++ b/src/aodv/doc/aodv.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/examples/aodv.cc b/src/aodv/examples/aodv.cc index 7db2790ba..361cba2e1 100644 --- a/src/aodv/examples/aodv.cc +++ b/src/aodv/examples/aodv.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/helper/aodv-helper.cc b/src/aodv/helper/aodv-helper.cc index 09446a9c1..f00401333 100644 --- a/src/aodv/helper/aodv-helper.cc +++ b/src/aodv/helper/aodv-helper.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/helper/aodv-helper.h b/src/aodv/helper/aodv-helper.h index ea71a8b51..a8675f950 100644 --- a/src/aodv/helper/aodv-helper.h +++ b/src/aodv/helper/aodv-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/model/aodv-dpd.cc b/src/aodv/model/aodv-dpd.cc index 9f47c2345..5ad4e298a 100644 --- a/src/aodv/model/aodv-dpd.cc +++ b/src/aodv/model/aodv-dpd.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/model/aodv-dpd.h b/src/aodv/model/aodv-dpd.h index b89c0da57..0821455f8 100644 --- a/src/aodv/model/aodv-dpd.h +++ b/src/aodv/model/aodv-dpd.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/model/aodv-id-cache.cc b/src/aodv/model/aodv-id-cache.cc index 5f9d3384b..a1e632cc3 100644 --- a/src/aodv/model/aodv-id-cache.cc +++ b/src/aodv/model/aodv-id-cache.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/model/aodv-id-cache.h b/src/aodv/model/aodv-id-cache.h index a3ea72ec0..8fd3ecb4b 100644 --- a/src/aodv/model/aodv-id-cache.h +++ b/src/aodv/model/aodv-id-cache.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/model/aodv-neighbor.cc b/src/aodv/model/aodv-neighbor.cc index 6f82c77f4..caa94d63b 100644 --- a/src/aodv/model/aodv-neighbor.cc +++ b/src/aodv/model/aodv-neighbor.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/model/aodv-neighbor.h b/src/aodv/model/aodv-neighbor.h index 1b2268cc4..d009dec72 100644 --- a/src/aodv/model/aodv-neighbor.h +++ b/src/aodv/model/aodv-neighbor.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/model/aodv-packet.cc b/src/aodv/model/aodv-packet.cc index ac0b36249..a6741e21c 100644 --- a/src/aodv/model/aodv-packet.cc +++ b/src/aodv/model/aodv-packet.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/model/aodv-packet.h b/src/aodv/model/aodv-packet.h index 38f648122..7c9ff69f1 100644 --- a/src/aodv/model/aodv-packet.h +++ b/src/aodv/model/aodv-packet.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * @@ -626,8 +625,9 @@ class RerrHeader : public Header bool AddUnDestination(Ipv4Address dst, uint32_t seqNo); /** * \brief Delete pair (address + sequence number) from REER header, if the number of unreachable - * destinations > 0 \param un unreachable pair (address + sequence number) \return true on - * success + * destinations > 0 + * \param un unreachable pair (address + sequence number) + * \return true on success */ bool RemoveUnDestination(std::pair& un); /// Clear header diff --git a/src/aodv/model/aodv-routing-protocol.cc b/src/aodv/model/aodv-routing-protocol.cc index 1537750d8..ba7e8355a 100644 --- a/src/aodv/model/aodv-routing-protocol.cc +++ b/src/aodv/model/aodv-routing-protocol.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/model/aodv-routing-protocol.h b/src/aodv/model/aodv-routing-protocol.h index 14af0e8ff..0dc2efc1d 100644 --- a/src/aodv/model/aodv-routing-protocol.h +++ b/src/aodv/model/aodv-routing-protocol.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * @@ -231,7 +230,7 @@ class RoutingProtocol : public Ipv4RoutingProtocol uint32_t m_netDiameter; ///< Net diameter measures the maximum possible number of hops between ///< two nodes in the network /** - * NodeTraversalTime is a conservative estimate of the average one hop traversal time for + * NodeTraversalTime is a conservative estimate of the average one hop traversal time for * packets and should include queuing delays, interrupt processing times and transfer times. */ Time m_nodeTraversalTime; @@ -329,9 +328,11 @@ class RoutingProtocol : public Ipv4RoutingProtocol void ScheduleRreqRetry(Ipv4Address dst); /** * Set lifetime field in routing table entry to the maximum of existing lifetime and lt, if the - * entry exists \param addr - destination address \param lt - proposed time for lifetime field - * in routing table entry for destination with address addr. \return true if route to - * destination address addr exist + * entry exists + * \param addr destination address + * \param lt proposed time for lifetime field in routing table entry for destination with + * address addr. + * \return true if route to destination address addr exist */ bool UpdateRouteLifeTime(Ipv4Address addr, Time lt); /** @@ -452,17 +453,19 @@ class RoutingProtocol : public Ipv4RoutingProtocol void SendRerrMessage(Ptr packet, std::vector precursors); /** * Send RERR message when no route to forward input packet. Unicast if there is reverse route to - * originating node, broadcast otherwise. \param dst - destination node IP address \param - * dstSeqNo - destination node sequence number \param origin - originating node IP address + * originating node, broadcast otherwise. + * \param dst destination node IP address + * \param dstSeqNo destination node sequence number + * \param origin originating node IP address */ void SendRerrWhenNoRouteToForward(Ipv4Address dst, uint32_t dstSeqNo, Ipv4Address origin); /// @} /** - * Send packet to destination scoket - * \param socket - destination node socket - * \param packet - packet to send - * \param destination - destination node IP address + * Send packet to destination socket + * \param socket destination node socket + * \param packet packet to send + * \param destination destination node IP address */ void SendTo(Ptr socket, Ptr packet, Ipv4Address destination); @@ -488,7 +491,7 @@ class RoutingProtocol : public Ipv4RoutingProtocol /** * Mark link to neighbor node as unidirectional for blacklistTimeout * - * \param neighbor the IP address of the neightbor node + * \param neighbor the IP address of the neighbor node * \param blacklistTimeout the black list timeout time */ void AckTimerExpire(Ipv4Address neighbor, Time blacklistTimeout); diff --git a/src/aodv/model/aodv-rqueue.cc b/src/aodv/model/aodv-rqueue.cc index 94fa90af2..4b571c5de 100644 --- a/src/aodv/model/aodv-rqueue.cc +++ b/src/aodv/model/aodv-rqueue.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/model/aodv-rqueue.h b/src/aodv/model/aodv-rqueue.h index bd2211cf3..41fb66793 100644 --- a/src/aodv/model/aodv-rqueue.h +++ b/src/aodv/model/aodv-rqueue.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * @@ -211,7 +210,9 @@ class RequestQueue /** * Push entry in queue, if there is no entry with the same packet and destination address in - * queue. \param entry the queue entry \returns true if the entry is queued + * queue. + * \param entry the queue entry + * \returns true if the entry is queued */ bool Enqueue(QueueEntry& entry); /** diff --git a/src/aodv/model/aodv-rtable.cc b/src/aodv/model/aodv-rtable.cc index b3ae82059..6962c7453 100644 --- a/src/aodv/model/aodv-rtable.cc +++ b/src/aodv/model/aodv-rtable.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/model/aodv-rtable.h b/src/aodv/model/aodv-rtable.h index 42282e753..ac65e21c8 100644 --- a/src/aodv/model/aodv-rtable.h +++ b/src/aodv/model/aodv-rtable.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * @@ -501,12 +500,12 @@ class RoutingTable void GetListOfDestinationWithNextHop(Ipv4Address nextHop, std::map& unreachable); /** - * Update routing entries with this destination as follows: - * 1. The destination sequence number of this routing entry, if it - * exists and is valid, is incremented. - * 2. The entry is invalidated by marking the route entry as invalid - * 3. The Lifetime field is updated to current time plus DELETE_PERIOD. - * \param unreachable routes to invalidate + * Update routing entries with this destination as follows: + * 1. The destination sequence number of this routing entry, if it + * exists and is valid, is incremented. + * 2. The entry is invalidated by marking the route entry as invalid + * 3. The Lifetime field is updated to current time plus DELETE_PERIOD. + * \param unreachable routes to invalidate */ void InvalidateRoutesWithDst(const std::map& unreachable); /** @@ -524,9 +523,10 @@ class RoutingTable /// Delete all outdated entries and invalidate valid entry if Lifetime is expired void Purge(); /** Mark entry as unidirectional (e.g. add this neighbor to "blacklist" for blacklistTimeout - * period) \param neighbor - neighbor address link to which assumed to be unidirectional \param - * blacklistTimeout - time for which the neighboring node is put into the blacklist \return true - * on success + * period) + * \param neighbor neighbor address link to which assumed to be unidirectional + * \param blacklistTimeout time for which the neighboring node is put into the blacklist + * \return true on success */ bool MarkLinkAsUnidirectional(Ipv4Address neighbor, Time blacklistTimeout); /** diff --git a/src/aodv/test/aodv-id-cache-test-suite.cc b/src/aodv/test/aodv-id-cache-test-suite.cc index 66a911550..41a7e50af 100644 --- a/src/aodv/test/aodv-id-cache-test-suite.cc +++ b/src/aodv/test/aodv-id-cache-test-suite.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/test/aodv-regression.cc b/src/aodv/test/aodv-regression.cc index 76a59bf91..053cb1e38 100644 --- a/src/aodv/test/aodv-regression.cc +++ b/src/aodv/test/aodv-regression.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/test/aodv-regression.h b/src/aodv/test/aodv-regression.h index 5aac3895d..f94582fc1 100644 --- a/src/aodv/test/aodv-regression.h +++ b/src/aodv/test/aodv-regression.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/test/aodv-test-suite.cc b/src/aodv/test/aodv-test-suite.cc index b0b191022..8ecbf03cb 100644 --- a/src/aodv/test/aodv-test-suite.cc +++ b/src/aodv/test/aodv-test-suite.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/test/bug-772.cc b/src/aodv/test/bug-772.cc index 1945c17d5..0719448b8 100644 --- a/src/aodv/test/bug-772.cc +++ b/src/aodv/test/bug-772.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 IITP RAS * diff --git a/src/aodv/test/bug-772.h b/src/aodv/test/bug-772.h index 0780490de..cfba00f14 100644 --- a/src/aodv/test/bug-772.h +++ b/src/aodv/test/bug-772.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 IITP RAS * diff --git a/src/aodv/test/loopback.cc b/src/aodv/test/loopback.cc index fdb24162a..6250d52fa 100644 --- a/src/aodv/test/loopback.cc +++ b/src/aodv/test/loopback.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 IITP RAS * diff --git a/src/applications/doc/applications.h b/src/applications/doc/applications.h index a1bba8e47..47129ad11 100644 --- a/src/applications/doc/applications.h +++ b/src/applications/doc/applications.h @@ -1,4 +1,3 @@ -/* -*- 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/src/applications/examples/three-gpp-http-example.cc b/src/applications/examples/three-gpp-http-example.cc index 989f32a8c..2fe725cb4 100644 --- a/src/applications/examples/three-gpp-http-example.cc +++ b/src/applications/examples/three-gpp-http-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2016 Magister Solutions * diff --git a/src/applications/helper/bulk-send-helper.cc b/src/applications/helper/bulk-send-helper.cc index 6826f02cb..1d7c4b2f7 100644 --- a/src/applications/helper/bulk-send-helper.cc +++ b/src/applications/helper/bulk-send-helper.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/applications/helper/bulk-send-helper.h b/src/applications/helper/bulk-send-helper.h index 20cfd7455..af714b0e0 100644 --- a/src/applications/helper/bulk-send-helper.h +++ b/src/applications/helper/bulk-send-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/applications/helper/on-off-helper.cc b/src/applications/helper/on-off-helper.cc index d1a2cb18d..311fee0f4 100644 --- a/src/applications/helper/on-off-helper.cc +++ b/src/applications/helper/on-off-helper.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/applications/helper/on-off-helper.h b/src/applications/helper/on-off-helper.h index c0b32f816..d0bf8e77f 100644 --- a/src/applications/helper/on-off-helper.h +++ b/src/applications/helper/on-off-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/applications/helper/packet-sink-helper.cc b/src/applications/helper/packet-sink-helper.cc index baad1dd0c..a1e2139f8 100644 --- a/src/applications/helper/packet-sink-helper.cc +++ b/src/applications/helper/packet-sink-helper.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/applications/helper/packet-sink-helper.h b/src/applications/helper/packet-sink-helper.h index 2cd28d89b..c1c17225c 100644 --- a/src/applications/helper/packet-sink-helper.h +++ b/src/applications/helper/packet-sink-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/applications/helper/three-gpp-http-helper.cc b/src/applications/helper/three-gpp-http-helper.cc index fa3936760..85fc270c3 100644 --- a/src/applications/helper/three-gpp-http-helper.cc +++ b/src/applications/helper/three-gpp-http-helper.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * Copyright (c) 2013 Magister Solutions diff --git a/src/applications/helper/three-gpp-http-helper.h b/src/applications/helper/three-gpp-http-helper.h index a562800cf..f4f131812 100644 --- a/src/applications/helper/three-gpp-http-helper.h +++ b/src/applications/helper/three-gpp-http-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * Copyright (c) 2013 Magister Solutions diff --git a/src/applications/helper/udp-client-server-helper.cc b/src/applications/helper/udp-client-server-helper.cc index 6b599ba2d..9307bf0ea 100644 --- a/src/applications/helper/udp-client-server-helper.cc +++ b/src/applications/helper/udp-client-server-helper.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/applications/helper/udp-client-server-helper.h b/src/applications/helper/udp-client-server-helper.h index 714821de0..41bf51cf1 100644 --- a/src/applications/helper/udp-client-server-helper.h +++ b/src/applications/helper/udp-client-server-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/applications/helper/udp-echo-helper.cc b/src/applications/helper/udp-echo-helper.cc index 01a11f710..e8b24a8db 100644 --- a/src/applications/helper/udp-echo-helper.cc +++ b/src/applications/helper/udp-echo-helper.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/applications/helper/udp-echo-helper.h b/src/applications/helper/udp-echo-helper.h index 7b088c873..6b904baf0 100644 --- a/src/applications/helper/udp-echo-helper.h +++ b/src/applications/helper/udp-echo-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/applications/model/application-packet-probe.cc b/src/applications/model/application-packet-probe.cc index bf5d14f95..00ffa7b42 100644 --- a/src/applications/model/application-packet-probe.cc +++ b/src/applications/model/application-packet-probe.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Bucknell University * diff --git a/src/applications/model/application-packet-probe.h b/src/applications/model/application-packet-probe.h index 5d7bc6913..aa41e5f4b 100644 --- a/src/applications/model/application-packet-probe.h +++ b/src/applications/model/application-packet-probe.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Bucknell University * diff --git a/src/applications/model/bulk-send-application.cc b/src/applications/model/bulk-send-application.cc index 69959fed7..9b2100a0b 100644 --- a/src/applications/model/bulk-send-application.cc +++ b/src/applications/model/bulk-send-application.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 Georgia Institute of Technology * diff --git a/src/applications/model/bulk-send-application.h b/src/applications/model/bulk-send-application.h index fd899f22f..bb809fe1b 100644 --- a/src/applications/model/bulk-send-application.h +++ b/src/applications/model/bulk-send-application.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 Georgia Institute of Technology * diff --git a/src/applications/model/onoff-application.cc b/src/applications/model/onoff-application.cc index 9b74220f4..c250e9c7c 100644 --- a/src/applications/model/onoff-application.cc +++ b/src/applications/model/onoff-application.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ // // Copyright (c) 2006 Georgia Tech Research Corporation // diff --git a/src/applications/model/onoff-application.h b/src/applications/model/onoff-application.h index 8a195c6ed..e1cb143a7 100644 --- a/src/applications/model/onoff-application.h +++ b/src/applications/model/onoff-application.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ // // Copyright (c) 2006 Georgia Tech Research Corporation // diff --git a/src/applications/model/packet-loss-counter.cc b/src/applications/model/packet-loss-counter.cc index 0d0168ac7..362986585 100644 --- a/src/applications/model/packet-loss-counter.cc +++ b/src/applications/model/packet-loss-counter.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA, UDCAST * diff --git a/src/applications/model/packet-loss-counter.h b/src/applications/model/packet-loss-counter.h index 0f4033bd0..3d8d65f62 100644 --- a/src/applications/model/packet-loss-counter.h +++ b/src/applications/model/packet-loss-counter.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007,2008,2009 INRIA, UDCAST * diff --git a/src/applications/model/packet-sink.cc b/src/applications/model/packet-sink.cc index b22054bb2..681c884c9 100644 --- a/src/applications/model/packet-sink.cc +++ b/src/applications/model/packet-sink.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright 2007 University of Washington * diff --git a/src/applications/model/packet-sink.h b/src/applications/model/packet-sink.h index 6910ac5e1..170dee422 100644 --- a/src/applications/model/packet-sink.h +++ b/src/applications/model/packet-sink.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright 2007 University of Washington * diff --git a/src/applications/model/seq-ts-echo-header.cc b/src/applications/model/seq-ts-echo-header.cc index 59a15cb58..6a9161032 100644 --- a/src/applications/model/seq-ts-echo-header.cc +++ b/src/applications/model/seq-ts-echo-header.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * Copyright (c) 2016 Universita' di Firenze (added echo fields) diff --git a/src/applications/model/seq-ts-echo-header.h b/src/applications/model/seq-ts-echo-header.h index ff47cd504..822520a24 100644 --- a/src/applications/model/seq-ts-echo-header.h +++ b/src/applications/model/seq-ts-echo-header.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * Copyright (c) 2016 Universita' di Firenze (added echo fields) diff --git a/src/applications/model/seq-ts-header.cc b/src/applications/model/seq-ts-header.cc index f5f1408f7..1de6d2ada 100644 --- a/src/applications/model/seq-ts-header.cc +++ b/src/applications/model/seq-ts-header.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/src/applications/model/seq-ts-header.h b/src/applications/model/seq-ts-header.h index 2c47a9443..cb1a8a90e 100644 --- a/src/applications/model/seq-ts-header.h +++ b/src/applications/model/seq-ts-header.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/src/applications/model/seq-ts-size-header.cc b/src/applications/model/seq-ts-size-header.cc index 2b0f08ecd..3c315d8eb 100644 --- a/src/applications/model/seq-ts-size-header.cc +++ b/src/applications/model/seq-ts-size-header.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * Copyright (c) 2018 Natale Patriciello diff --git a/src/applications/model/seq-ts-size-header.h b/src/applications/model/seq-ts-size-header.h index 14ba6c5d1..1bc0e4528 100644 --- a/src/applications/model/seq-ts-size-header.h +++ b/src/applications/model/seq-ts-size-header.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * Copyright (c) 2018 Natale Patriciello diff --git a/src/applications/model/three-gpp-http-client.cc b/src/applications/model/three-gpp-http-client.cc index 3f56bd5f8..8cfec42f2 100644 --- a/src/applications/model/three-gpp-http-client.cc +++ b/src/applications/model/three-gpp-http-client.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2013 Magister Solutions * @@ -364,10 +363,10 @@ ThreeGppHttpClient::OpenConnection() { m_socket = Socket::CreateSocket(GetNode(), TcpSocketFactory::GetTypeId()); - [[maybe_unused]] int ret; - if (Ipv4Address::IsMatchingType(m_remoteServerAddress)) { + int ret [[maybe_unused]]; + ret = m_socket->Bind(); NS_LOG_DEBUG(this << " Bind() return value= " << ret << " GetErrNo= " << m_socket->GetErrno() << "."); @@ -382,6 +381,8 @@ ThreeGppHttpClient::OpenConnection() } else if (Ipv6Address::IsMatchingType(m_remoteServerAddress)) { + int ret [[maybe_unused]]; + ret = m_socket->Bind6(); NS_LOG_DEBUG(this << " Bind6() return value= " << ret << " GetErrNo= " << m_socket->GetErrno() << "."); diff --git a/src/applications/model/three-gpp-http-client.h b/src/applications/model/three-gpp-http-client.h index abdc9ef1f..a149ce878 100644 --- a/src/applications/model/three-gpp-http-client.h +++ b/src/applications/model/three-gpp-http-client.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2013 Magister Solutions * diff --git a/src/applications/model/three-gpp-http-header.cc b/src/applications/model/three-gpp-http-header.cc index f2802d480..bf366277e 100644 --- a/src/applications/model/three-gpp-http-header.cc +++ b/src/applications/model/three-gpp-http-header.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 Magister Solutions * diff --git a/src/applications/model/three-gpp-http-header.h b/src/applications/model/three-gpp-http-header.h index 93d984ca0..9f8f028b7 100644 --- a/src/applications/model/three-gpp-http-header.h +++ b/src/applications/model/three-gpp-http-header.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 Magister Solutions * diff --git a/src/applications/model/three-gpp-http-server.cc b/src/applications/model/three-gpp-http-server.cc index 7da0f0c26..e90931e9f 100644 --- a/src/applications/model/three-gpp-http-server.cc +++ b/src/applications/model/three-gpp-http-server.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2013 Magister Solutions * @@ -209,15 +208,13 @@ ThreeGppHttpServer::StartApplication() m_initialSocket = Socket::CreateSocket(GetNode(), TcpSocketFactory::GetTypeId()); m_initialSocket->SetAttribute("SegmentSize", UintegerValue(m_mtuSize)); - [[maybe_unused]] int ret; - if (Ipv4Address::IsMatchingType(m_localAddress)) { const Ipv4Address ipv4 = Ipv4Address::ConvertFrom(m_localAddress); const InetSocketAddress inetSocket = InetSocketAddress(ipv4, m_localPort); NS_LOG_INFO(this << " Binding on " << ipv4 << " port " << m_localPort << " / " << inetSocket << "."); - ret = m_initialSocket->Bind(inetSocket); + int ret [[maybe_unused]] = m_initialSocket->Bind(inetSocket); NS_LOG_DEBUG(this << " Bind() return value= " << ret << " GetErrNo= " << m_initialSocket->GetErrno() << "."); } @@ -227,12 +224,12 @@ ThreeGppHttpServer::StartApplication() const Inet6SocketAddress inet6Socket = Inet6SocketAddress(ipv6, m_localPort); NS_LOG_INFO(this << " Binding on " << ipv6 << " port " << m_localPort << " / " << inet6Socket << "."); - ret = m_initialSocket->Bind(inet6Socket); + int ret [[maybe_unused]] = m_initialSocket->Bind(inet6Socket); NS_LOG_DEBUG(this << " Bind() return value= " << ret << " GetErrNo= " << m_initialSocket->GetErrno() << "."); } - ret = m_initialSocket->Listen(); + int ret [[maybe_unused]] = m_initialSocket->Listen(); NS_LOG_DEBUG(this << " Listen () return value= " << ret << " GetErrNo= " << m_initialSocket->GetErrno() << "."); @@ -454,8 +451,8 @@ ThreeGppHttpServer::SendCallback(Ptr socket, uint32_t availableBufferSiz if (!m_txBuffer->IsBufferEmpty(socket)) { - [[maybe_unused]] const uint32_t txBufferSize = m_txBuffer->GetBufferSize(socket); - [[maybe_unused]] const uint32_t actualSent = ServeFromTxBuffer(socket); + const uint32_t txBufferSize [[maybe_unused]] = m_txBuffer->GetBufferSize(socket); + const uint32_t actualSent [[maybe_unused]] = ServeFromTxBuffer(socket); #ifdef NS3_LOG_ENABLE // Some log messages. diff --git a/src/applications/model/three-gpp-http-server.h b/src/applications/model/three-gpp-http-server.h index f834ea5b3..4b7b1c6ff 100644 --- a/src/applications/model/three-gpp-http-server.h +++ b/src/applications/model/three-gpp-http-server.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2013 Magister Solutions * diff --git a/src/applications/model/three-gpp-http-variables.cc b/src/applications/model/three-gpp-http-variables.cc index 747a61414..bad12f5c3 100644 --- a/src/applications/model/three-gpp-http-variables.cc +++ b/src/applications/model/three-gpp-http-variables.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2013 Magister Solutions * diff --git a/src/applications/model/three-gpp-http-variables.h b/src/applications/model/three-gpp-http-variables.h index 73c21ce9b..b2f2d6e2c 100644 --- a/src/applications/model/three-gpp-http-variables.h +++ b/src/applications/model/three-gpp-http-variables.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2013 Magister Solutions * diff --git a/src/applications/model/udp-client.cc b/src/applications/model/udp-client.cc index d48760461..a1e002e5a 100644 --- a/src/applications/model/udp-client.cc +++ b/src/applications/model/udp-client.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007,2008,2009 INRIA, UDCAST * diff --git a/src/applications/model/udp-client.h b/src/applications/model/udp-client.h index f636632d9..0f241ab5a 100644 --- a/src/applications/model/udp-client.h +++ b/src/applications/model/udp-client.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007,2008,2009 INRIA, UDCAST * diff --git a/src/applications/model/udp-echo-client.cc b/src/applications/model/udp-echo-client.cc index 2b45353a1..70cd095cb 100644 --- a/src/applications/model/udp-echo-client.cc +++ b/src/applications/model/udp-echo-client.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright 2007 University of Washington * diff --git a/src/applications/model/udp-echo-client.h b/src/applications/model/udp-echo-client.h index cab919be6..ed7bed03d 100644 --- a/src/applications/model/udp-echo-client.h +++ b/src/applications/model/udp-echo-client.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright 2007 University of Washington * diff --git a/src/applications/model/udp-echo-server.cc b/src/applications/model/udp-echo-server.cc index bbf9dd9c0..f00eed7b4 100644 --- a/src/applications/model/udp-echo-server.cc +++ b/src/applications/model/udp-echo-server.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright 2007 University of Washington * diff --git a/src/applications/model/udp-echo-server.h b/src/applications/model/udp-echo-server.h index 97ff53652..d71963a92 100644 --- a/src/applications/model/udp-echo-server.h +++ b/src/applications/model/udp-echo-server.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright 2007 University of Washington * diff --git a/src/applications/model/udp-server.cc b/src/applications/model/udp-server.cc index 5c4eac55b..940d94ca5 100644 --- a/src/applications/model/udp-server.cc +++ b/src/applications/model/udp-server.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007,2008,2009 INRIA, UDCAST * diff --git a/src/applications/model/udp-server.h b/src/applications/model/udp-server.h index d8e720872..a824b5d96 100644 --- a/src/applications/model/udp-server.h +++ b/src/applications/model/udp-server.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007,2008,2009 INRIA, UDCAST * diff --git a/src/applications/model/udp-trace-client.cc b/src/applications/model/udp-trace-client.cc index 804a7a02d..b45180dd2 100644 --- a/src/applications/model/udp-trace-client.cc +++ b/src/applications/model/udp-trace-client.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007,2008, 2009 INRIA, UDcast * @@ -193,7 +192,7 @@ UdpTraceClient::LoadTrace(std::string filename) char frameType; TraceEntry entry; std::ifstream ifTraceFile; - ifTraceFile.open(filename.c_str(), std::ifstream::in); + ifTraceFile.open(filename, std::ifstream::in); m_entries.clear(); if (!ifTraceFile.good()) { diff --git a/src/applications/model/udp-trace-client.h b/src/applications/model/udp-trace-client.h index f41119533..c34364b65 100644 --- a/src/applications/model/udp-trace-client.h +++ b/src/applications/model/udp-trace-client.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007,2008, 2009 INRIA, UDcast * diff --git a/src/applications/test/bulk-send-application-test-suite.cc b/src/applications/test/bulk-send-application-test-suite.cc index fa067e91e..bf344bb57 100644 --- a/src/applications/test/bulk-send-application-test-suite.cc +++ b/src/applications/test/bulk-send-application-test-suite.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 Tom Henderson (tomh@tomh.org) * diff --git a/src/applications/test/three-gpp-http-client-server-test.cc b/src/applications/test/three-gpp-http-client-server-test.cc index 489428217..7337e23e8 100644 --- a/src/applications/test/three-gpp-http-client-server-test.cc +++ b/src/applications/test/three-gpp-http-client-server-test.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 Magister Solutions * diff --git a/src/applications/test/udp-client-server-test.cc b/src/applications/test/udp-client-server-test.cc index e270fad2e..b4b7a167a 100644 --- a/src/applications/test/udp-client-server-test.cc +++ b/src/applications/test/udp-client-server-test.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007,2008, 2009 INRIA, UDcast * diff --git a/src/bridge/examples/csma-bridge-one-hop.cc b/src/bridge/examples/csma-bridge-one-hop.cc index af4ec03ba..1ea6317d7 100644 --- a/src/bridge/examples/csma-bridge-one-hop.cc +++ b/src/bridge/examples/csma-bridge-one-hop.cc @@ -1,4 +1,3 @@ -/* -*- 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/src/bridge/examples/csma-bridge.cc b/src/bridge/examples/csma-bridge.cc index 42941f6ff..b2d60e3e3 100644 --- a/src/bridge/examples/csma-bridge.cc +++ b/src/bridge/examples/csma-bridge.cc @@ -1,4 +1,3 @@ -/* -*- 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/src/bridge/helper/bridge-helper.cc b/src/bridge/helper/bridge-helper.cc index 308c6e436..3fea2f89d 100644 --- a/src/bridge/helper/bridge-helper.cc +++ b/src/bridge/helper/bridge-helper.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) * diff --git a/src/bridge/helper/bridge-helper.h b/src/bridge/helper/bridge-helper.h index 347de3469..9d8a7fc69 100644 --- a/src/bridge/helper/bridge-helper.h +++ b/src/bridge/helper/bridge-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/bridge/model/bridge-channel.cc b/src/bridge/model/bridge-channel.cc index 02005e99a..56dbdb30b 100644 --- a/src/bridge/model/bridge-channel.cc +++ b/src/bridge/model/bridge-channel.cc @@ -1,4 +1,3 @@ -/* -*- 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/src/bridge/model/bridge-channel.h b/src/bridge/model/bridge-channel.h index 5c2020d66..553912380 100644 --- a/src/bridge/model/bridge-channel.h +++ b/src/bridge/model/bridge-channel.h @@ -1,4 +1,3 @@ -/* -*- 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/src/bridge/model/bridge-net-device.cc b/src/bridge/model/bridge-net-device.cc index 87f138f2f..0613232f2 100644 --- a/src/bridge/model/bridge-net-device.cc +++ b/src/bridge/model/bridge-net-device.cc @@ -1,4 +1,3 @@ -/* -*- 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/src/bridge/model/bridge-net-device.h b/src/bridge/model/bridge-net-device.h index 14921a89b..5d29f726f 100644 --- a/src/bridge/model/bridge-net-device.h +++ b/src/bridge/model/bridge-net-device.h @@ -1,4 +1,3 @@ -/* -*- 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/src/brite/examples/brite-MPI-example.cc b/src/brite/examples/brite-MPI-example.cc index 2e52ca3bf..8530b0249 100644 --- a/src/brite/examples/brite-MPI-example.cc +++ b/src/brite/examples/brite-MPI-example.cc @@ -1,4 +1,3 @@ -/* -*- 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/src/brite/examples/brite-generic-example.cc b/src/brite/examples/brite-generic-example.cc index 745321b46..c90d72d26 100644 --- a/src/brite/examples/brite-generic-example.cc +++ b/src/brite/examples/brite-generic-example.cc @@ -1,4 +1,3 @@ -/* -*- 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/src/brite/helper/brite-topology-helper.cc b/src/brite/helper/brite-topology-helper.cc index eac82ef41..3d38ffeeb 100644 --- a/src/brite/helper/brite-topology-helper.cc +++ b/src/brite/helper/brite-topology-helper.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -42,7 +41,7 @@ BriteTopologyHelper::BriteTopologyHelper(std::string confFile, m_seedFile(seedFile), m_newSeedFile(newseedFile), m_numAs(0), - m_topology(NULL), + m_topology(nullptr), m_numNodes(0), m_numEdges(0) { @@ -54,7 +53,7 @@ BriteTopologyHelper::BriteTopologyHelper(std::string confFile, BriteTopologyHelper::BriteTopologyHelper(std::string confFile) : m_confFile(confFile), m_numAs(0), - m_topology(NULL), + m_topology(nullptr), m_numNodes(0), m_numEdges(0) { @@ -94,7 +93,7 @@ BriteTopologyHelper::AssignStreams(int64_t streamNumber) } void -BriteTopologyHelper::BuildBriteNodeInfoList(void) +BriteTopologyHelper::BuildBriteNodeInfoList() { NS_LOG_FUNCTION(this); brite::Graph* g = m_topology->GetGraph(); @@ -140,7 +139,7 @@ BriteTopologyHelper::BuildBriteNodeInfoList(void) break; default: NS_FATAL_ERROR( - "Topology::Output(): Improperly classfied Router node encountered..."); + "Topology::Output(): Improperly classified Router node encountered..."); } break; @@ -166,7 +165,7 @@ BriteTopologyHelper::BuildBriteNodeInfoList(void) nodeInfo.type = "AS_BACKBONE "; break; default: - NS_FATAL_ERROR("Topology::Output(): Improperly classfied AS node encountered..."); + NS_FATAL_ERROR("Topology::Output(): Improperly classified AS node encountered..."); } break; } @@ -181,7 +180,7 @@ BriteTopologyHelper::BuildBriteNodeInfoList(void) } void -BriteTopologyHelper::BuildBriteEdgeInfoList(void) +BriteTopologyHelper::BuildBriteEdgeInfoList() { NS_LOG_FUNCTION(this); brite::Graph* g = m_topology->GetGraph(); @@ -310,7 +309,7 @@ BriteTopologyHelper::GetNEdgesTopology() const } uint32_t -BriteTopologyHelper::GetNAs(void) const +BriteTopologyHelper::GetNAs() const { return m_numAs; } @@ -322,9 +321,9 @@ BriteTopologyHelper::GetSystemNumberForAs(uint32_t asNum) const } void -BriteTopologyHelper::GenerateBriteTopology(void) +BriteTopologyHelper::GenerateBriteTopology() { - NS_ASSERT_MSG(m_topology == NULL, "Brite Topology Already Created"); + NS_ASSERT_MSG(!m_topology, "Brite Topology Already Created"); // check to see if need to generate seed file bool generateSeedFile = m_seedFile.empty(); @@ -437,7 +436,7 @@ BriteTopologyHelper::AssignIpv4Addresses(Ipv4AddressHelper& address) { NS_LOG_FUNCTION(this); // assign IPs - for (unsigned int i = 0; i < m_netDevices.size(); ++i) + for (std::size_t i = 0; i < m_netDevices.size(); ++i) { address.Assign(*m_netDevices[i]); address.NewNetwork(); @@ -449,7 +448,7 @@ BriteTopologyHelper::AssignIpv6Addresses(Ipv6AddressHelper& address) { NS_LOG_FUNCTION(this); - for (unsigned int i = 0; i < m_netDevices.size(); ++i) + for (std::size_t i = 0; i < m_netDevices.size(); ++i) { address.Assign(*m_netDevices[i]); address.NewNetwork(); diff --git a/src/brite/helper/brite-topology-helper.h b/src/brite/helper/brite-topology-helper.h index bf4367096..d864c0170 100644 --- a/src/brite/helper/brite-topology-helper.h +++ b/src/brite/helper/brite-topology-helper.h @@ -1,4 +1,3 @@ -/* -*- 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 @@ -36,6 +35,7 @@ namespace ns3 { class PointToPointHelper; +class Ipv4AddressHelper; /** * \defgroup brite BRITE Topology Generator @@ -89,14 +89,13 @@ class BriteTopologyHelper * generate brite seed file * * \param streamNumber the stream number to assign - * */ void AssignStreams(int64_t streamNumber); /** - * Create NS3 topology using information generated from BRITE. + * Create NS3 topology using information generated from BRITE. * - * \param stack Internet stack to assign to nodes in topology + * \param stack Internet stack to assign to nodes in topology */ void BuildBriteTopology(InternetStackHelper& stack); @@ -106,7 +105,6 @@ class BriteTopologyHelper * * \param stack Internet stack to assign to nodes in topology. * \param systemCount The number of MPI instances to be used in the simulation. - * */ void BuildBriteTopology(InternetStackHelper& stack, const uint32_t systemCount); @@ -115,7 +113,6 @@ class BriteTopologyHelper * * \param asNum the AS number * \returns the number of leaf nodes in the specified AS - * */ uint32_t GetNLeafNodesForAs(uint32_t asNum); @@ -142,7 +139,6 @@ class BriteTopologyHelper * \param asNum the AS number * \param nodeNum the Node number * \return the specified node - * */ Ptr GetNodeForAs(uint32_t asNum, uint32_t nodeNum); @@ -151,7 +147,7 @@ class BriteTopologyHelper * * \returns the number of AS created in the topology */ - uint32_t GetNAs(void) const; + uint32_t GetNAs() const; /** * Returns the system number for the MPI instance that this AS is assigned to. Will always @@ -164,6 +160,8 @@ class BriteTopologyHelper uint32_t GetSystemNumberForAs(uint32_t asNum) const; /** + * Assign IPv4 addresses. + * * \param address an Ipv4AddressHelper which is used to install * IPv4 addresses on all the node interfaces in * the topology @@ -171,6 +169,8 @@ class BriteTopologyHelper void AssignIpv4Addresses(Ipv4AddressHelper& address); /** + * Assign IPv6 addresses. + * * \param address an Ipv6AddressHelper which is used to install * IPv6 addresses on all the node interfaces in * the topology @@ -242,13 +242,13 @@ class BriteTopologyHelper NodeContainer m_nodes; /// Build the Node Info list - void BuildBriteNodeInfoList(void); + void BuildBriteNodeInfoList(); /// Build the Edge Info list - void BuildBriteEdgeInfoList(void); + void BuildBriteEdgeInfoList(); /// Construct the topology. - void ConstructTopology(void); + void ConstructTopology(); /// Generate the BRITE topology. - void GenerateBriteTopology(void); + void GenerateBriteTopology(); /// brite configuration file to use std::string m_confFile; diff --git a/src/brite/test/brite-test-topology.cc b/src/brite/test/brite-test-topology.cc index b00bee09d..022d61912 100644 --- a/src/brite/test/brite-test-topology.cc +++ b/src/brite/test/brite-test-topology.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -44,10 +43,10 @@ class BriteTopologyStructureTestCase : public TestCase { public: BriteTopologyStructureTestCase(); - virtual ~BriteTopologyStructureTestCase(); + ~BriteTopologyStructureTestCase() override; private: - virtual void DoRun(void); + void DoRun() override; }; BriteTopologyStructureTestCase::BriteTopologyStructureTestCase() @@ -61,7 +60,7 @@ BriteTopologyStructureTestCase::~BriteTopologyStructureTestCase() } void -BriteTopologyStructureTestCase::DoRun(void) +BriteTopologyStructureTestCase::DoRun() { std::string confFile = "src/brite/test/test.conf"; @@ -112,10 +111,10 @@ class BriteTopologyFunctionTestCase : public TestCase { public: BriteTopologyFunctionTestCase(); - virtual ~BriteTopologyFunctionTestCase(); + ~BriteTopologyFunctionTestCase() override; private: - virtual void DoRun(void); + void DoRun() override; }; BriteTopologyFunctionTestCase::BriteTopologyFunctionTestCase() @@ -128,7 +127,7 @@ BriteTopologyFunctionTestCase::~BriteTopologyFunctionTestCase() } void -BriteTopologyFunctionTestCase::DoRun(void) +BriteTopologyFunctionTestCase::DoRun() { std::string confFile = "src/brite/test/test.conf"; BriteTopologyHelper bth(confFile); diff --git a/src/buildings/examples/buildings-pathloss-profiler.cc b/src/buildings/examples/buildings-pathloss-profiler.cc index 005386d78..2633a31a5 100644 --- a/src/buildings/examples/buildings-pathloss-profiler.cc +++ b/src/buildings/examples/buildings-pathloss-profiler.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/examples/outdoor-group-mobility-example.cc b/src/buildings/examples/outdoor-group-mobility-example.cc index 614bca1cb..fa3b81b28 100644 --- a/src/buildings/examples/outdoor-group-mobility-example.cc +++ b/src/buildings/examples/outdoor-group-mobility-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 Institute for the Wireless Internet of Things, Northeastern University, * Boston, MA Copyright (c) 2021, University of Washington: refactor for hierarchical model @@ -105,7 +104,7 @@ void PrintGnuplottableBuildingListToFile(std::string filename) { std::ofstream outFile; - outFile.open(filename.c_str(), std::ios_base::out | std::ios_base::trunc); + outFile.open(filename, std::ios_base::out | std::ios_base::trunc); if (!outFile.is_open()) { NS_LOG_ERROR("Can't open file " << filename); diff --git a/src/buildings/examples/outdoor-random-walk-example.cc b/src/buildings/examples/outdoor-random-walk-example.cc index 5c00298a3..18cd8d666 100644 --- a/src/buildings/examples/outdoor-random-walk-example.cc +++ b/src/buildings/examples/outdoor-random-walk-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * Copyright (c) 2019, University of Padova, Dep. of Information Engineering, SIGNET lab diff --git a/src/buildings/helper/building-allocator.cc b/src/buildings/helper/building-allocator.cc index afe4334d0..d671bac35 100644 --- a/src/buildings/helper/building-allocator.cc +++ b/src/buildings/helper/building-allocator.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007 INRIA * Copyright (C) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) diff --git a/src/buildings/helper/building-allocator.h b/src/buildings/helper/building-allocator.h index 7b0c96255..b8ad63318 100644 --- a/src/buildings/helper/building-allocator.h +++ b/src/buildings/helper/building-allocator.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007 INRIA * Copyright (C) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) diff --git a/src/buildings/helper/building-container.cc b/src/buildings/helper/building-container.cc index bbac6c438..fafba52a3 100644 --- a/src/buildings/helper/building-container.cc +++ b/src/buildings/helper/building-container.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) diff --git a/src/buildings/helper/building-container.h b/src/buildings/helper/building-container.h index 8f22d4af4..7f48048f8 100644 --- a/src/buildings/helper/building-container.h +++ b/src/buildings/helper/building-container.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) diff --git a/src/buildings/helper/building-position-allocator.cc b/src/buildings/helper/building-position-allocator.cc index c7fe0488b..1a6bfbd21 100644 --- a/src/buildings/helper/building-position-allocator.cc +++ b/src/buildings/helper/building-position-allocator.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (C) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/helper/building-position-allocator.h b/src/buildings/helper/building-position-allocator.h index b0ba8cb3f..404ff22cb 100644 --- a/src/buildings/helper/building-position-allocator.h +++ b/src/buildings/helper/building-position-allocator.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (C) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/helper/buildings-helper.cc b/src/buildings/helper/buildings-helper.cc index d34d5000e..8d0f614bf 100644 --- a/src/buildings/helper/buildings-helper.cc +++ b/src/buildings/helper/buildings-helper.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2012 CTTC * diff --git a/src/buildings/helper/buildings-helper.h b/src/buildings/helper/buildings-helper.h index 50622ff0c..1a557ba86 100644 --- a/src/buildings/helper/buildings-helper.h +++ b/src/buildings/helper/buildings-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2012 CTTC * diff --git a/src/buildings/model/building-list.cc b/src/buildings/model/building-list.cc index 5c1d617b6..9f533e83d 100644 --- a/src/buildings/model/building-list.cc +++ b/src/buildings/model/building-list.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/building-list.h b/src/buildings/model/building-list.h index 269da2076..c2286b065 100644 --- a/src/buildings/model/building-list.h +++ b/src/buildings/model/building-list.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/building.cc b/src/buildings/model/building.cc index abb5dea37..ead9dcd9d 100644 --- a/src/buildings/model/building.cc +++ b/src/buildings/model/building.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/building.h b/src/buildings/model/building.h index c14f50d67..74b072763 100644 --- a/src/buildings/model/building.h +++ b/src/buildings/model/building.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/buildings-channel-condition-model.cc b/src/buildings/model/buildings-channel-condition-model.cc index 04c115897..bed68dc72 100644 --- a/src/buildings/model/buildings-channel-condition-model.cc +++ b/src/buildings/model/buildings-channel-condition-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015, NYU WIRELESS, Tandon School of Engineering, New York * University @@ -133,7 +132,7 @@ BuildingsChannelConditionModel::IsLineOfSightBlocked(const ns3::Vector& l1, } int64_t -BuildingsChannelConditionModel::AssignStreams([[maybe_unused]] int64_t stream) +BuildingsChannelConditionModel::AssignStreams(int64_t /* stream */) { return 0; } diff --git a/src/buildings/model/buildings-channel-condition-model.h b/src/buildings/model/buildings-channel-condition-model.h index dafb1188c..518c9a084 100644 --- a/src/buildings/model/buildings-channel-condition-model.h +++ b/src/buildings/model/buildings-channel-condition-model.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015, NYU WIRELESS, Tandon School of Engineering, New York * University diff --git a/src/buildings/model/buildings-propagation-loss-model.cc b/src/buildings/model/buildings-propagation-loss-model.cc index 70acd78af..34544ee05 100644 --- a/src/buildings/model/buildings-propagation-loss-model.cc +++ b/src/buildings/model/buildings-propagation-loss-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/buildings-propagation-loss-model.h b/src/buildings/model/buildings-propagation-loss-model.h index 686c75759..fe6e7a85c 100644 --- a/src/buildings/model/buildings-propagation-loss-model.h +++ b/src/buildings/model/buildings-propagation-loss-model.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/hybrid-buildings-propagation-loss-model.cc b/src/buildings/model/hybrid-buildings-propagation-loss-model.cc index 98437148f..9509acd3e 100644 --- a/src/buildings/model/hybrid-buildings-propagation-loss-model.cc +++ b/src/buildings/model/hybrid-buildings-propagation-loss-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/hybrid-buildings-propagation-loss-model.h b/src/buildings/model/hybrid-buildings-propagation-loss-model.h index d94a49b76..5a9c6ca41 100644 --- a/src/buildings/model/hybrid-buildings-propagation-loss-model.h +++ b/src/buildings/model/hybrid-buildings-propagation-loss-model.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/itu-r-1238-propagation-loss-model.cc b/src/buildings/model/itu-r-1238-propagation-loss-model.cc index 22a5996a3..853cbf95d 100644 --- a/src/buildings/model/itu-r-1238-propagation-loss-model.cc +++ b/src/buildings/model/itu-r-1238-propagation-loss-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/itu-r-1238-propagation-loss-model.h b/src/buildings/model/itu-r-1238-propagation-loss-model.h index dbdc2f2d9..b6ded5bb9 100644 --- a/src/buildings/model/itu-r-1238-propagation-loss-model.h +++ b/src/buildings/model/itu-r-1238-propagation-loss-model.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/mobility-building-info.cc b/src/buildings/model/mobility-building-info.cc index 323fdfefb..f7c58b359 100644 --- a/src/buildings/model/mobility-building-info.cc +++ b/src/buildings/model/mobility-building-info.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/mobility-building-info.h b/src/buildings/model/mobility-building-info.h index b654cb8ed..ba71f33e9 100644 --- a/src/buildings/model/mobility-building-info.h +++ b/src/buildings/model/mobility-building-info.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * @@ -71,20 +70,24 @@ class MobilityBuildingInfo : public Object * \brief Mark this MobilityBuildingInfo instance as indoor * * \param building the building into which the MobilityBuildingInfo instance is located - * \param nfloor the floor number 1...nFloors at which the MobilityBuildingInfo instance is - * located \param nroomx the X room number 1...nRoomsX at which the MobilityBuildingInfo - * instance is located \param nroomy the Y room number 1...nRoomsY at which the - * MobilityBuildingInfo instance is located + * \param nfloor the floor number 1...nFloors at which the MobilityBuildingInfo instance + * is located + * \param nroomx the X room number 1...nRoomsX at which the MobilityBuildingInfo instance + * is located + * \param nroomy the Y room number 1...nRoomsY at which the MobilityBuildingInfo instance + * is located */ void SetIndoor(Ptr building, uint8_t nfloor, uint8_t nroomx, uint8_t nroomy); /** * \brief Mark this MobilityBuildingInfo instance as indoor * - * \param nfloor the floor number 1...nFloors at which the MobilityBuildingInfo instance is - * located \param nroomx the X room number 1...nRoomsX at which the MobilityBuildingInfo - * instance is located \param nroomy the Y room number 1...nRoomsY at which the - * MobilityBuildingInfo instance is located + * \param nfloor the floor number 1...nFloors at which the MobilityBuildingInfo instance + * is located + * \param nroomx the X room number 1...nRoomsX at which the MobilityBuildingInfo instance + * is located + * \param nroomy the Y room number 1...nRoomsY at which the MobilityBuildingInfo instance + * is located */ void SetIndoor(uint8_t nfloor, uint8_t nroomx, uint8_t nroomy); diff --git a/src/buildings/model/oh-buildings-propagation-loss-model.cc b/src/buildings/model/oh-buildings-propagation-loss-model.cc index e345f5683..132831a6d 100644 --- a/src/buildings/model/oh-buildings-propagation-loss-model.cc +++ b/src/buildings/model/oh-buildings-propagation-loss-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/oh-buildings-propagation-loss-model.h b/src/buildings/model/oh-buildings-propagation-loss-model.h index 189ce50c1..7e7aa10be 100644 --- a/src/buildings/model/oh-buildings-propagation-loss-model.h +++ b/src/buildings/model/oh-buildings-propagation-loss-model.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc b/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc index db2d366a4..6f6fda524 100644 --- a/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc +++ b/src/buildings/model/random-walk-2d-outdoor-mobility-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2006,2007 INRIA * Copyright (c) 2019 University of Padova diff --git a/src/buildings/model/random-walk-2d-outdoor-mobility-model.h b/src/buildings/model/random-walk-2d-outdoor-mobility-model.h index 4f0cc1fd7..327de64e3 100644 --- a/src/buildings/model/random-walk-2d-outdoor-mobility-model.h +++ b/src/buildings/model/random-walk-2d-outdoor-mobility-model.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2006,2007 INRIA * Copyright (c) 2019 University of Padova @@ -95,16 +94,19 @@ class RandomWalk2dOutdoorMobilityModel : public MobilityModel /** * Check if there is a building between two positions (or if the nextPosition is inside a * building). The code is taken from MmWave3gppBuildingsPropagationLossModel from the NYU/UNIPD - * ns-3 mmWave module \param currentPosition The current position of the node \param - * nextPosition The position to check \return a pair with a boolean (true if the line between - * the two position does not intersect building), and a pointer which is 0 if the boolean is - * true, or it points to the building which is intersected + * ns-3 mmWave module + * \param currentPosition The current position of the node + * \param nextPosition The position to check + * \return a pair with a boolean (true if the line between the two position does not intersect + * building), and a pointer which is 0 if the boolean is true, or it points to the building + * which is intersected */ std::pair> IsLineClearOfBuildings(Vector currentPosition, Vector nextPosition) const; /** * Compute the intersecting point of the box represented by boundaries and the line between - * current and next Notice that we only consider a 2d plane \param current The current position + * current and next. Notice that we only consider a 2d plane. + * \param current The current position * \param next The next position * \param boundaries The boundaries of the building we will intersect * \return a vector with the position of the intersection diff --git a/src/buildings/model/three-gpp-v2v-channel-condition-model.cc b/src/buildings/model/three-gpp-v2v-channel-condition-model.cc index d3207f15a..21e02bed2 100644 --- a/src/buildings/model/three-gpp-v2v-channel-condition-model.cc +++ b/src/buildings/model/three-gpp-v2v-channel-condition-model.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 SIGNET Lab, Department of Information Engineering, * University of Padova diff --git a/src/buildings/model/three-gpp-v2v-channel-condition-model.h b/src/buildings/model/three-gpp-v2v-channel-condition-model.h index f7918ff9a..0d50c409f 100644 --- a/src/buildings/model/three-gpp-v2v-channel-condition-model.h +++ b/src/buildings/model/three-gpp-v2v-channel-condition-model.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 SIGNET Lab, Department of Information Engineering, * University of Padova diff --git a/src/buildings/test/building-position-allocator-test.cc b/src/buildings/test/building-position-allocator-test.cc index 81c022bb2..94879a592 100644 --- a/src/buildings/test/building-position-allocator-test.cc +++ b/src/buildings/test/building-position-allocator-test.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/test/buildings-channel-condition-model-test.cc b/src/buildings/test/buildings-channel-condition-model-test.cc index dd2987281..2924d4051 100644 --- a/src/buildings/test/buildings-channel-condition-model-test.cc +++ b/src/buildings/test/buildings-channel-condition-model-test.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2019 SIGNET Lab, Department of Information Engineering, * University of Padova diff --git a/src/buildings/test/buildings-helper-test.cc b/src/buildings/test/buildings-helper-test.cc index 308bc2656..16489f85b 100644 --- a/src/buildings/test/buildings-helper-test.cc +++ b/src/buildings/test/buildings-helper-test.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/test/buildings-pathloss-test.cc b/src/buildings/test/buildings-pathloss-test.cc index 3c8ab45d3..7e9a39f11 100644 --- a/src/buildings/test/buildings-pathloss-test.cc +++ b/src/buildings/test/buildings-pathloss-test.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/test/buildings-pathloss-test.h b/src/buildings/test/buildings-pathloss-test.h index 57f44304f..7cbf3c3c2 100644 --- a/src/buildings/test/buildings-pathloss-test.h +++ b/src/buildings/test/buildings-pathloss-test.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/test/buildings-shadowing-test.cc b/src/buildings/test/buildings-shadowing-test.cc index 1b147af12..5adc16b65 100644 --- a/src/buildings/test/buildings-shadowing-test.cc +++ b/src/buildings/test/buildings-shadowing-test.cc @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/test/buildings-shadowing-test.h b/src/buildings/test/buildings-shadowing-test.h index 72433ea15..68a2af7f5 100644 --- a/src/buildings/test/buildings-shadowing-test.h +++ b/src/buildings/test/buildings-shadowing-test.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * diff --git a/src/buildings/test/outdoor-random-walk-test.cc b/src/buildings/test/outdoor-random-walk-test.cc index cd0b49af0..f6db0a306 100644 --- a/src/buildings/test/outdoor-random-walk-test.cc +++ b/src/buildings/test/outdoor-random-walk-test.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2019 SIGNET Lab, Department of Information Engineering, * University of Padova diff --git a/src/buildings/test/three-gpp-v2v-channel-condition-model-test.cc b/src/buildings/test/three-gpp-v2v-channel-condition-model-test.cc index 41a259f6c..ddb2f4eaf 100644 --- a/src/buildings/test/three-gpp-v2v-channel-condition-model-test.cc +++ b/src/buildings/test/three-gpp-v2v-channel-condition-model-test.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) * Copyright (c) 2020 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) diff --git a/src/click/examples/nsclick-defines.cc b/src/click/examples/nsclick-defines.cc index 9602650d5..dd1a0e619 100644 --- a/src/click/examples/nsclick-defines.cc +++ b/src/click/examples/nsclick-defines.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -70,4 +69,6 @@ main(int argc, char* argv[]) #else NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); #endif + + return 0; } diff --git a/src/click/examples/nsclick-raw-wlan.cc b/src/click/examples/nsclick-raw-wlan.cc index ef96d9e74..47c669fcb 100644 --- a/src/click/examples/nsclick-raw-wlan.cc +++ b/src/click/examples/nsclick-raw-wlan.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -151,8 +150,9 @@ main(int argc, char* argv[]) Simulator::Run(); Simulator::Destroy(); - return 0; #else NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); #endif + + return 0; } diff --git a/src/click/examples/nsclick-routing.cc b/src/click/examples/nsclick-routing.cc index 15b9f70fc..82fd143db 100644 --- a/src/click/examples/nsclick-routing.cc +++ b/src/click/examples/nsclick-routing.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -135,4 +134,6 @@ main(int argc, char* argv[]) #else NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); #endif + + return 0; } diff --git a/src/click/examples/nsclick-simple-lan.cc b/src/click/examples/nsclick-simple-lan.cc index 03a483cb4..fc6f38e42 100644 --- a/src/click/examples/nsclick-simple-lan.cc +++ b/src/click/examples/nsclick-simple-lan.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -105,8 +104,9 @@ main(int argc, char* argv[]) Simulator::Run(); Simulator::Destroy(); - return 0; #else NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); #endif + + return 0; } diff --git a/src/click/examples/nsclick-udp-client-server-csma.cc b/src/click/examples/nsclick-udp-client-server-csma.cc index ebb259b20..6a2264234 100644 --- a/src/click/examples/nsclick-udp-client-server-csma.cc +++ b/src/click/examples/nsclick-udp-client-server-csma.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -134,4 +133,6 @@ main(int argc, char* argv[]) #else NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); #endif + + return 0; } diff --git a/src/click/examples/nsclick-udp-client-server-wifi.cc b/src/click/examples/nsclick-udp-client-server-wifi.cc index 243a694f2..c601ac2ef 100644 --- a/src/click/examples/nsclick-udp-client-server-wifi.cc +++ b/src/click/examples/nsclick-udp-client-server-wifi.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -220,4 +219,6 @@ main(int argc, char* argv[]) #else NS_FATAL_ERROR("Can't use ns-3-click without NSCLICK compiled in"); #endif + + return 0; } diff --git a/src/click/helper/click-internet-stack-helper.cc b/src/click/helper/click-internet-stack-helper.cc index ad7fed172..ee800ddc3 100644 --- a/src/click/helper/click-internet-stack-helper.cc +++ b/src/click/helper/click-internet-stack-helper.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * @@ -95,7 +94,7 @@ ClickInternetStackHelper::operator=(const ClickInternetStackHelper& o) } void -ClickInternetStackHelper::Reset(void) +ClickInternetStackHelper::Reset() { m_ipv4Enabled = true; Initialize(); @@ -169,7 +168,7 @@ ClickInternetStackHelper::Install(NodeContainer c) const } void -ClickInternetStackHelper::InstallAll(void) const +ClickInternetStackHelper::InstallAll() const { Install(NodeContainer::GetGlobal()); } diff --git a/src/click/helper/click-internet-stack-helper.h b/src/click/helper/click-internet-stack-helper.h index fcd187626..f0f039782 100644 --- a/src/click/helper/click-internet-stack-helper.h +++ b/src/click/helper/click-internet-stack-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * @@ -54,19 +53,19 @@ class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp /** * Create a new ClickInternetStackHelper which uses Ipv4ClickRouting for routing */ - ClickInternetStackHelper(void); + ClickInternetStackHelper(); /** * Destroy the ClickInternetStackHelper */ - virtual ~ClickInternetStackHelper(void); + ~ClickInternetStackHelper() override; ClickInternetStackHelper(const ClickInternetStackHelper&); ClickInternetStackHelper& operator=(const ClickInternetStackHelper& o); /** * Return helper internal state to that of a newly constructed one */ - void Reset(void); + void Reset(); /** * Aggregate implementations of the ns3::Ipv4L3ClickProtocol, ns3::ArpL3Protocol, @@ -100,7 +99,7 @@ class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp /** * Aggregate IPv4, UDP, and TCP stacks to all nodes in the simulation */ - void InstallAll(void) const; + void InstallAll() const; /** * \brief set the Tcp stack which will not need any other parameter. @@ -180,10 +179,10 @@ class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp * @param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing. * @param interface Interface ID on the Ipv4 on which you want to enable tracing. */ - virtual void EnablePcapIpv4Internal(std::string prefix, - Ptr ipv4, - uint32_t interface, - bool explicitFilename); + void EnablePcapIpv4Internal(std::string prefix, + Ptr ipv4, + uint32_t interface, + bool explicitFilename) override; /** * @brief Enable ascii trace output on the indicated Ipv4 and interface pair. @@ -194,18 +193,18 @@ class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp * @param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing. * @param interface Interface ID on the Ipv4 on which you want to enable tracing. */ - virtual void EnableAsciiIpv4Internal(Ptr stream, - std::string prefix, - Ptr ipv4, - uint32_t interface, - bool explicitFilename); + void EnableAsciiIpv4Internal(Ptr stream, + std::string prefix, + Ptr ipv4, + uint32_t interface, + bool explicitFilename) override; - void Initialize(void); + void Initialize(); ObjectFactory m_tcpFactory; static void CreateAndAggregateObjectFromTypeId(Ptr node, const std::string typeId); - static void Cleanup(void); + static void Cleanup(); bool PcapHooked(Ptr ipv4); diff --git a/src/click/model/ipv4-click-routing.cc b/src/click/model/ipv4-click-routing.cc index 7f87ed07b..c70b69628 100644 --- a/src/click/model/ipv4-click-routing.cc +++ b/src/click/model/ipv4-click-routing.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 Lalith Suresh * @@ -50,7 +49,7 @@ NS_OBJECT_ENSURE_REGISTERED(Ipv4ClickRouting); std::map> Ipv4ClickRouting::m_clickInstanceFromSimNode; TypeId -Ipv4ClickRouting::GetTypeId(void) +Ipv4ClickRouting::GetTypeId() { static TypeId tid = TypeId("ns3::Ipv4ClickRouting") .SetParent() @@ -62,7 +61,7 @@ Ipv4ClickRouting::GetTypeId(void) Ipv4ClickRouting::Ipv4ClickRouting() : m_nonDefaultName(false), - m_ipv4(0) + m_ipv4(nullptr) { m_random = CreateObject(); m_simNode = new simclick_node_t; @@ -113,7 +112,7 @@ Ipv4ClickRouting::SetIpv4(Ptr ipv4) } Ptr -Ipv4ClickRouting::GetRandomVariable(void) +Ipv4ClickRouting::GetRandomVariable() { return m_random; } @@ -125,7 +124,7 @@ Ipv4ClickRouting::DoDispose() { simclick_click_kill(m_simNode); } - m_ipv4 = 0; + m_ipv4 = nullptr; delete m_simNode; Ipv4RoutingProtocol::DoDispose(); } @@ -143,7 +142,7 @@ Ipv4ClickRouting::SetDefines(std::map defines) } std::map -Ipv4ClickRouting::GetDefines(void) +Ipv4ClickRouting::GetDefines() { return m_defines; } @@ -442,8 +441,11 @@ Ipv4ClickRouting::Receive(Ptr p, Mac48Address receiverAddr, Mac48Address std::string Ipv4ClickRouting::ReadHandler(std::string elementName, std::string handlerName) { - char* handle = - simclick_click_read_handler(m_simNode, elementName.c_str(), handlerName.c_str(), 0, 0); + char* handle = simclick_click_read_handler(m_simNode, + elementName.c_str(), + handlerName.c_str(), + nullptr, + nullptr); std::string ret(handle); // This is required because Click does not free @@ -498,7 +500,7 @@ Ipv4ClickRouting::RouteOutput(Ptr p, std::string s = ReadHandler(m_clickRoutingTableElement, addr.str()); NS_LOG_DEBUG("string from click routing table: " << s); - size_t pos = s.find(" "); + size_t pos = s.find(' '); Ipv4Address destination; int interfaceId; if (pos == std::string::npos) @@ -631,7 +633,7 @@ simclick_sim_send(simclick_node_t* simnode, << ifid << " " << type << " " << data << " " << len); - if (simnode == NULL) + if (!simnode) { return -1; } diff --git a/src/click/model/ipv4-click-routing.h b/src/click/model/ipv4-click-routing.h index d2c26331e..72217f4c7 100644 --- a/src/click/model/ipv4-click-routing.h +++ b/src/click/model/ipv4-click-routing.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 Lalith Suresh * @@ -66,18 +65,18 @@ class Ipv4ClickRouting : public Ipv4RoutingProtocol friend class ::ClickIfidFromNameTest; friend class ::ClickIpMacAddressFromNameTest; - static TypeId GetTypeId(void); + static TypeId GetTypeId(); Ipv4ClickRouting(); - virtual ~Ipv4ClickRouting(); + ~Ipv4ClickRouting() override; - Ptr GetRandomVariable(void); + Ptr GetRandomVariable(); protected: - virtual void DoInitialize(void); + void DoInitialize() override; public: - virtual void DoDispose(); + void DoDispose() override; /** * \brief Click configuration file to be used by the node's Click Instance. @@ -138,9 +137,10 @@ class Ipv4ClickRouting : public Ipv4RoutingProtocol public: /** * \brief Allows the Click service methods, which reside outside Ipv4ClickRouting, to get the - * required Ipv4ClickRouting instances. \param simnode The Click simclick_node_t instance for - * which the Ipv4ClickRouting instance is required \return A Ptr to the required - * Ipv4ClickRouting instance + * required Ipv4ClickRouting instances. + * \param simnode The Click simclick_node_t instance for which the Ipv4ClickRouting instance is + * required + * \return A Ptr to the required Ipv4ClickRouting instance */ static Ptr GetClickInstanceFromSimNode(simclick_node_t* simnode); @@ -149,7 +149,7 @@ class Ipv4ClickRouting : public Ipv4RoutingProtocol * \brief Provides for SIMCLICK_GET_DEFINES * \return The defines mapping for .click configuration file parsing */ - std::map GetDefines(void); + std::map GetDefines(); /** * \brief Provides for SIMCLICK_IFID_FROM_NAME @@ -195,7 +195,7 @@ class Ipv4ClickRouting : public Ipv4RoutingProtocol * \brief Set the Ipv4 instance to be used * \param ipv4 The Ipv4 instance */ - virtual void SetIpv4(Ptr ipv4); + void SetIpv4(Ptr ipv4) override; private: /** @@ -256,23 +256,23 @@ class Ipv4ClickRouting : public Ipv4RoutingProtocol void Receive(Ptr p, Mac48Address receiverAddr, Mac48Address dest); // From Ipv4RoutingProtocol - virtual Ptr RouteOutput(Ptr p, - const Ipv4Header& header, - Ptr oif, - Socket::SocketErrno& sockerr); - virtual bool RouteInput(Ptr p, - const Ipv4Header& header, - Ptr idev, - UnicastForwardCallback ucb, - MulticastForwardCallback mcb, - LocalDeliverCallback lcb, - ErrorCallback ecb); - virtual void PrintRoutingTable(Ptr stream, - Time::Unit unit = Time::S) const; - virtual void NotifyInterfaceUp(uint32_t interface); - virtual void NotifyInterfaceDown(uint32_t interface); - virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address); - virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address); + Ptr RouteOutput(Ptr p, + const Ipv4Header& header, + Ptr oif, + Socket::SocketErrno& sockerr) override; + bool RouteInput(Ptr p, + const Ipv4Header& header, + Ptr idev, + UnicastForwardCallback ucb, + MulticastForwardCallback mcb, + LocalDeliverCallback lcb, + ErrorCallback ecb) override; + void PrintRoutingTable(Ptr stream, + Time::Unit unit = Time::S) const override; + void NotifyInterfaceUp(uint32_t interface) override; + void NotifyInterfaceDown(uint32_t interface) override; + void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address) override; + void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address) override; private: std::string m_clickFile; diff --git a/src/click/model/ipv4-l3-click-protocol.cc b/src/click/model/ipv4-l3-click-protocol.cc index 17047050b..60d4ca089 100644 --- a/src/click/model/ipv4-l3-click-protocol.cc +++ b/src/click/model/ipv4-l3-click-protocol.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ // // Copyright (c) 2006 Georgia Tech Research Corporation // @@ -47,7 +46,7 @@ const uint16_t Ipv4L3ClickProtocol::PROT_NUMBER = 0x0800; NS_OBJECT_ENSURE_REGISTERED(Ipv4L3ClickProtocol); TypeId -Ipv4L3ClickProtocol::GetTypeId(void) +Ipv4L3ClickProtocol::GetTypeId() { static TypeId tid = TypeId("ns3::Ipv4L3ClickProtocol") @@ -78,25 +77,25 @@ Ipv4L3ClickProtocol::~Ipv4L3ClickProtocol() } void -Ipv4L3ClickProtocol::DoDispose(void) +Ipv4L3ClickProtocol::DoDispose() { NS_LOG_FUNCTION(this); for (L4List_t::iterator i = m_protocols.begin(); i != m_protocols.end(); ++i) { - i->second = 0; + i->second = nullptr; } m_protocols.clear(); for (Ipv4InterfaceList::iterator i = m_interfaces.begin(); i != m_interfaces.end(); ++i) { - *i = 0; + *i = nullptr; } m_interfaces.clear(); m_reverseInterfacesContainer.clear(); m_sockets.clear(); - m_node = 0; - m_routingProtocol = 0; + m_node = nullptr; + m_routingProtocol = nullptr; Object::DoDispose(); } @@ -125,7 +124,7 @@ Ipv4L3ClickProtocol::SetRoutingProtocol(Ptr routingProtocol } Ptr -Ipv4L3ClickProtocol::GetRoutingProtocol(void) const +Ipv4L3ClickProtocol::GetRoutingProtocol() const { return m_routingProtocol; } @@ -138,11 +137,11 @@ Ipv4L3ClickProtocol::GetInterface(uint32_t index) const { return m_interfaces[index]; } - return 0; + return nullptr; } uint32_t -Ipv4L3ClickProtocol::GetNInterfaces(void) const +Ipv4L3ClickProtocol::GetNInterfaces() const { NS_LOG_FUNCTION_NOARGS(); return m_interfaces.size(); @@ -284,7 +283,7 @@ Ipv4L3ClickProtocol::SetIpForward(bool forward) } bool -Ipv4L3ClickProtocol::GetIpForward(void) const +Ipv4L3ClickProtocol::GetIpForward() const { return m_ipForward; } @@ -296,7 +295,7 @@ Ipv4L3ClickProtocol::SetWeakEsModel(bool model) } bool -Ipv4L3ClickProtocol::GetWeakEsModel(void) const +Ipv4L3ClickProtocol::GetWeakEsModel() const { return m_weakEsModel; } @@ -316,12 +315,12 @@ Ipv4L3ClickProtocol::SetDefaultTtl(uint8_t ttl) } void -Ipv4L3ClickProtocol::SetupLoopback(void) +Ipv4L3ClickProtocol::SetupLoopback() { NS_LOG_FUNCTION_NOARGS(); Ptr interface = CreateObject(); - Ptr device = 0; + Ptr device = nullptr; // First check whether an existing LoopbackNetDevice exists on the node for (uint32_t i = 0; i < m_node->GetNDevices(); i++) { @@ -353,7 +352,7 @@ Ipv4L3ClickProtocol::SetupLoopback(void) } Ptr -Ipv4L3ClickProtocol::CreateRawSocket(void) +Ipv4L3ClickProtocol::CreateRawSocket() { NS_LOG_FUNCTION(this); Ptr socket = CreateObject(); @@ -374,7 +373,6 @@ Ipv4L3ClickProtocol::DeleteRawSocket(Ptr socket) return; } } - return; } void @@ -726,7 +724,6 @@ Ipv4L3ClickProtocol::Send(Ptr packet, } packet->AddHeader(ipHeader); click->Send(packet->Copy(), source, destination); - return; } void @@ -883,7 +880,7 @@ Ipv4L3ClickProtocol::LocalDeliver(Ptr packet, const Ipv4Header& ip } Ptr -Ipv4L3ClickProtocol::GetIcmp(void) const +Ipv4L3ClickProtocol::GetIcmp() const { Ptr prot = GetProtocol(Icmpv4L4Protocol::GetStaticProtocolNumber()); if (prot) @@ -892,7 +889,7 @@ Ipv4L3ClickProtocol::GetIcmp(void) const } else { - return 0; + return nullptr; } } @@ -992,7 +989,7 @@ Ipv4L3ClickProtocol::GetProtocol(int protocolNumber, int32_t interfaceIndex) con return i->second; } - return 0; + return nullptr; } } // namespace ns3 diff --git a/src/click/model/ipv4-l3-click-protocol.h b/src/click/model/ipv4-l3-click-protocol.h index 3fd12a1b0..6f36f9cee 100644 --- a/src/click/model/ipv4-l3-click-protocol.h +++ b/src/click/model/ipv4-l3-click-protocol.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ // // Copyright (c) 2006 Georgia Tech Research Corporation // @@ -63,7 +62,7 @@ class Ipv4L3ClickProtocol : public Ipv4 { #ifdef NS3_CLICK public: - static TypeId GetTypeId(void); + static TypeId GetTypeId(); /** * Protocol number for Ipv4 L3 (0x0800). @@ -71,18 +70,18 @@ class Ipv4L3ClickProtocol : public Ipv4 static const uint16_t PROT_NUMBER; Ipv4L3ClickProtocol(); - virtual ~Ipv4L3ClickProtocol(); + ~Ipv4L3ClickProtocol() override; - virtual void Insert(Ptr protocol); - virtual void Insert(Ptr protocol, uint32_t interfaceIndex); + void Insert(Ptr protocol) override; + void Insert(Ptr protocol, uint32_t interfaceIndex) override; - virtual void Remove(Ptr protocol); - virtual void Remove(Ptr protocol, uint32_t interfaceIndex); + void Remove(Ptr protocol) override; + void Remove(Ptr protocol, uint32_t interfaceIndex) override; - virtual Ptr GetProtocol(int protocolNumber) const; - virtual Ptr GetProtocol(int protocolNumber, int32_t interfaceIndex) const; + Ptr GetProtocol(int protocolNumber) const override; + Ptr GetProtocol(int protocolNumber, int32_t interfaceIndex) const override; - virtual Ipv4Address SourceAddressSelection(uint32_t interface, Ipv4Address dest); + Ipv4Address SourceAddressSelection(uint32_t interface, Ipv4Address dest) override; /** * \param ttl default ttl to use @@ -106,7 +105,7 @@ class Ipv4L3ClickProtocol : public Ipv4 Ipv4Address source, Ipv4Address destination, uint8_t protocol, - Ptr route); + Ptr route) override; /** * \param packet packet to send @@ -116,7 +115,7 @@ class Ipv4L3ClickProtocol : public Ipv4 * Higher-level layers call this method to send a packet with IPv4 Header * (Intend to be used with IpHeaderInclude attribute.) */ - void SendWithHeader(Ptr packet, Ipv4Header ipHeader, Ptr route); + void SendWithHeader(Ptr packet, Ipv4Header ipHeader, Ptr route) override; /** * \param packet packet to send down the stack @@ -175,66 +174,66 @@ class Ipv4L3ClickProtocol : public Ipv4 * Returns the Icmpv4L4Protocol for the node * \returns Icmpv4L4Protocol instance of the node */ - Ptr GetIcmp(void) const; + Ptr GetIcmp() const; /** * Sets up a Loopback device */ - void SetupLoopback(void); + void SetupLoopback(); /** * Creates a raw-socket * \returns Pointer to the created socket */ - Ptr CreateRawSocket(void); + Ptr CreateRawSocket() override; /** * Deletes a particular raw socket * \param socket Pointer of socket to be deleted */ - void DeleteRawSocket(Ptr socket); + void DeleteRawSocket(Ptr socket) override; // functions defined in base class Ipv4 - void SetRoutingProtocol(Ptr routingProtocol); - Ptr GetRoutingProtocol(void) const; + void SetRoutingProtocol(Ptr routingProtocol) override; + Ptr GetRoutingProtocol() const override; - Ptr GetNetDevice(uint32_t i); + Ptr GetNetDevice(uint32_t i) override; - uint32_t AddInterface(Ptr device); - uint32_t GetNInterfaces(void) const; + uint32_t AddInterface(Ptr device) override; + uint32_t GetNInterfaces() const override; - int32_t GetInterfaceForAddress(Ipv4Address addr) const; - int32_t GetInterfaceForPrefix(Ipv4Address addr, Ipv4Mask mask) const; - int32_t GetInterfaceForDevice(Ptr device) const; - bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const; + int32_t GetInterfaceForAddress(Ipv4Address addr) const override; + int32_t GetInterfaceForPrefix(Ipv4Address addr, Ipv4Mask mask) const override; + int32_t GetInterfaceForDevice(Ptr device) const override; + bool IsDestinationAddress(Ipv4Address address, uint32_t iif) const override; - bool AddAddress(uint32_t i, Ipv4InterfaceAddress address); - Ipv4InterfaceAddress GetAddress(uint32_t interfaceIndex, uint32_t addressIndex) const; - uint32_t GetNAddresses(uint32_t interface) const; - bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex); - bool RemoveAddress(uint32_t interfaceIndex, Ipv4Address address); + bool AddAddress(uint32_t i, Ipv4InterfaceAddress address) override; + Ipv4InterfaceAddress GetAddress(uint32_t interfaceIndex, uint32_t addressIndex) const override; + uint32_t GetNAddresses(uint32_t interface) const override; + bool RemoveAddress(uint32_t interfaceIndex, uint32_t addressIndex) override; + bool RemoveAddress(uint32_t interfaceIndex, Ipv4Address address) override; Ipv4Address SelectSourceAddress(Ptr device, Ipv4Address dst, - Ipv4InterfaceAddress::InterfaceAddressScope_e scope); + Ipv4InterfaceAddress::InterfaceAddressScope_e scope) override; - void SetMetric(uint32_t i, uint16_t metric); - uint16_t GetMetric(uint32_t i) const; - uint16_t GetMtu(uint32_t i) const; - bool IsUp(uint32_t i) const; - void SetUp(uint32_t i); - void SetDown(uint32_t i); - bool IsForwarding(uint32_t i) const; - void SetForwarding(uint32_t i, bool val); + void SetMetric(uint32_t i, uint16_t metric) override; + uint16_t GetMetric(uint32_t i) const override; + uint16_t GetMtu(uint32_t i) const override; + bool IsUp(uint32_t i) const override; + void SetUp(uint32_t i) override; + void SetDown(uint32_t i) override; + bool IsForwarding(uint32_t i) const override; + void SetForwarding(uint32_t i, bool val) override; void SetPromisc(uint32_t i); protected: - virtual void DoDispose(void); + void DoDispose() override; /** * This function will notify other components connected to the node that a new stack member is * now connected This will be used to notify Layer 3 protocol of layer 4 protocol stack to * connect them together. */ - virtual void NotifyNewAggregate(); + void NotifyNewAggregate() override; private: Ipv4Header BuildHeader(Ipv4Address source, @@ -244,10 +243,10 @@ class Ipv4L3ClickProtocol : public Ipv4 uint8_t ttl, bool mayFragment); - virtual void SetIpForward(bool forward); - virtual bool GetIpForward(void) const; - virtual void SetWeakEsModel(bool model); - virtual bool GetWeakEsModel(void) const; + void SetIpForward(bool forward) override; + bool GetIpForward() const override; + void SetWeakEsModel(bool model) override; + bool GetWeakEsModel() const override; typedef std::vector> Ipv4InterfaceList; /** diff --git a/src/click/test/ipv4-click-routing-test.cc b/src/click/test/ipv4-click-routing-test.cc index 547dcdcfd..ba943b034 100644 --- a/src/click/test/ipv4-click-routing-test.cc +++ b/src/click/test/ipv4-click-routing-test.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 Lalith Suresh * @@ -29,6 +28,7 @@ #include "ns3/test.h" #include +#include using namespace ns3; @@ -60,7 +60,7 @@ class ClickIfidFromNameTest : public TestCase { public: ClickIfidFromNameTest(); - virtual void DoRun(); + void DoRun() override; }; ClickIfidFromNameTest::ClickIfidFromNameTest() @@ -106,7 +106,7 @@ class ClickIpMacAddressFromNameTest : public TestCase { public: ClickIpMacAddressFromNameTest(); - virtual void DoRun(); + void DoRun() override; }; ClickIpMacAddressFromNameTest::ClickIpMacAddressFromNameTest() @@ -131,34 +131,33 @@ ClickIpMacAddressFromNameTest::DoRun() Ptr click = DynamicCast(ipv4->GetRoutingProtocol()); click->DoInitialize(); - char* buf = NULL; - buf = new char[255]; + char* buf = new char[255]; simclick_sim_command(click->m_simNode, SIMCLICK_IPADDR_FROM_NAME, "eth0", buf, 255); - NS_TEST_EXPECT_MSG_EQ(strcmp(buf, "10.1.1.1"), 0, "eth0 has IP 10.1.1.1"); + NS_TEST_EXPECT_MSG_EQ(std::string(buf), "10.1.1.1", "eth0 has IP 10.1.1.1"); simclick_sim_command(click->m_simNode, SIMCLICK_MACADDR_FROM_NAME, "eth0", buf, 255); - NS_TEST_EXPECT_MSG_EQ(strcmp(buf, "00:00:00:00:00:01"), - 0, + NS_TEST_EXPECT_MSG_EQ(std::string(buf), + "00:00:00:00:00:01", "eth0 has Mac Address 00:00:00:00:00:01"); simclick_sim_command(click->m_simNode, SIMCLICK_IPADDR_FROM_NAME, "eth1", buf, 255); - NS_TEST_EXPECT_MSG_EQ(strcmp(buf, "10.1.1.2"), 0, "eth1 has IP 10.1.1.2"); + NS_TEST_EXPECT_MSG_EQ(std::string(buf), "10.1.1.2", "eth1 has IP 10.1.1.2"); simclick_sim_command(click->m_simNode, SIMCLICK_MACADDR_FROM_NAME, "eth1", buf, 255); - NS_TEST_EXPECT_MSG_EQ(strcmp(buf, "00:00:00:00:00:02"), - 0, + NS_TEST_EXPECT_MSG_EQ(std::string(buf), + "00:00:00:00:00:02", "eth0 has Mac Address 00:00:00:00:00:02"); // Not sure how to test the below case, because the Ipv4ClickRouting code is to ASSERT for such // inputs simclick_sim_command (click->m_simNode, SIMCLICK_IPADDR_FROM_NAME, "eth2", buf, 255); - // NS_TEST_EXPECT_MSG_EQ (buf, NULL, "No eth2"); + // NS_TEST_EXPECT_MSG_EQ (buf, nullptr, "No eth2"); simclick_sim_command(click->m_simNode, SIMCLICK_IPADDR_FROM_NAME, "tap0", buf, 255); - NS_TEST_EXPECT_MSG_EQ(strcmp(buf, "127.0.0.1"), 0, "tun0 has IP 127.0.0.1"); + NS_TEST_EXPECT_MSG_EQ(std::string(buf), "127.0.0.1", "tun0 has IP 127.0.0.1"); simclick_sim_command(click->m_simNode, SIMCLICK_MACADDR_FROM_NAME, "tap0", buf, 255); - NS_TEST_EXPECT_MSG_EQ(strcmp(buf, "00:00:00:00:00:00"), 0, "tun0 has IP 127.0.0.1"); + NS_TEST_EXPECT_MSG_EQ(std::string(buf), "00:00:00:00:00:00", "tun0 has IP 127.0.0.1"); delete[] buf; } @@ -167,7 +166,7 @@ class ClickTrivialTest : public TestCase { public: ClickTrivialTest(); - virtual void DoRun(); + void DoRun() override; }; ClickTrivialTest::ClickTrivialTest() @@ -190,11 +189,10 @@ ClickTrivialTest::DoRun() click->DoInitialize(); int ret = 0; - char* buf = NULL; - buf = new char[255]; + char* buf = new char[255]; ret = simclick_sim_command(click->m_simNode, SIMCLICK_GET_NODE_NAME, buf, 255); - NS_TEST_EXPECT_MSG_EQ(strcmp(buf, "myNode"), 0, "Node name is Node"); + NS_TEST_EXPECT_MSG_EQ(std::string(buf), "myNode", "Node name is Node"); ret = simclick_sim_command(click->m_simNode, SIMCLICK_IF_READY, 0); NS_TEST_EXPECT_MSG_EQ(ret, 1, "tap0 is ready"); diff --git a/src/config-store/examples/config-store-save.cc b/src/config-store/examples/config-store-save.cc index 2692a1a72..63c640e94 100644 --- a/src/config-store/examples/config-store-save.cc +++ b/src/config-store/examples/config-store-save.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ #include "ns3/config-store-module.h" #include "ns3/core-module.h" diff --git a/src/config-store/model/attribute-default-iterator.cc b/src/config-store/model/attribute-default-iterator.cc index 2b35aee9c..27dde2826 100644 --- a/src/config-store/model/attribute-default-iterator.cc +++ b/src/config-store/model/attribute-default-iterator.cc @@ -1,4 +1,3 @@ -/* -*- 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/src/config-store/model/attribute-default-iterator.h b/src/config-store/model/attribute-default-iterator.h index 02b8a2507..14cbf6d1b 100644 --- a/src/config-store/model/attribute-default-iterator.h +++ b/src/config-store/model/attribute-default-iterator.h @@ -1,4 +1,3 @@ -/* -*- 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/src/config-store/model/attribute-iterator.cc b/src/config-store/model/attribute-iterator.cc index de95ca25f..d6df2676f 100644 --- a/src/config-store/model/attribute-iterator.cc +++ b/src/config-store/model/attribute-iterator.cc @@ -1,4 +1,3 @@ -/* -*- 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/src/config-store/model/attribute-iterator.h b/src/config-store/model/attribute-iterator.h index 82f4636fb..4fe203c9a 100644 --- a/src/config-store/model/attribute-iterator.h +++ b/src/config-store/model/attribute-iterator.h @@ -1,4 +1,3 @@ -/* -*- 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/src/config-store/model/config-store.cc b/src/config-store/model/config-store.cc index 34f08cfce..d611bb3bd 100644 --- a/src/config-store/model/config-store.cc +++ b/src/config-store/model/config-store.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/src/config-store/model/config-store.h b/src/config-store/model/config-store.h index 3d4eaf356..468b3ed7b 100644 --- a/src/config-store/model/config-store.h +++ b/src/config-store/model/config-store.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/src/config-store/model/display-functions.cc b/src/config-store/model/display-functions.cc index 4e4ae0ae8..bb61fb5a8 100644 --- a/src/config-store/model/display-functions.cc +++ b/src/config-store/model/display-functions.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -38,7 +37,7 @@ cell_data_function_col_1(GtkTreeViewColumn* col, GtkTreeIter* iter, gpointer user_data) { - ModelNode* node = 0; + ModelNode* node = nullptr; gtk_tree_model_get(model, iter, COL_NODE, &node, -1); if (!node) { @@ -48,13 +47,13 @@ cell_data_function_col_1(GtkTreeViewColumn* col, { StringValue str; node->object->GetAttribute(node->name, str); - g_object_set(renderer, "text", str.Get().c_str(), (char*)0); - g_object_set(renderer, "editable", TRUE, (char*)0); + g_object_set(renderer, "text", str.Get().c_str(), nullptr); + g_object_set(renderer, "editable", TRUE, nullptr); } else { - g_object_set(renderer, "text", "", (char*)0); - g_object_set(renderer, "editable", FALSE, (char*)0); + g_object_set(renderer, "text", "", nullptr); + g_object_set(renderer, "editable", FALSE, nullptr); } } @@ -69,9 +68,9 @@ cell_data_function_col_0(GtkTreeViewColumn* col, GtkTreeIter* iter, gpointer user_data) { - ModelNode* node = 0; + ModelNode* node = nullptr; gtk_tree_model_get(model, iter, COL_NODE, &node, -1); - g_object_set(renderer, "editable", FALSE, (char*)0); + g_object_set(renderer, "editable", FALSE, nullptr); if (!node) { return; @@ -83,22 +82,22 @@ cell_data_function_col_0(GtkTreeViewColumn* col, g_object_set(renderer, "text", node->object->GetInstanceTypeId().GetName().c_str(), - (char*)0); + nullptr); break; case ModelNode::NODE_POINTER: - g_object_set(renderer, "text", node->name.c_str(), (char*)0); + g_object_set(renderer, "text", node->name.c_str(), nullptr); break; case ModelNode::NODE_VECTOR: - g_object_set(renderer, "text", node->name.c_str(), (char*)0); + g_object_set(renderer, "text", node->name.c_str(), nullptr); break; case ModelNode::NODE_VECTOR_ITEM: { std::stringstream oss; oss << node->index; - g_object_set(renderer, "text", oss.str().c_str(), (char*)0); + g_object_set(renderer, "text", oss.str().c_str(), nullptr); } break; case ModelNode::NODE_ATTRIBUTE: - g_object_set(renderer, "text", node->name.c_str(), (char*)0); + g_object_set(renderer, "text", node->name.c_str(), nullptr); break; } } @@ -115,7 +114,7 @@ cell_edited_callback(GtkCellRendererText* cell, GtkTreeModel* model = GTK_TREE_MODEL(user_data); GtkTreeIter iter; gtk_tree_model_get_iter_from_string(model, &iter, path_string); - ModelNode* node = 0; + ModelNode* node = nullptr; gtk_tree_model_get(model, &iter, COL_NODE, &node, -1); if (!node) { @@ -134,8 +133,8 @@ get_col_number_from_tree_view_column(GtkTreeViewColumn* col) { GList* cols; int num; - g_return_val_if_fail(col != 0, -1); - g_return_val_if_fail(gtk_tree_view_column_get_tree_view(col) != 0, -1); + g_return_val_if_fail(col != nullptr, -1); + g_return_val_if_fail(gtk_tree_view_column_get_tree_view(col) != nullptr, -1); cols = gtk_tree_view_get_columns(GTK_TREE_VIEW(gtk_tree_view_column_get_tree_view(col))); num = g_list_index(cols, (gpointer)col); g_list_free(cols); @@ -162,18 +161,24 @@ cell_tooltip_callback(GtkWidget* widget, &y, keyboard_tip, &model, - 0, + nullptr, &iter)) { return FALSE; } - if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), x, y, 0, &column, 0, 0)) + if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), + x, + y, + nullptr, + &column, + nullptr, + nullptr)) { return FALSE; } int col = get_col_number_from_tree_view_column(column); - ModelNode* node = 0; + ModelNode* node = nullptr; gtk_tree_model_get(model, &iter, COL_NODE, &node, -1); if (!node) { @@ -264,7 +269,7 @@ create_view(GtkTreeStore* model) GtkWidget* view; view = gtk_tree_view_new(); - g_object_set(view, "has-tooltip", TRUE, (char*)0); + g_object_set(view, "has-tooltip", TRUE, nullptr); g_signal_connect(view, "query-tooltip", (GCallback)cell_tooltip_callback, 0); gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(view), GTK_TREE_VIEW_GRID_LINES_BOTH); @@ -275,8 +280,12 @@ create_view(GtkTreeStore* model) gtk_tree_view_append_column(GTK_TREE_VIEW(view), col); renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(col, renderer, TRUE); - gtk_tree_view_column_set_cell_data_func(col, renderer, cell_data_function_col_0, 0, 0); - g_object_set(renderer, "editable", FALSE, (char*)0); + gtk_tree_view_column_set_cell_data_func(col, + renderer, + cell_data_function_col_0, + nullptr, + nullptr); + g_object_set(renderer, "editable", FALSE, nullptr); col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, "Attribute Value"); @@ -284,7 +293,11 @@ create_view(GtkTreeStore* model) renderer = gtk_cell_renderer_text_new(); g_signal_connect(renderer, "edited", (GCallback)cell_edited_callback, model); gtk_tree_view_column_pack_start(col, renderer, TRUE); - gtk_tree_view_column_set_cell_data_func(col, renderer, cell_data_function_col_1, 0, 0); + gtk_tree_view_column_set_cell_data_func(col, + renderer, + cell_data_function_col_1, + nullptr, + nullptr); gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(model)); @@ -320,13 +333,13 @@ delete_event_callback(GtkWidget* widget, GdkEvent* event, gpointer user_data) gboolean clean_model_callback(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data) { - ModelNode* node = 0; + ModelNode* node = nullptr; gtk_tree_model_get(GTK_TREE_MODEL(model), iter, COL_NODE, &node, -1); if (node) { delete node; } - gtk_tree_store_set(GTK_TREE_STORE(model), iter, COL_NODE, (ModelNode*)0, -1); + gtk_tree_store_set(GTK_TREE_STORE(model), iter, COL_NODE, nullptr, -1); return FALSE; } @@ -342,7 +355,7 @@ cell_data_function_col_1_config_default(GtkTreeViewColumn* col, GtkTreeIter* iter, gpointer user_data) { - ModelTypeid* node = 0; + ModelTypeid* node = nullptr; gtk_tree_model_get(model, iter, COL_TYPEID, &node, -1); if (!node) { @@ -350,13 +363,13 @@ cell_data_function_col_1_config_default(GtkTreeViewColumn* col, } if (node->type == ModelTypeid::NODE_ATTRIBUTE) { - g_object_set(renderer, "text", node->defaultValue.c_str(), (char*)0); - g_object_set(renderer, "editable", TRUE, (char*)0); + g_object_set(renderer, "text", node->defaultValue.c_str(), nullptr); + g_object_set(renderer, "editable", TRUE, nullptr); } else { - g_object_set(renderer, "text", "", (char*)0); - g_object_set(renderer, "editable", FALSE, (char*)0); + g_object_set(renderer, "text", "", nullptr); + g_object_set(renderer, "editable", FALSE, nullptr); } } @@ -370,9 +383,9 @@ cell_data_function_col_0_config_default(GtkTreeViewColumn* col, GtkTreeIter* iter, gpointer user_data) { - ModelTypeid* node = 0; + ModelTypeid* node = nullptr; gtk_tree_model_get(model, iter, COL_NODE, &node, -1); - g_object_set(renderer, "editable", FALSE, (char*)0); + g_object_set(renderer, "editable", FALSE, nullptr); if (!node) { return; @@ -381,10 +394,10 @@ cell_data_function_col_0_config_default(GtkTreeViewColumn* col, switch (node->type) { case ModelTypeid::NODE_TYPEID: - g_object_set(renderer, "text", node->tid.GetName().c_str(), (char*)0); + g_object_set(renderer, "text", node->tid.GetName().c_str(), nullptr); break; case ModelTypeid::NODE_ATTRIBUTE: - g_object_set(renderer, "text", node->name.c_str(), (char*)0); + g_object_set(renderer, "text", node->name.c_str(), nullptr); break; } } @@ -403,7 +416,7 @@ cell_edited_callback_config_default(GtkCellRendererText* cell, GtkTreeModel* model = GTK_TREE_MODEL(user_data); GtkTreeIter iter; gtk_tree_model_get_iter_from_string(model, &iter, path_string); - ModelTypeid* node = 0; + ModelTypeid* node = nullptr; gtk_tree_model_get(model, &iter, COL_NODE, &node, -1); if (!node) { @@ -447,18 +460,24 @@ cell_tooltip_callback_config_default(GtkWidget* widget, &y, keyboard_tip, &model, - 0, + nullptr, &iter)) { return FALSE; } - if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), x, y, 0, &column, 0, 0)) + if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), + x, + y, + nullptr, + &column, + nullptr, + nullptr)) { return FALSE; } int col = get_col_number_from_tree_view_column(column); - ModelTypeid* node = 0; + ModelTypeid* node = nullptr; gtk_tree_model_get(model, &iter, COL_NODE, &node, -1); if (!node) { @@ -652,7 +671,7 @@ create_view_config_default(GtkTreeStore* model) GtkWidget* view; view = gtk_tree_view_new(); - g_object_set(view, "has-tooltip", TRUE, (char*)0); + g_object_set(view, "has-tooltip", TRUE, nullptr); g_signal_connect(view, "query-tooltip", (GCallback)cell_tooltip_callback_config_default, 0); gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(view), GTK_TREE_VIEW_GRID_LINES_BOTH); @@ -666,9 +685,9 @@ create_view_config_default(GtkTreeStore* model) gtk_tree_view_column_set_cell_data_func(col, renderer, cell_data_function_col_0_config_default, - 0, - 0); - g_object_set(renderer, "editable", FALSE, (char*)0); + nullptr, + nullptr); + g_object_set(renderer, "editable", FALSE, nullptr); col = gtk_tree_view_column_new(); gtk_tree_view_column_set_title(col, "Attribute Value"); @@ -679,8 +698,8 @@ create_view_config_default(GtkTreeStore* model) gtk_tree_view_column_set_cell_data_func(col, renderer, cell_data_function_col_1_config_default, - 0, - 0); + nullptr, + nullptr); gtk_tree_view_set_model(GTK_TREE_VIEW(view), GTK_TREE_MODEL(model)); @@ -698,13 +717,13 @@ clean_model_callback_config_default(GtkTreeModel* model, GtkTreeIter* iter, gpointer data) { - ModelTypeid* node = 0; + ModelTypeid* node = nullptr; gtk_tree_model_get(GTK_TREE_MODEL(model), iter, COL_TYPEID, &node, -1); if (node) { delete node; } - gtk_tree_store_set(GTK_TREE_STORE(model), iter, COL_TYPEID, (ModelTypeid*)0, -1); + gtk_tree_store_set(GTK_TREE_STORE(model), iter, COL_TYPEID, nullptr, -1); return FALSE; } diff --git a/src/config-store/model/display-functions.h b/src/config-store/model/display-functions.h index 3c6d27c1d..1164cd8c9 100644 --- a/src/config-store/model/display-functions.h +++ b/src/config-store/model/display-functions.h @@ -1,4 +1,3 @@ -/* -*- 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 @@ -58,10 +57,10 @@ void cell_data_function_col_0(GtkTreeViewColumn* col, /** * This is the callback called when the value of an attribute is changed * - * \param cell the changed cell - * \param path_string the path - * \param new_text the updated text in the cell - * \param user_data user data + * \param cell the changed cell + * \param path_string the path + * \param new_text the updated text in the cell + * \param user_data user data */ void cell_edited_callback(GtkCellRendererText* cell, gchar* path_string, @@ -108,7 +107,7 @@ void exit_clicked_callback(GtkButton* button, gpointer user_data); /** * Exit the application * \param widget a pointer to the widget - * \param event the event responsible for the aplication exit + * \param event the event responsible for the application exit * \param user_data user data * \returns true on clean exit */ @@ -126,7 +125,7 @@ gboolean clean_model_callback(GtkTreeModel* model, GtkTreeIter* iter, gpointer data); -// display functions used by default configurator +// display functions used by default configurator /** * This function writes data in the second column, this data is going to be editable @@ -188,14 +187,14 @@ void save_clicked_attribute(GtkButton* button, gpointer user_data); */ void load_clicked_attribute(GtkButton* button, gpointer user_data); /** - * This functions is called whenever there is a change in the value of an attribute - * If the input value is ok, it will be updated in the default value and in the - * GUI, otherwise, it won't be updated in both. + * This functions is called whenever there is a change in the value of an attribute + * If the input value is ok, it will be updated in the default value and in the + * GUI, otherwise, it won't be updated in both. * - * \param cell the changed cell - * \param path_string the path - * \param new_text the updated text in the cell - * \param user_data user data + * \param cell the changed cell + * \param path_string the path + * \param new_text the updated text in the cell + * \param user_data user data */ void cell_edited_callback_config_default(GtkCellRendererText* cell, gchar* path_string, diff --git a/src/config-store/model/file-config.cc b/src/config-store/model/file-config.cc index 23ac522ce..ec70bd54f 100644 --- a/src/config-store/model/file-config.cc +++ b/src/config-store/model/file-config.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/src/config-store/model/file-config.h b/src/config-store/model/file-config.h index 0cefd7343..b0e064dd8 100644 --- a/src/config-store/model/file-config.h +++ b/src/config-store/model/file-config.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/src/config-store/model/gtk-config-store.cc b/src/config-store/model/gtk-config-store.cc index 01a4aeddc..eb4cc37d3 100644 --- a/src/config-store/model/gtk-config-store.cc +++ b/src/config-store/model/gtk-config-store.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -36,7 +35,7 @@ GtkConfigStore::GtkConfigStore() } void -GtkConfigStore::ConfigureDefaults(void) +GtkConfigStore::ConfigureDefaults() { // this function should be called before running the script to enable the user // to configure the default values for the objects he wants to use @@ -44,7 +43,7 @@ GtkConfigStore::ConfigureDefaults(void) GtkWidget* view; GtkWidget* scroll; - gtk_init(0, 0); + gtk_init(nullptr, nullptr); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "ns-3 Default attributes."); gtk_window_set_default_size(GTK_WINDOW(window), 600, 600); @@ -55,7 +54,7 @@ GtkConfigStore::ConfigureDefaults(void) creator.Build(model); view = create_view_config_default(model); - scroll = gtk_scrolled_window_new(0, 0); + scroll = gtk_scrolled_window_new(nullptr, nullptr); gtk_container_add(GTK_CONTAINER(scroll), view); GtkWidget* vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); @@ -79,19 +78,19 @@ GtkConfigStore::ConfigureDefaults(void) gtk_main(); - gtk_tree_model_foreach(GTK_TREE_MODEL(model), clean_model_callback_config_default, 0); + gtk_tree_model_foreach(GTK_TREE_MODEL(model), clean_model_callback_config_default, nullptr); gtk_widget_destroy(window); } void -GtkConfigStore::ConfigureAttributes(void) +GtkConfigStore::ConfigureAttributes() { GtkWidget* window; GtkWidget* view; GtkWidget* scroll; - gtk_init(0, 0); + gtk_init(nullptr, nullptr); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "ns-3 Object attributes."); @@ -104,7 +103,7 @@ GtkConfigStore::ConfigureAttributes(void) creator.Build(model); view = create_view(model); - scroll = gtk_scrolled_window_new(0, 0); + scroll = gtk_scrolled_window_new(nullptr, nullptr); gtk_container_add(GTK_CONTAINER(scroll), view); GtkWidget* vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); @@ -128,7 +127,7 @@ GtkConfigStore::ConfigureAttributes(void) gtk_main(); - gtk_tree_model_foreach(GTK_TREE_MODEL(model), clean_model_callback, 0); + gtk_tree_model_foreach(GTK_TREE_MODEL(model), clean_model_callback, nullptr); gtk_widget_destroy(window); } diff --git a/src/config-store/model/gtk-config-store.h b/src/config-store/model/gtk-config-store.h index cdd03d611..45d8bb049 100644 --- a/src/config-store/model/gtk-config-store.h +++ b/src/config-store/model/gtk-config-store.h @@ -1,4 +1,3 @@ -/* -*- 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 @@ -36,11 +35,11 @@ class GtkConfigStore /** * Process default values */ - void ConfigureDefaults(void); + void ConfigureDefaults(); /** * Process attribute values */ - void ConfigureAttributes(void); + void ConfigureAttributes(); }; } // namespace ns3 diff --git a/src/config-store/model/model-node-creator.cc b/src/config-store/model/model-node-creator.cc index d3d391c53..c5df8133e 100644 --- a/src/config-store/model/model-node-creator.cc +++ b/src/config-store/model/model-node-creator.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -31,7 +30,7 @@ void ModelCreator::Build(GtkTreeStore* treestore) { m_treestore = treestore; - m_iters.push_back(0); + m_iters.push_back(nullptr); // this function will go through all the objects and call on them // DoStartVisitObject, DoIterate and DoEndVisitObject Iterate(); @@ -49,7 +48,7 @@ ModelCreator::Add(ModelNode* node) } void -ModelCreator::Remove(void) +ModelCreator::Remove() { GtkTreeIter* iter = m_iters.back(); g_free(iter); @@ -77,7 +76,7 @@ ModelCreator::DoStartVisitObject(Ptr object) } void -ModelCreator::DoEndVisitObject(void) +ModelCreator::DoEndVisitObject() { Remove(); } @@ -93,7 +92,7 @@ ModelCreator::DoStartVisitPointerAttribute(Ptr object, std::string name, } void -ModelCreator::DoEndVisitPointerAttribute(void) +ModelCreator::DoEndVisitPointerAttribute() { Remove(); } @@ -111,7 +110,7 @@ ModelCreator::DoStartVisitArrayAttribute(Ptr object, } void -ModelCreator::DoEndVisitArrayAttribute(void) +ModelCreator::DoEndVisitArrayAttribute() { Remove(); } @@ -133,7 +132,7 @@ ModelCreator::DoStartVisitArrayItem(const ObjectPtrContainerValue& vector, } void -ModelCreator::DoEndVisitArrayItem(void) +ModelCreator::DoEndVisitArrayItem() { GtkTreeIter* iter = m_iters.back(); g_free(iter); diff --git a/src/config-store/model/model-node-creator.h b/src/config-store/model/model-node-creator.h index c2ac1aa48..c8e5b04d0 100644 --- a/src/config-store/model/model-node-creator.h +++ b/src/config-store/model/model-node-creator.h @@ -1,4 +1,3 @@ -/* -*- 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 @@ -77,28 +76,28 @@ class ModelCreator : public AttributeIterator void Build(GtkTreeStore* treestore); private: - virtual void DoVisitAttribute(Ptr object, std::string name); - virtual void DoStartVisitObject(Ptr object); - virtual void DoEndVisitObject(void); - virtual void DoStartVisitPointerAttribute(Ptr object, - std::string name, - Ptr value); - virtual void DoEndVisitPointerAttribute(void); - virtual void DoStartVisitArrayAttribute(Ptr object, - std::string name, - const ObjectPtrContainerValue& vector); - virtual void DoEndVisitArrayAttribute(void); - virtual void DoStartVisitArrayItem(const ObjectPtrContainerValue& vector, - uint32_t index, - Ptr item); - virtual void DoEndVisitArrayItem(void); + void DoVisitAttribute(Ptr object, std::string name) override; + void DoStartVisitObject(Ptr object) override; + void DoEndVisitObject() override; + void DoStartVisitPointerAttribute(Ptr object, + std::string name, + Ptr value) override; + void DoEndVisitPointerAttribute() override; + void DoStartVisitArrayAttribute(Ptr object, + std::string name, + const ObjectPtrContainerValue& vector) override; + void DoEndVisitArrayAttribute() override; + void DoStartVisitArrayItem(const ObjectPtrContainerValue& vector, + uint32_t index, + Ptr item) override; + void DoEndVisitArrayItem() override; /** * Add item to attribute tree * \param node The model node */ void Add(ModelNode* node); /// Remove current tree item - void Remove(void); + void Remove(); GtkTreeStore* m_treestore; ///< attribute tree std::vector m_iters; ///< attribute tree item diff --git a/src/config-store/model/model-typeid-creator.cc b/src/config-store/model/model-typeid-creator.cc index c3333503d..fd360eb99 100644 --- a/src/config-store/model/model-typeid-creator.cc +++ b/src/config-store/model/model-typeid-creator.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -30,7 +29,7 @@ void ModelTypeidCreator::Build(GtkTreeStore* treestore) { m_treestore = treestore; - m_iters.push_back(0); + m_iters.push_back(nullptr); Iterate(); NS_ASSERT(m_iters.size() == 1); } @@ -46,7 +45,7 @@ ModelTypeidCreator::Add(ModelTypeid* node) } void -ModelTypeidCreator::Remove(void) +ModelTypeidCreator::Remove() { GtkTreeIter* iter = m_iters.back(); g_free(iter); @@ -79,7 +78,7 @@ ModelTypeidCreator::StartVisitTypeId(std::string name) } void -ModelTypeidCreator::EndVisitTypeId(void) +ModelTypeidCreator::EndVisitTypeId() { Remove(); } diff --git a/src/config-store/model/model-typeid-creator.h b/src/config-store/model/model-typeid-creator.h index 7457d3d93..007680dd0 100644 --- a/src/config-store/model/model-typeid-creator.h +++ b/src/config-store/model/model-typeid-creator.h @@ -1,4 +1,3 @@ -/* -*- 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 @@ -84,19 +83,19 @@ class ModelTypeidCreator : public AttributeDefaultIterator * \param defaultValue default value * \param index index of the attribute in the specified Typeid */ - virtual void VisitAttribute(TypeId tid, - std::string name, - std::string defaultValue, - uint32_t index); + void VisitAttribute(TypeId tid, + std::string name, + std::string defaultValue, + uint32_t index) override; /** * \brief Add a node for the new TypeId object * \param name TypeId name */ - virtual void StartVisitTypeId(std::string name); + void StartVisitTypeId(std::string name) override; /** * \brief Remove the last gtk tree iterator */ - virtual void EndVisitTypeId(void); + void EndVisitTypeId() override; /** * \brief Adds a treestore iterator to m_treestore model * \param node the node to be added @@ -105,7 +104,7 @@ class ModelTypeidCreator : public AttributeDefaultIterator /** * Removes the last GtkTreeIterator from m_iters */ - void Remove(void); + void Remove(); /// this is the TreeStore model corresponding to the view GtkTreeStore* m_treestore; /// This contains a vector of iterators used to build the TreeStore diff --git a/src/config-store/model/raw-text-config.cc b/src/config-store/model/raw-text-config.cc index 7b83aa970..4c8d90ca6 100644 --- a/src/config-store/model/raw-text-config.cc +++ b/src/config-store/model/raw-text-config.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * @@ -60,7 +59,7 @@ RawTextConfigSave::SetFilename(std::string filename) { NS_LOG_FUNCTION(this << filename); m_os = new std::ofstream(); - m_os->open(filename.c_str(), std::ios::out); + m_os->open(filename, std::ios::out); } void @@ -227,7 +226,7 @@ RawTextConfigLoad::SetFilename(std::string filename) { NS_LOG_FUNCTION(this << filename); m_is = new std::ifstream(); - m_is->open(filename.c_str(), std::ios::in); + m_is->open(filename, std::ios::in); } std::string diff --git a/src/config-store/model/raw-text-config.h b/src/config-store/model/raw-text-config.h index 2720e09cc..7dc2a4218 100644 --- a/src/config-store/model/raw-text-config.h +++ b/src/config-store/model/raw-text-config.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/src/config-store/model/xml-config.cc b/src/config-store/model/xml-config.cc index 2ea3d460b..bbc7abf3f 100644 --- a/src/config-store/model/xml-config.cc +++ b/src/config-store/model/xml-config.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/src/config-store/model/xml-config.h b/src/config-store/model/xml-config.h index f8bfeed07..8b9703042 100644 --- a/src/config-store/model/xml-config.h +++ b/src/config-store/model/xml-config.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 2cf6aa45a..8ca8c15de 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -123,9 +123,25 @@ if(${ENABLE_BUILD_VERSION}) ) endif() +if(WIN32) + set(libraries_to_link + ${libraries_to_link} + wsock32 + ws2_32 + ) + set(fd-reader-sources + model/win32-fd-reader.cc + ) +else() + set(fd-reader-sources + model/unix-fd-reader.cc + ) +endif() + # Define core lib sources set(source_files ${int64x64_sources} + ${fd-reader-sources} ${example_as_test_sources} ${embedded_version_sources} helper/csv-reader.cc @@ -191,7 +207,6 @@ set(source_files model/system-wall-clock-timestamp.cc model/length.cc model/trickle-timer.cc - model/unix-fd-reader.cc model/realtime-simulator-impl.cc model/wall-clock-synchronizer.cc ) @@ -231,6 +246,7 @@ set(header_files model/event-impl.h model/fatal-error.h model/fatal-impl.h + model/fd-reader.h model/global-value.h model/hash-fnv.h model/hash-function.h @@ -291,7 +307,6 @@ set(header_files model/type-name.h model/type-traits.h model/uinteger.h - model/unix-fd-reader.h model/unused.h model/valgrind.h model/vector.h diff --git a/src/core/doc/core.h b/src/core/doc/core.h index 84bac299a..f4ed96e7f 100644 --- a/src/core/doc/core.h +++ b/src/core/doc/core.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2017 Peter D. Barnes, Jr. * diff --git a/src/core/doc/deprecated-example.h b/src/core/doc/deprecated-example.h index 334790c19..b4becf2bf 100644 --- a/src/core/doc/deprecated-example.h +++ b/src/core/doc/deprecated-example.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 Lawrence Livermore National Laboratory * diff --git a/src/core/examples/build-version-example.cc b/src/core/examples/build-version-example.cc index 66e6a7b14..6426eb839 100644 --- a/src/core/examples/build-version-example.cc +++ b/src/core/examples/build-version-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2018 Lawrence Livermore National Laboratory * diff --git a/src/core/examples/command-line-example.cc b/src/core/examples/command-line-example.cc index d7b7c60fc..61e0f7c6a 100644 --- a/src/core/examples/command-line-example.cc +++ b/src/core/examples/command-line-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2013 Lawrence Livermore National Laboratory * @@ -58,16 +57,36 @@ SetCbArg(std::string val) } // unnamed namespace +/** + * Print a row containing the name, the default + * and the final values of an argument. + * + * \param [in] label The argument label. + * \param [in] defaultValue The default value of the argument. + * \param [in] finalValue The final value of the argument. + * + */ +#define DefaultFinal(label, defaultValue, finalValue) \ + std::left << std::setw(20) << label + std::string(":") << std::setw(20) << defaultValue \ + << finalValue << "\n" + int main(int argc, char* argv[]) { + // Plain old data options int intArg = 1; bool boolArg = false; std::string strArg = "strArg default"; - // Attribute path + + // Attribute path option const std::string attrClass = "ns3::RandomVariableStream"; const std::string attrName = "Antithetic"; const std::string attrPath = attrClass + "::" + attrName; + + // char* buffer option + constexpr int CHARBUF_SIZE = 10; + char charbuf[CHARBUF_SIZE] = "charstar"; + // Non-option arguments int nonOpt1 = 1; int nonOpt2 = 1; @@ -86,6 +105,7 @@ main(int argc, char* argv[]) tid.LookupAttributeByName(attrName, &info); attrDef = info.originalInitialValue->SerializeToString(info.checker); } + const std::string charbufDef{charbuf}; const int nonOpt1Def = nonOpt1; const int nonOpt2Def = nonOpt2; @@ -98,11 +118,12 @@ main(int argc, char* argv[]) cmd.AddValue("strArg", "a string argument", strArg); cmd.AddValue("anti", attrPath); cmd.AddValue("cbArg", "a string via callback", MakeCallback(SetCbArg)); + cmd.AddValue("charbuf", "a char* buffer", charbuf, CHARBUF_SIZE); cmd.AddNonOption("nonOpt1", "first non-option", nonOpt1); cmd.AddNonOption("nonOpt2", "second non-option", nonOpt2); cmd.Parse(argc, argv); - // Show initial values: + // Show what happened std::cout << std::endl; std::cout << cmd.GetName() << ":" << std::endl; @@ -111,52 +132,43 @@ main(int argc, char* argv[]) cmd.PrintVersion(std::cout); std::cout << std::endl; - std::cout << "Initial values:" << std::endl; + std::cout << "Argument Initial Value Final Value\n" + << std::left << std::boolalpha; - std::cout << std::left << std::setw(10) << "intArg:" << intDef << std::endl; - std::cout << std::setw(10) << "boolArg:" << std::boolalpha << boolDef << std::noboolalpha - << std::endl; - - std::cout << std::setw(10) << "strArg:" - << "\"" << strDef << "\"" << std::endl; - std::cout << std::setw(10) << "anti:" - << "\"" << attrDef << "\"" << std::endl; - std::cout << std::setw(10) << "cbArg:" - << "\"" << cbDef << "\"" << std::endl; - std::cout << std::left << std::setw(10) << "nonOpt1:" << nonOpt1Def << std::endl; - std::cout << std::left << std::setw(10) << "nonOpt2:" << nonOpt2Def << std::endl; - std::cout << std::endl; - - // Show final values - std::cout << "Final values:" << std::endl; - std::cout << std::left << std::setw(10) << "intArg:" << intArg << std::endl; - std::cout << std::setw(10) << "boolArg:" << std::boolalpha << boolArg << std::noboolalpha - << std::endl; - - std::cout << std::setw(10) << "strArg:" - << "\"" << strArg << "\"" << std::endl; + std::cout << DefaultFinal("intArg", intDef, intArg) // + << DefaultFinal("boolArg", + (boolDef ? "true" : "false"), + (boolArg ? "true" : "false")) // + << DefaultFinal("strArg", "\"" + strDef + "\"", "\"" + strArg + "\""); // Look up new default value for attribute + std::string antiArg; { struct TypeId::AttributeInformation info; tid.LookupAttributeByName(attrName, &info); - - std::cout << std::setw(10) << "anti:" - << "\"" << info.initialValue->SerializeToString(info.checker) << "\"" - << std::endl; + antiArg = info.initialValue->SerializeToString(info.checker); } - std::cout << std::setw(10) << "cbArg:" - << "\"" << g_cbArg << "\"" << std::endl; - std::cout << std::left << std::setw(10) << "nonOpt1:" << nonOpt1 << std::endl; - std::cout << std::left << std::setw(10) << "nonOpt2:" << nonOpt2 << std::endl; - std::cout << std::left << "Number of extra non-option arguments:" << cmd.GetNExtraNonOptions() - << std::endl; + + std::cout << DefaultFinal("anti", "\"" + attrDef + "\"", "\"" + antiArg + "\"") + << DefaultFinal("cbArg", cbDef, g_cbArg) + << DefaultFinal("charbuf", + "\"" + charbufDef + "\"", + "\"" + std::string(charbuf) + "\"") + << DefaultFinal("nonOpt1", nonOpt1Def, nonOpt1) + << DefaultFinal("nonOpt2", nonOpt2Def, nonOpt2) << std::endl; + + std::cout << std::setw(40) + << "Number of extra non-option arguments:" << cmd.GetNExtraNonOptions() << std::endl; for (std::size_t i = 0; i < cmd.GetNExtraNonOptions(); ++i) { - std::cout << std::left << std::setw(10) << "extra:" - << "\"" << cmd.GetExtraNonOption(i) << "\"" << std::endl; + std::cout << DefaultFinal("extra non-option " + std::to_string(i), + "", + "\"" + cmd.GetExtraNonOption(i) + "\""); } + std::cout << std::endl; + +#undef DefaultFinal return 0; } diff --git a/src/core/examples/empirical-random-variable-example.cc b/src/core/examples/empirical-random-variable-example.cc index 003899727..4de4f777f 100644 --- a/src/core/examples/empirical-random-variable-example.cc +++ b/src/core/examples/empirical-random-variable-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 Lawrence Livermore National Laboratory * diff --git a/src/core/examples/fatal-example.cc b/src/core/examples/fatal-example.cc index 6a0eebc2b..9cf5bfe49 100644 --- a/src/core/examples/fatal-example.cc +++ b/src/core/examples/fatal-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 Lawrence Livermore National Laboratory * diff --git a/src/core/examples/hash-example.cc b/src/core/examples/hash-example.cc index 4f6405f0e..c3a3420e5 100644 --- a/src/core/examples/hash-example.cc +++ b/src/core/examples/hash-example.cc @@ -1,4 +1,3 @@ -/* -*- 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 @@ -476,7 +475,7 @@ class DictFiles // Open the file std::ifstream dictStream; - dictStream.open(dictFile.c_str()); + dictStream.open(dictFile); if (!dictStream.is_open()) { std::cerr << "Failed to open dictionary file." diff --git a/src/core/examples/length-example.cc b/src/core/examples/length-example.cc index c85948272..c6a2b9282 100644 --- a/src/core/examples/length-example.cc +++ b/src/core/examples/length-example.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2019 Lawrence Livermore National Laboratory * diff --git a/src/core/examples/main-callback.cc b/src/core/examples/main-callback.cc index 88093316b..ad4d6969e 100644 --- a/src/core/examples/main-callback.cc +++ b/src/core/examples/main-callback.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2006 INRIA * diff --git a/src/core/examples/main-ptr.cc b/src/core/examples/main-ptr.cc index 3322122e5..f1e8fd630 100644 --- a/src/core/examples/main-ptr.cc +++ b/src/core/examples/main-ptr.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2006 INRIA * diff --git a/src/core/examples/main-random-variable-stream.cc b/src/core/examples/main-random-variable-stream.cc index 92948440a..b0455524d 100644 --- a/src/core/examples/main-random-variable-stream.cc +++ b/src/core/examples/main-random-variable-stream.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 Timo Bingmann * diff --git a/src/core/examples/main-test-sync.cc b/src/core/examples/main-test-sync.cc index d395a534a..b1fc37e6b 100644 --- a/src/core/examples/main-test-sync.cc +++ b/src/core/examples/main-test-sync.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 University of Washington * diff --git a/src/core/examples/sample-log-time-format.cc b/src/core/examples/sample-log-time-format.cc index 98ac49b68..e63e7847a 100644 --- a/src/core/examples/sample-log-time-format.cc +++ b/src/core/examples/sample-log-time-format.cc @@ -1,4 +1,3 @@ -/* -*- 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/src/core/examples/sample-random-variable-stream.cc b/src/core/examples/sample-random-variable-stream.cc index 2a9a2272f..46f22ed98 100644 --- a/src/core/examples/sample-random-variable-stream.cc +++ b/src/core/examples/sample-random-variable-stream.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2012 University of Washington * diff --git a/src/core/examples/sample-random-variable.cc b/src/core/examples/sample-random-variable.cc index 514be265c..6854fdbbc 100644 --- a/src/core/examples/sample-random-variable.cc +++ b/src/core/examples/sample-random-variable.cc @@ -1,4 +1,3 @@ -/* -*- 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/src/core/examples/sample-show-progress.cc b/src/core/examples/sample-show-progress.cc index 627ed1d0d..811481307 100644 --- a/src/core/examples/sample-show-progress.cc +++ b/src/core/examples/sample-show-progress.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2017 Lawrence Livermore National Laboratory * diff --git a/src/core/examples/sample-simulator.cc b/src/core/examples/sample-simulator.cc index 6433ac95e..dc5ac0c67 100644 --- a/src/core/examples/sample-simulator.cc +++ b/src/core/examples/sample-simulator.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2010 INRIA * diff --git a/src/core/examples/sample-simulator.py b/src/core/examples/sample-simulator.py index 551e87c92..58f2650d2 100755 --- a/src/core/examples/sample-simulator.py +++ b/src/core/examples/sample-simulator.py @@ -103,14 +103,14 @@ ns.cppyy.cppdef(""" """) -def main(dummy_argv): - cmd = ns.getCommandLine(__file__) - cmd.Parse(dummy_argv) +def main(argv): + cmd = ns.CommandLine(__file__) + cmd.Parse(argv) model = ns.cppyy.gbl.MyModel() v = ns.CreateObject("UniformRandomVariable") - v.SetAttribute("Min", ns.core.DoubleValue (10)) - v.SetAttribute("Max", ns.core.DoubleValue (20)) + v.SetAttribute("Min", ns.core.DoubleValue(10)) + v.SetAttribute("Max", ns.core.DoubleValue(20)) ev = ns.cppyy.gbl.ExampleFunctionEvent(model) ns.core.Simulator.Schedule(ns.core.Seconds(10.0), ev) diff --git a/src/core/examples/system-path-examples.cc b/src/core/examples/system-path-examples.cc index 54be3bea7..7e52f10da 100644 --- a/src/core/examples/system-path-examples.cc +++ b/src/core/examples/system-path-examples.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2020 Lawrence Livermore National Laboratory * diff --git a/src/core/examples/test-string-value-formatting.cc b/src/core/examples/test-string-value-formatting.cc index 1b5c34cbc..0379e4f06 100644 --- a/src/core/examples/test-string-value-formatting.cc +++ b/src/core/examples/test-string-value-formatting.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2016 Tom Henderson * diff --git a/src/core/helper/csv-reader.cc b/src/core/helper/csv-reader.cc index caf00d8d6..084ecfbdf 100644 --- a/src/core/helper/csv-reader.cc +++ b/src/core/helper/csv-reader.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2019 Lawrence Livermore National Laboratory * diff --git a/src/core/helper/csv-reader.h b/src/core/helper/csv-reader.h index afdc0a4e4..bb8ecef74 100644 --- a/src/core/helper/csv-reader.h +++ b/src/core/helper/csv-reader.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2019 Lawrence Livermore National Laboratory * diff --git a/src/core/helper/event-garbage-collector.cc b/src/core/helper/event-garbage-collector.cc index 771c4ec70..8fa0d8100 100644 --- a/src/core/helper/event-garbage-collector.cc +++ b/src/core/helper/event-garbage-collector.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007 INESC Porto * diff --git a/src/core/helper/event-garbage-collector.h b/src/core/helper/event-garbage-collector.h index 76da3948e..c336d66d1 100644 --- a/src/core/helper/event-garbage-collector.h +++ b/src/core/helper/event-garbage-collector.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2007 INESC Porto * diff --git a/src/core/helper/random-variable-stream-helper.cc b/src/core/helper/random-variable-stream-helper.cc index 2b57a3b10..e174ba6a4 100644 --- a/src/core/helper/random-variable-stream-helper.cc +++ b/src/core/helper/random-variable-stream-helper.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2012 University of Washington * diff --git a/src/core/helper/random-variable-stream-helper.h b/src/core/helper/random-variable-stream-helper.h index 2081cb913..51bb1a010 100644 --- a/src/core/helper/random-variable-stream-helper.h +++ b/src/core/helper/random-variable-stream-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2012 University of Washington * diff --git a/src/core/model/abort.h b/src/core/model/abort.h index ed4078d29..cd22e48f7 100644 --- a/src/core/model/abort.h +++ b/src/core/model/abort.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA, 2010 NICTA * diff --git a/src/core/model/ascii-file.cc b/src/core/model/ascii-file.cc index 8b940dbd9..98d4e813b 100644 --- a/src/core/model/ascii-file.cc +++ b/src/core/model/ascii-file.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2012 University of Washington * @@ -72,7 +71,7 @@ AsciiFile::Open(const std::string& filename, std::ios::openmode mode) NS_ASSERT((mode & std::ios::app) == 0); NS_ASSERT(!m_file.fail()); - m_file.open(filename.c_str(), mode); + m_file.open(filename, mode); } void diff --git a/src/core/model/ascii-file.h b/src/core/model/ascii-file.h index cc657cd8b..a0f74656b 100644 --- a/src/core/model/ascii-file.h +++ b/src/core/model/ascii-file.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2012 University of Washington * diff --git a/src/core/model/ascii-test.h b/src/core/model/ascii-test.h index 3f7b5ac70..6e313f387 100644 --- a/src/core/model/ascii-test.h +++ b/src/core/model/ascii-test.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2012 University of Washington * diff --git a/src/core/model/assert.h b/src/core/model/assert.h index 8e37b6b18..4902412e9 100644 --- a/src/core/model/assert.h +++ b/src/core/model/assert.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2006 INRIA, 2010 NICTA * diff --git a/src/core/model/attribute-accessor-helper.h b/src/core/model/attribute-accessor-helper.h index fb673b1f9..1beccfbc5 100644 --- a/src/core/model/attribute-accessor-helper.h +++ b/src/core/model/attribute-accessor-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * @@ -39,7 +38,7 @@ namespace ns3 * * The get functor method should have a signature like * \code - * typedef U (T::*getter)(void) const + * typedef U (T::*getter)() const * \endcode * where \pname{T} is the class and \pname{U} is the type of * the return value. @@ -77,7 +76,7 @@ inline Ptr MakeAccessorHelper(T1 a1); * * The get functor method should have a signature like * \code - * typedef U (T::*getter)(void) const + * typedef U (T::*getter)() const * \endcode * where \pname{T} is the class and \pname{U} is the type of * the return value. @@ -328,7 +327,7 @@ DoMakeAccessorHelperOne(U (T::*getter)() const) } private: - bool DoSet([[maybe_unused]] T* object, [[maybe_unused]] const V* v) const override + bool DoSet(T* /* object */, const V* /* v */) const override { return false; } @@ -399,7 +398,7 @@ DoMakeAccessorHelperOne(void (T::*setter)(U)) return true; } - bool DoGet([[maybe_unused]] const T* object, [[maybe_unused]] V* v) const override + bool DoGet(const T* /* object */, V* /* v */) const override { return false; } diff --git a/src/core/model/attribute-construction-list.cc b/src/core/model/attribute-construction-list.cc index 1821ee9d7..87f0e51c7 100644 --- a/src/core/model/attribute-construction-list.cc +++ b/src/core/model/attribute-construction-list.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Mathieu Lacage * diff --git a/src/core/model/attribute-construction-list.h b/src/core/model/attribute-construction-list.h index c2c762e6e..43debec8c 100644 --- a/src/core/model/attribute-construction-list.h +++ b/src/core/model/attribute-construction-list.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2011 Mathieu Lacage * diff --git a/src/core/model/attribute-container.h b/src/core/model/attribute-container.h index 6b0c7a5eb..08ffdccfc 100644 --- a/src/core/model/attribute-container.h +++ b/src/core/model/attribute-container.h @@ -1,4 +1,3 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2018 Caliola Engineering, LLC. * diff --git a/src/core/model/attribute-helper.h b/src/core/model/attribute-helper.h index f8c4617d5..a0f453bba 100644 --- a/src/core/model/attribute-helper.h +++ b/src/core/model/attribute-helper.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * @@ -74,7 +73,7 @@ namespace ns3 * * There are three versions of DoMakeAccessorHelperOne: * - With a member variable: DoMakeAccessorHelperOne(U T::*) - * - With a class get functor: DoMakeAccessorHelperOne(U(T::*)(void) const) + * - With a class get functor: DoMakeAccessorHelperOne(U(T::*)() const) * - With a class set method: DoMakeAccessorHelperOne(void(T::*)(U)) * * There are two pairs of DoMakeAccessorHelperTwo (four total): @@ -203,17 +202,17 @@ MakeSimpleAttributeChecker(std::string name, std::string underlying) name##Value(); \ name##Value(const type& value); \ void Set(const type& value); \ - type Get(void) const; \ + type Get() const; \ template \ bool GetAccessor(T& value) const \ { \ value = T(m_value); \ return true; \ } \ - virtual Ptr Copy(void) const; \ - virtual std::string SerializeToString(Ptr checker) const; \ - virtual bool DeserializeFromString(std::string value, \ - Ptr checker); \ + Ptr Copy() const override; \ + std::string SerializeToString(Ptr checker) const override; \ + bool DeserializeFromString(std::string value, \ + Ptr checker) override; \ \ private: \ type m_value; \ @@ -269,7 +268,7 @@ MakeSimpleAttributeChecker(std::string name, std::string underlying) class type##Checker : public AttributeChecker \ { \ }; \ - Ptr Make##type##Checker(void) + Ptr Make##type##Checker() /** * \ingroup attributehelper @@ -300,11 +299,11 @@ MakeSimpleAttributeChecker(std::string name, std::string underlying) { \ m_value = v; \ } \ - type name##Value::Get(void) const \ + type name##Value::Get() const \ { \ return m_value; \ } \ - Ptr name##Value::Copy(void) const \ + Ptr name##Value::Copy() const \ { \ return ns3::Create(*this); \ } \ @@ -355,7 +354,7 @@ MakeSimpleAttributeChecker(std::string name, std::string underlying) * Typically invoked in the source file.. */ #define ATTRIBUTE_CHECKER_IMPLEMENT(type) \ - Ptr Make##type##Checker(void) \ + Ptr Make##type##Checker() \ { \ return MakeSimpleAttributeChecker(#type "Value", #type); \ } @@ -374,7 +373,7 @@ MakeSimpleAttributeChecker(std::string name, std::string underlying) * Typically invoked in the source file.. */ #define ATTRIBUTE_CHECKER_IMPLEMENT_WITH_NAME(type, name) \ - Ptr Make##type##Checker(void) \ + Ptr Make##type##Checker() \ { \ return MakeSimpleAttributeChecker(#type "Value", name); \ } diff --git a/src/core/model/attribute.cc b/src/core/model/attribute.cc index dc1ffa036..88f21f66d 100644 --- a/src/core/model/attribute.cc +++ b/src/core/model/attribute.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * @@ -126,18 +125,16 @@ EmptyAttributeAccessor::~EmptyAttributeAccessor() } bool -EmptyAttributeAccessor::Set(ObjectBase* object, const AttributeValue& value) const +EmptyAttributeAccessor::Set(ObjectBase* object [[maybe_unused]], + const AttributeValue& value [[maybe_unused]]) const { - (void)object; - (void)value; return true; } bool -EmptyAttributeAccessor::Get(const ObjectBase* object, AttributeValue& attribute) const +EmptyAttributeAccessor::Get(const ObjectBase* object [[maybe_unused]], + AttributeValue& attribute [[maybe_unused]]) const { - (void)object; - (void)attribute; return true; } @@ -163,9 +160,8 @@ EmptyAttributeChecker::~EmptyAttributeChecker() } bool -EmptyAttributeChecker::Check(const AttributeValue& value) const +EmptyAttributeChecker::Check(const AttributeValue& value [[maybe_unused]]) const { - (void)value; return true; } @@ -195,10 +191,9 @@ EmptyAttributeChecker::Create() const } bool -EmptyAttributeChecker::Copy(const AttributeValue& source, AttributeValue& destination) const +EmptyAttributeChecker::Copy(const AttributeValue& source [[maybe_unused]], + AttributeValue& destination [[maybe_unused]]) const { - (void)source; - (void)destination; return true; } diff --git a/src/core/model/attribute.h b/src/core/model/attribute.h index ac55d1d47..f94f22a1c 100644 --- a/src/core/model/attribute.h +++ b/src/core/model/attribute.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/core/model/boolean.cc b/src/core/model/boolean.cc index dc6fa5fac..f7c2a0697 100644 --- a/src/core/model/boolean.cc +++ b/src/core/model/boolean.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/core/model/boolean.h b/src/core/model/boolean.h index 69383fd43..8e010b009 100644 --- a/src/core/model/boolean.h +++ b/src/core/model/boolean.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * diff --git a/src/core/model/breakpoint.cc b/src/core/model/breakpoint.cc index cf395b031..4ae8637fb 100644 --- a/src/core/model/breakpoint.cc +++ b/src/core/model/breakpoint.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2006,2007 INRIA, INESC Porto * @@ -52,17 +51,17 @@ BreakpointFallback() #else void -BreakpointFallback(void) +BreakpointFallback() { NS_LOG_FUNCTION_NOARGS(); - int* a = 0; + int* a = nullptr; /** * we test here to allow a debugger to change the value of * the variable 'a' to allow the debugger to avoid the * subsequent segfault. */ - if (a == 0) + if (a == nullptr) { *a = 0; } diff --git a/src/core/model/breakpoint.h b/src/core/model/breakpoint.h index 6371090d6..8593038cd 100644 --- a/src/core/model/breakpoint.h +++ b/src/core/model/breakpoint.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2006,2007 INESC Porto, INRIA * diff --git a/src/core/model/build-profile.h b/src/core/model/build-profile.h index fa79dc863..5a3994726 100644 --- a/src/core/model/build-profile.h +++ b/src/core/model/build-profile.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2015 LLNL * diff --git a/src/core/model/cairo-wideint-private.h b/src/core/model/cairo-wideint-private.h index 16e394dd3..9dbc1e3b2 100644 --- a/src/core/model/cairo-wideint-private.h +++ b/src/core/model/cairo-wideint-private.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* cairo - a vector graphics library with display and print output * * Copyright © 2004 Keith Packard @@ -26,10 +25,13 @@ * The Initial Developer of the Original Code is Keith Packard * * Contributor(s): - * Keith R. Packard + * Keith R. Packard * */ +// NOLINTBEGIN +// clang-format off + #ifndef CAIRO_WIDEINT_H #define CAIRO_WIDEINT_H @@ -49,9 +51,6 @@ // extern const char * cairo_impl64; // extern const char * cairo_impl128; -// NOLINTBEGIN -// clang-format off - /*for compatibility with MacOS and Cygwin*/ #ifndef HAVE_STDINT_H #ifdef __APPLE__ @@ -361,7 +360,7 @@ _cairo_int_96by64_32x64_divrem (cairo_int128_t num, }; #endif - // clang-format on - // NOLINTEND - #endif /* CAIRO_WIDEINT_H */ + +// clang-format on +// NOLINTEND diff --git a/src/core/model/cairo-wideint.c b/src/core/model/cairo-wideint.c index d1fd963fe..893112f32 100644 --- a/src/core/model/cairo-wideint.c +++ b/src/core/model/cairo-wideint.c @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* cairo - a vector graphics library with display and print output * * Copyright © 2004 Keith Packard @@ -26,11 +25,14 @@ * The Initial Developer of the Original Code is Keith Packard * * Contributor(s): - * Keith R. Packard + * Keith R. Packard * * Code changes for ns-3 from upstream are marked with `//PDB' */ +// NOLINTBEGIN +// clang-format off + #include "cairo-wideint-private.h" #include @@ -41,9 +43,6 @@ * Implementation of the cairo_x functions which implement high precision arithmetic. */ -// NOLINTBEGIN -// clang-format off - #if HAVE_UINT64_T const char * cairo_impl64 = "uint64_t"; @@ -53,7 +52,7 @@ const char * cairo_impl64 = "uint64_t"; cairo_uquorem64_t _cairo_uint64_divrem (cairo_uint64_t num, cairo_uint64_t den) { - cairo_uquorem64_t qr; + cairo_uquorem64_t qr; qr.quo = num / den; qr.rem = num % den; @@ -67,7 +66,7 @@ const char * cairo_impl64 = "uint32_t"; cairo_uint64_t _cairo_uint32_to_uint64 (uint32_t i) { - cairo_uint64_t q; + cairo_uint64_t q; q.lo = i; q.hi = 0; @@ -77,7 +76,7 @@ _cairo_uint32_to_uint64 (uint32_t i) cairo_int64_t _cairo_int32_to_int64 (int32_t i) { - cairo_uint64_t q; + cairo_uint64_t q; q.lo = i; q.hi = i < 0 ? -1 : 0; @@ -87,7 +86,7 @@ _cairo_int32_to_int64 (int32_t i) static cairo_uint64_t _cairo_uint32s_to_uint64 (uint32_t h, uint32_t l) { - cairo_uint64_t q; + cairo_uint64_t q; q.lo = l; q.hi = h; @@ -97,38 +96,38 @@ _cairo_uint32s_to_uint64 (uint32_t h, uint32_t l) cairo_uint64_t _cairo_uint64_add (cairo_uint64_t a, cairo_uint64_t b) { - cairo_uint64_t s; + cairo_uint64_t s; s.hi = a.hi + b.hi; s.lo = a.lo + b.lo; if (s.lo < a.lo) - s.hi++; + s.hi++; return s; } cairo_uint64_t _cairo_uint64_sub (cairo_uint64_t a, cairo_uint64_t b) { - cairo_uint64_t s; + cairo_uint64_t s; s.hi = a.hi - b.hi; s.lo = a.lo - b.lo; if (s.lo > a.lo) - s.hi--; + s.hi--; return s; } -#define uint32_lo(i) ((i) & 0xffff) -#define uint32_hi(i) ((i) >> 16) -#define uint32_carry16 ((1) << 16) +#define uint32_lo(i) ((i) & 0xffff) +#define uint32_hi(i) ((i) >> 16) +#define uint32_carry16 ((1) << 16) cairo_uint64_t _cairo_uint32x32_64_mul (uint32_t a, uint32_t b) { cairo_uint64_t s; - uint16_t ah, al, bh, bl; - uint32_t r0, r1, r2, r3; + uint16_t ah, al, bh, bl; + uint32_t r0, r1, r2, r3; al = uint32_lo (a); ah = uint32_hi (a); @@ -141,9 +140,9 @@ _cairo_uint32x32_64_mul (uint32_t a, uint32_t b) r3 = (uint32_t) ah * bh; r1 += uint32_hi(r0); /* no carry possible */ - r1 += r2; /* but this can carry */ - if (r1 < r2) /* check */ - r3 += uint32_carry16; + r1 += r2; /* but this can carry */ + if (r1 < r2) /* check */ + r3 += uint32_carry16; s.hi = r3 + uint32_hi(r1); s.lo = (uint32_lo (r1) << 16) + uint32_lo (r0); @@ -156,16 +155,16 @@ _cairo_int32x32_64_mul (int32_t a, int32_t b) cairo_int64_t s; s = _cairo_uint32x32_64_mul ((uint32_t) a, (uint32_t) b); if (a < 0) - s.hi -= b; + s.hi -= b; if (b < 0) - s.hi -= a; + s.hi -= a; return s; } cairo_uint64_t _cairo_uint64_mul (cairo_uint64_t a, cairo_uint64_t b) { - cairo_uint64_t s; + cairo_uint64_t s; s = _cairo_uint32x32_64_mul (a.lo, b.lo); s.hi += a.lo * b.hi + a.hi * b.lo; @@ -177,14 +176,14 @@ _cairo_uint64_lsl (cairo_uint64_t a, int shift) { if (shift >= 32) { - a.hi = a.lo; - a.lo = 0; - shift -= 32; + a.hi = a.lo; + a.lo = 0; + shift -= 32; } if (shift) { - a.hi = a.hi << shift | a.lo >> (32 - shift); - a.lo = a.lo << shift; + a.hi = a.hi << shift | a.lo >> (32 - shift); + a.lo = a.lo << shift; } return a; } @@ -194,33 +193,33 @@ _cairo_uint64_rsl (cairo_uint64_t a, int shift) { if (shift >= 32) { - a.lo = a.hi; - a.hi = 0; - shift -= 32; + a.lo = a.hi; + a.hi = 0; + shift -= 32; } if (shift) { - a.lo = a.lo >> shift | a.hi << (32 - shift); - a.hi = a.hi >> shift; + a.lo = a.lo >> shift | a.hi << (32 - shift); + a.hi = a.hi >> shift; } return a; } -#define _cairo_uint32_rsa(a,n) ((uint32_t) (((int32_t) (a)) >> (n))) +#define _cairo_uint32_rsa(a,n) ((uint32_t) (((int32_t) (a)) >> (n))) cairo_int64_t _cairo_uint64_rsa (cairo_int64_t a, int shift) { if (shift >= 32) { - a.lo = a.hi; - a.hi = _cairo_uint32_rsa (a.hi, 31); - shift -= 32; + a.lo = a.hi; + a.hi = _cairo_uint32_rsa (a.hi, 31); + shift -= 32; } if (shift) { - a.lo = a.lo >> shift | a.hi << (32 - shift); - a.hi = _cairo_uint32_rsa (a.hi, shift); + a.lo = a.lo >> shift | a.hi << (32 - shift); + a.hi = _cairo_uint32_rsa (a.hi, shift); } return a; } @@ -229,7 +228,7 @@ int _cairo_uint64_lt (cairo_uint64_t a, cairo_uint64_t b) { return (a.hi < b.hi || - (a.hi == b.hi && a.lo < b.lo)); + (a.hi == b.hi && a.lo < b.lo)); } int @@ -242,9 +241,9 @@ int _cairo_int64_lt (cairo_int64_t a, cairo_int64_t b) { if (_cairo_int64_negative (a) && !_cairo_int64_negative (b)) - return 1; + return 1; if (!_cairo_int64_negative (a) && _cairo_int64_negative (b)) - return 0; + return 0; return _cairo_uint64_lt (a, b); } @@ -262,7 +261,7 @@ _cairo_uint64_negate (cairo_uint64_t a) a.lo = ~a.lo; a.hi = ~a.hi; if (++a.lo == 0) - ++a.hi; + ++a.hi; return a; } @@ -272,30 +271,30 @@ _cairo_uint64_negate (cairo_uint64_t a) cairo_uquorem64_t _cairo_uint64_divrem (cairo_uint64_t num, cairo_uint64_t den) { - cairo_uquorem64_t qr; - cairo_uint64_t bit; - cairo_uint64_t quo; + cairo_uquorem64_t qr; + cairo_uint64_t bit; + cairo_uint64_t quo; bit = _cairo_uint32_to_uint64 (1); /* normalize to make den >= num, but not overflow */ while (_cairo_uint64_lt (den, num) && (den.hi & 0x80000000) == 0) { - bit = _cairo_uint64_lsl (bit, 1); - den = _cairo_uint64_lsl (den, 1); + bit = _cairo_uint64_lsl (bit, 1); + den = _cairo_uint64_lsl (den, 1); } quo = _cairo_uint32_to_uint64 (0); /* generate quotient, one bit at a time */ while (bit.hi | bit.lo) { - if (_cairo_uint64_le (den, num)) - { - num = _cairo_uint64_sub (num, den); - quo = _cairo_uint64_add (quo, bit); - } - bit = _cairo_uint64_rsl (bit, 1); - den = _cairo_uint64_rsl (den, 1); + if (_cairo_uint64_le (den, num)) + { + num = _cairo_uint64_sub (num, den); + quo = _cairo_uint64_add (quo, bit); + } + bit = _cairo_uint64_rsl (bit, 1); + den = _cairo_uint64_rsl (den, 1); } qr.quo = quo; qr.rem = num; @@ -307,24 +306,24 @@ _cairo_uint64_divrem (cairo_uint64_t num, cairo_uint64_t den) cairo_quorem64_t _cairo_int64_divrem (cairo_int64_t num, cairo_int64_t den) { - int num_neg = _cairo_int64_negative (num); - int den_neg = _cairo_int64_negative (den); - cairo_uquorem64_t uqr; - cairo_quorem64_t qr; + int num_neg = _cairo_int64_negative (num); + int den_neg = _cairo_int64_negative (den); + cairo_uquorem64_t uqr; + cairo_quorem64_t qr; if (num_neg) - num = _cairo_int64_negate (num); + num = _cairo_int64_negate (num); if (den_neg) - den = _cairo_int64_negate (den); + den = _cairo_int64_negate (den); uqr = _cairo_uint64_divrem (num, den); if (num_neg) - qr.rem = _cairo_int64_negate ((cairo_int64_t)uqr.rem); //PDB cast + qr.rem = _cairo_int64_negate ((cairo_int64_t)uqr.rem); //PDB cast else - qr.rem = uqr.rem; + qr.rem = uqr.rem; if (num_neg != den_neg) - qr.quo = (cairo_int64_t) _cairo_int64_negate ((cairo_int64_t)uqr.quo); //PDB cast + qr.quo = (cairo_int64_t) _cairo_int64_negate ((cairo_int64_t)uqr.quo); //PDB cast else - qr.quo = (cairo_int64_t) uqr.quo; + qr.quo = (cairo_int64_t) uqr.quo; return qr; } @@ -335,7 +334,7 @@ const char * cairo_impl128 = "uint128_t"; cairo_uquorem128_t _cairo_uint128_divrem (cairo_uint128_t num, cairo_uint128_t den) { - cairo_uquorem128_t qr; + cairo_uquorem128_t qr; qr.quo = num / den; qr.rem = num % den; @@ -349,7 +348,7 @@ const char * cairo_impl128 = "cairo_uint64_t"; cairo_uint128_t _cairo_uint32_to_uint128 (uint32_t i) { - cairo_uint128_t q; + cairo_uint128_t q; q.lo = _cairo_uint32_to_uint64 (i); q.hi = _cairo_uint32_to_uint64 (0); @@ -359,7 +358,7 @@ _cairo_uint32_to_uint128 (uint32_t i) cairo_int128_t _cairo_int32_to_int128 (int32_t i) { - cairo_int128_t q; + cairo_int128_t q; q.lo = _cairo_int32_to_int64 (i); q.hi = _cairo_int32_to_int64 (i < 0 ? -1 : 0); @@ -369,7 +368,7 @@ _cairo_int32_to_int128 (int32_t i) cairo_uint128_t _cairo_uint64_to_uint128 (cairo_uint64_t i) { - cairo_uint128_t q; + cairo_uint128_t q; q.lo = i; q.hi = _cairo_uint32_to_uint64 (0); @@ -379,7 +378,7 @@ _cairo_uint64_to_uint128 (cairo_uint64_t i) cairo_int128_t _cairo_int64_to_int128 (cairo_int64_t i) { - cairo_int128_t q; + cairo_int128_t q; q.lo = i; q.hi = _cairo_int32_to_int64 (_cairo_int64_negative(i) ? -1 : 0); @@ -389,40 +388,40 @@ _cairo_int64_to_int128 (cairo_int64_t i) cairo_uint128_t _cairo_uint128_add (cairo_uint128_t a, cairo_uint128_t b) { - cairo_uint128_t s; + cairo_uint128_t s; s.hi = _cairo_uint64_add (a.hi, b.hi); s.lo = _cairo_uint64_add (a.lo, b.lo); if (_cairo_uint64_lt (s.lo, a.lo)) - s.hi = _cairo_uint64_add (s.hi, _cairo_uint32_to_uint64 (1)); + s.hi = _cairo_uint64_add (s.hi, _cairo_uint32_to_uint64 (1)); return s; } cairo_uint128_t _cairo_uint128_sub (cairo_uint128_t a, cairo_uint128_t b) { - cairo_uint128_t s; + cairo_uint128_t s; s.hi = _cairo_uint64_sub (a.hi, b.hi); s.lo = _cairo_uint64_sub (a.lo, b.lo); if (_cairo_uint64_gt (s.lo, a.lo)) - s.hi = _cairo_uint64_sub (s.hi, _cairo_uint32_to_uint64(1)); + s.hi = _cairo_uint64_sub (s.hi, _cairo_uint32_to_uint64(1)); return s; } #if HAVE_UINT64_T -#define uint64_lo32(i) ((i) & 0xffffffff) -#define uint64_hi32(i) ((i) >> 32) -#define uint64_lo(i) ((i) & 0xffffffff) -#define uint64_hi(i) ((i) >> 32) +#define uint64_lo32(i) ((i) & 0xffffffff) +#define uint64_hi32(i) ((i) >> 32) +#define uint64_lo(i) ((i) & 0xffffffff) +#define uint64_hi(i) ((i) >> 32) #define uint64_shift32(i) ((i) << 32) -#define uint64_carry32 (((uint64_t) 1) << 32) +#define uint64_carry32 (((uint64_t) 1) << 32) #else -#define uint64_lo32(i) ((i).lo) -#define uint64_hi32(i) ((i).hi) +#define uint64_lo32(i) ((i).lo) +#define uint64_hi32(i) ((i).hi) static cairo_uint64_t uint64_lo (cairo_uint64_t i) @@ -461,9 +460,9 @@ static const cairo_uint64_t uint64_carry32 = { 0, 1 }; cairo_uint128_t _cairo_uint64x64_128_mul (cairo_uint64_t a, cairo_uint64_t b) { - cairo_uint128_t s; - uint32_t ah, al, bh, bl; - cairo_uint64_t r0, r1, r2, r3; + cairo_uint128_t s; + uint32_t ah, al, bh, bl; + cairo_uint64_t r0, r1, r2, r3; al = uint64_lo32 (a); ah = uint64_hi32 (a); @@ -476,13 +475,13 @@ _cairo_uint64x64_128_mul (cairo_uint64_t a, cairo_uint64_t b) r3 = _cairo_uint32x32_64_mul (ah, bh); r1 = _cairo_uint64_add (r1, uint64_hi (r0)); /* no carry possible */ - r1 = _cairo_uint64_add (r1, r2); /* but this can carry */ - if (_cairo_uint64_lt (r1, r2)) /* check */ - r3 = _cairo_uint64_add (r3, uint64_carry32); + r1 = _cairo_uint64_add (r1, r2); /* but this can carry */ + if (_cairo_uint64_lt (r1, r2)) /* check */ + r3 = _cairo_uint64_add (r3, uint64_carry32); s.hi = _cairo_uint64_add (r3, uint64_hi(r1)); s.lo = _cairo_uint64_add (uint64_shift32 (r1), - uint64_lo (r0)); + uint64_lo (r0)); return s; } @@ -491,26 +490,26 @@ _cairo_int64x64_128_mul (cairo_int64_t a, cairo_int64_t b) { cairo_int128_t s; s = _cairo_uint64x64_128_mul (_cairo_int64_to_uint64(a), - _cairo_int64_to_uint64(b)); + _cairo_int64_to_uint64(b)); if (_cairo_int64_negative (a)) - s.hi = _cairo_uint64_sub (s.hi, - _cairo_int64_to_uint64 (b)); + s.hi = _cairo_uint64_sub (s.hi, + _cairo_int64_to_uint64 (b)); if (_cairo_int64_negative (b)) - s.hi = _cairo_uint64_sub (s.hi, - _cairo_int64_to_uint64 (a)); + s.hi = _cairo_uint64_sub (s.hi, + _cairo_int64_to_uint64 (a)); return s; } cairo_uint128_t _cairo_uint128_mul (cairo_uint128_t a, cairo_uint128_t b) { - cairo_uint128_t s; + cairo_uint128_t s; s = _cairo_uint64x64_128_mul (a.lo, b.lo); s.hi = _cairo_uint64_add (s.hi, - _cairo_uint64_mul (a.lo, b.hi)); + _cairo_uint64_mul (a.lo, b.hi)); s.hi = _cairo_uint64_add (s.hi, - _cairo_uint64_mul (a.hi, b.lo)); + _cairo_uint64_mul (a.hi, b.lo)); return s; } @@ -519,15 +518,15 @@ _cairo_uint128_lsl (cairo_uint128_t a, int shift) { if (shift >= 64) { - a.hi = a.lo; - a.lo = _cairo_uint32_to_uint64 (0); - shift -= 64; + a.hi = a.lo; + a.lo = _cairo_uint32_to_uint64 (0); + shift -= 64; } if (shift) { - a.hi = _cairo_uint64_add (_cairo_uint64_lsl (a.hi, shift), - _cairo_uint64_rsl (a.lo, (64 - shift))); - a.lo = _cairo_uint64_lsl (a.lo, shift); + a.hi = _cairo_uint64_add (_cairo_uint64_lsl (a.hi, shift), + _cairo_uint64_rsl (a.lo, (64 - shift))); + a.lo = _cairo_uint64_lsl (a.lo, shift); } return a; } @@ -537,15 +536,15 @@ _cairo_uint128_rsl (cairo_uint128_t a, int shift) { if (shift >= 64) { - a.lo = a.hi; - a.hi = _cairo_uint32_to_uint64 (0); - shift -= 64; + a.lo = a.hi; + a.hi = _cairo_uint32_to_uint64 (0); + shift -= 64; } if (shift) { - a.lo = _cairo_uint64_add (_cairo_uint64_rsl (a.lo, shift), - _cairo_uint64_lsl (a.hi, (64 - shift))); - a.hi = _cairo_uint64_rsl (a.hi, shift); + a.lo = _cairo_uint64_add (_cairo_uint64_rsl (a.lo, shift), + _cairo_uint64_lsl (a.hi, (64 - shift))); + a.hi = _cairo_uint64_rsl (a.hi, shift); } return a; } @@ -555,15 +554,15 @@ _cairo_uint128_rsa (cairo_int128_t a, int shift) { if (shift >= 64) { - a.lo = a.hi; - a.hi = _cairo_uint64_rsa (a.hi, 64-1); - shift -= 64; + a.lo = a.hi; + a.hi = _cairo_uint64_rsa (a.hi, 64-1); + shift -= 64; } if (shift) { - a.lo = _cairo_uint64_add (_cairo_uint64_rsl (a.lo, shift), - _cairo_uint64_lsl (a.hi, (64 - shift))); - a.hi = _cairo_uint64_rsa (a.hi, shift); + a.lo = _cairo_uint64_add (_cairo_uint64_rsl (a.lo, shift), + _cairo_uint64_lsl (a.hi, (64 - shift))); + a.hi = _cairo_uint64_rsa (a.hi, shift); } return a; } @@ -572,17 +571,17 @@ int _cairo_uint128_lt (cairo_uint128_t a, cairo_uint128_t b) { return (_cairo_uint64_lt (a.hi, b.hi) || - (_cairo_uint64_eq (a.hi, b.hi) && - _cairo_uint64_lt (a.lo, b.lo))); + (_cairo_uint64_eq (a.hi, b.hi) && + _cairo_uint64_lt (a.lo, b.lo))); } int _cairo_int128_lt (cairo_int128_t a, cairo_int128_t b) { if (_cairo_int128_negative (a) && !_cairo_int128_negative (b)) - return 1; + return 1; if (!_cairo_int128_negative (a) && _cairo_int128_negative (b)) - return 0; + return 0; return _cairo_uint128_lt (a, b); } @@ -590,7 +589,7 @@ int _cairo_uint128_eq (cairo_uint128_t a, cairo_uint128_t b) { return (_cairo_uint64_eq (a.hi, b.hi) && - _cairo_uint64_eq (a.lo, b.lo)); + _cairo_uint64_eq (a.lo, b.lo)); } #if HAVE_UINT64_T @@ -602,30 +601,30 @@ _cairo_uint128_eq (cairo_uint128_t a, cairo_uint128_t b) cairo_uquorem128_t _cairo_uint128_divrem (cairo_uint128_t num, cairo_uint128_t den) { - cairo_uquorem128_t qr; - cairo_uint128_t bit; - cairo_uint128_t quo; + cairo_uquorem128_t qr; + cairo_uint128_t bit; + cairo_uint128_t quo; bit = _cairo_uint32_to_uint128 (1); /* normalize to make den >= num, but not overflow */ while (_cairo_uint128_lt (den, num) && !_cairo_msbset64(den.hi)) { - bit = _cairo_uint128_lsl (bit, 1); - den = _cairo_uint128_lsl (den, 1); + bit = _cairo_uint128_lsl (bit, 1); + den = _cairo_uint128_lsl (den, 1); } quo = _cairo_uint32_to_uint128 (0); /* generate quotient, one bit at a time */ while (_cairo_uint128_ne (bit, _cairo_uint32_to_uint128(0))) { - if (_cairo_uint128_le (den, num)) - { - num = _cairo_uint128_sub (num, den); - quo = _cairo_uint128_add (quo, bit); - } - bit = _cairo_uint128_rsl (bit, 1); - den = _cairo_uint128_rsl (den, 1); + if (_cairo_uint128_le (den, num)) + { + num = _cairo_uint128_sub (num, den); + quo = _cairo_uint128_add (quo, bit); + } + bit = _cairo_uint128_rsl (bit, 1); + den = _cairo_uint128_rsl (den, 1); } qr.quo = quo; qr.rem = num; @@ -653,24 +652,24 @@ _cairo_uint128_not (cairo_uint128_t a) cairo_quorem128_t _cairo_int128_divrem (cairo_int128_t num, cairo_int128_t den) { - int num_neg = _cairo_int128_negative (num); - int den_neg = _cairo_int128_negative (den); - cairo_uquorem128_t uqr; - cairo_quorem128_t qr; + int num_neg = _cairo_int128_negative (num); + int den_neg = _cairo_int128_negative (den); + cairo_uquorem128_t uqr; + cairo_quorem128_t qr; if (num_neg) - num = _cairo_int128_negate (num); + num = _cairo_int128_negate (num); if (den_neg) - den = _cairo_int128_negate (den); + den = _cairo_int128_negate (den); uqr = _cairo_uint128_divrem (num, den); if (num_neg) - qr.rem = _cairo_int128_negate (uqr.rem); + qr.rem = _cairo_int128_negate (uqr.rem); else - qr.rem = uqr.rem; + qr.rem = uqr.rem; if (num_neg != den_neg) - qr.quo = _cairo_int128_negate (uqr.quo); + qr.quo = _cairo_int128_negate (uqr.quo); else - qr.quo = uqr.quo; + qr.quo = uqr.quo; return qr; } @@ -685,7 +684,7 @@ _cairo_int128_divrem (cairo_int128_t num, cairo_int128_t den) * non-zero. */ cairo_uquorem64_t _cairo_uint_96by64_32x64_divrem (cairo_uint128_t num, - cairo_uint64_t den) + cairo_uint64_t den) { cairo_uquorem64_t result; cairo_uint64_t B = _cairo_uint32s_to_uint64 (1, 0); @@ -701,94 +700,94 @@ _cairo_uint_96by64_32x64_divrem (cairo_uint128_t num, /* Don't bother if the quotient is going to overflow. */ if (_cairo_uint64_ge (x, den)) { - return /* overflow */ result; + return /* overflow */ result; } if (_cairo_uint64_lt (x, B)) { - /* When the final quotient is known to fit in 32 bits, then - * num < 2^64 if and only if den < 2^32. */ - return _cairo_uint64_divrem (_cairo_uint128_to_uint64 (num), den); + /* When the final quotient is known to fit in 32 bits, then + * num < 2^64 if and only if den < 2^32. */ + return _cairo_uint64_divrem (_cairo_uint128_to_uint64 (num), den); } else { - /* Denominator is >= 2^32. the numerator is >= 2^64, and the - * division won't overflow: need two divrems. Write the - * numerator and denominator as - * - * num = xB + y x : 64 bits, y : 32 bits - * den = uB + v u, v : 32 bits - */ - uint32_t y = _cairo_uint128_to_uint32 (num); - uint32_t u = uint64_hi32 (den); - uint32_t v = _cairo_uint64_to_uint32 (den); + /* Denominator is >= 2^32. the numerator is >= 2^64, and the + * division won't overflow: need two divrems. Write the + * numerator and denominator as + * + * num = xB + y x : 64 bits, y : 32 bits + * den = uB + v u, v : 32 bits + */ + uint32_t y = _cairo_uint128_to_uint32 (num); + uint32_t u = uint64_hi32 (den); + uint32_t v = _cairo_uint64_to_uint32 (den); - /* Compute a lower bound approximate quotient of num/den - * from x/(u+1). Then we have - * - * x = q(u+1) + r ; q : 32 bits, r <= u : 32 bits. - * - * xB + y = q(u+1)B + (rB+y) - * = q(uB + B + v - v) + (rB+y) - * = q(uB + v) + qB - qv + (rB+y) - * = q(uB + v) + q(B-v) + (rB+y) - * - * The true quotient of num/den then is q plus the - * contribution of q(B-v) + (rB+y). The main contribution - * comes from the term q(B-v), with the term (rB+y) only - * contributing at most one part. - * - * The term q(B-v) must fit into 64 bits, since q fits into 32 - * bits on account of being a lower bound to the true - * quotient, and as B-v <= 2^32, we may safely use a single - * 64/64 bit division to find its contribution. */ + /* Compute a lower bound approximate quotient of num/den + * from x/(u+1). Then we have + * + * x = q(u+1) + r ; q : 32 bits, r <= u : 32 bits. + * + * xB + y = q(u+1)B + (rB+y) + * = q(uB + B + v - v) + (rB+y) + * = q(uB + v) + qB - qv + (rB+y) + * = q(uB + v) + q(B-v) + (rB+y) + * + * The true quotient of num/den then is q plus the + * contribution of q(B-v) + (rB+y). The main contribution + * comes from the term q(B-v), with the term (rB+y) only + * contributing at most one part. + * + * The term q(B-v) must fit into 64 bits, since q fits into 32 + * bits on account of being a lower bound to the true + * quotient, and as B-v <= 2^32, we may safely use a single + * 64/64 bit division to find its contribution. */ - cairo_uquorem64_t quorem; - cairo_uint64_t remainder; /* will contain final remainder */ - uint32_t quotient; /* will contain final quotient. */ - uint32_t q; - uint32_t r; + cairo_uquorem64_t quorem; + cairo_uint64_t remainder; /* will contain final remainder */ + uint32_t quotient; /* will contain final quotient. */ + uint32_t q; + uint32_t r; - /* Approximate quotient by dividing the high 64 bits of num by - * u+1. Watch out for overflow of u+1. */ - if (u+1) { - quorem = _cairo_uint64_divrem (x, _cairo_uint32_to_uint64 (u+1)); - q = _cairo_uint64_to_uint32 (quorem.quo); - r = _cairo_uint64_to_uint32 (quorem.rem); - } - else { - q = uint64_hi32 (x); - r = _cairo_uint64_to_uint32 (x); - } - quotient = q; + /* Approximate quotient by dividing the high 64 bits of num by + * u+1. Watch out for overflow of u+1. */ + if (u+1) { + quorem = _cairo_uint64_divrem (x, _cairo_uint32_to_uint64 (u+1)); + q = _cairo_uint64_to_uint32 (quorem.quo); + r = _cairo_uint64_to_uint32 (quorem.rem); + } + else { + q = uint64_hi32 (x); + r = _cairo_uint64_to_uint32 (x); + } + quotient = q; - /* Add the main term's contribution to quotient. Note B-v = - * -v as an uint32 (unless v = 0) */ - if (v) - quorem = _cairo_uint64_divrem (_cairo_uint32x32_64_mul (q, -(int32_t)v), den); //PDB cast - else - quorem = _cairo_uint64_divrem (_cairo_uint32s_to_uint64 (q, 0), den); - quotient += _cairo_uint64_to_uint32 (quorem.quo); + /* Add the main term's contribution to quotient. Note B-v = + * -v as an uint32 (unless v = 0) */ + if (v) + quorem = _cairo_uint64_divrem (_cairo_uint32x32_64_mul (q, -(int32_t)v), den); //PDB cast + else + quorem = _cairo_uint64_divrem (_cairo_uint32s_to_uint64 (q, 0), den); + quotient += _cairo_uint64_to_uint32 (quorem.quo); - /* Add the contribution of the subterm and start computing the - * true remainder. */ - remainder = _cairo_uint32s_to_uint64 (r, y); - if (_cairo_uint64_ge (remainder, den)) { - remainder = _cairo_uint64_sub (remainder, den); - quotient++; - } + /* Add the contribution of the subterm and start computing the + * true remainder. */ + remainder = _cairo_uint32s_to_uint64 (r, y); + if (_cairo_uint64_ge (remainder, den)) { + remainder = _cairo_uint64_sub (remainder, den); + quotient++; + } - /* Add the contribution of the main term's remainder. The - * funky test here checks that remainder + main_rem >= den, - * taking into account overflow of the addition. */ - remainder = _cairo_uint64_add (remainder, quorem.rem); - if (_cairo_uint64_ge (remainder, den) || - _cairo_uint64_lt (remainder, quorem.rem)) - { - remainder = _cairo_uint64_sub (remainder, den); - quotient++; - } + /* Add the contribution of the main term's remainder. The + * funky test here checks that remainder + main_rem >= den, + * taking into account overflow of the addition. */ + remainder = _cairo_uint64_add (remainder, quorem.rem); + if (_cairo_uint64_ge (remainder, den) || + _cairo_uint64_lt (remainder, quorem.rem)) + { + remainder = _cairo_uint64_sub (remainder, den); + quotient++; + } - result.quo = _cairo_uint32_to_uint64 (quotient); - result.rem = remainder; + result.quo = _cairo_uint32_to_uint64 (quotient); + result.rem = remainder; } return result; } @@ -796,35 +795,35 @@ _cairo_uint_96by64_32x64_divrem (cairo_uint128_t num, cairo_quorem64_t _cairo_int_96by64_32x64_divrem (cairo_int128_t num, cairo_int64_t den) { - int num_neg = _cairo_int128_negative (num); - int den_neg = _cairo_int64_negative (den); - cairo_uint64_t nonneg_den; - cairo_uquorem64_t uqr; - cairo_quorem64_t qr; + int num_neg = _cairo_int128_negative (num); + int den_neg = _cairo_int64_negative (den); + cairo_uint64_t nonneg_den; + cairo_uquorem64_t uqr; + cairo_quorem64_t qr; if (num_neg) - num = _cairo_int128_negate (num); + num = _cairo_int128_negate (num); if (den_neg) - nonneg_den = _cairo_int64_negate (den); + nonneg_den = _cairo_int64_negate (den); else - nonneg_den = den; + nonneg_den = den; uqr = _cairo_uint_96by64_32x64_divrem (num, nonneg_den); if (_cairo_uint64_eq (uqr.rem, _cairo_int64_to_uint64 (nonneg_den))) { - /* bail on overflow. */ - qr.quo = _cairo_uint32s_to_uint64 (0x7FFFFFFF, UINT_MAX); //PDB cast - qr.rem = den; - return qr; + /* bail on overflow. */ + qr.quo = _cairo_uint32s_to_uint64 (0x7FFFFFFF, UINT_MAX); //PDB cast + qr.rem = den; + return qr; } if (num_neg) - qr.rem = _cairo_int64_negate ((cairo_int64_t)uqr.rem); //PDB cast + qr.rem = _cairo_int64_negate ((cairo_int64_t)uqr.rem); //PDB cast else - qr.rem = uqr.rem; + qr.rem = uqr.rem; if (num_neg != den_neg) - qr.quo = _cairo_int64_negate ((cairo_int64_t)uqr.quo); //PDB cast + qr.quo = _cairo_int64_negate ((cairo_int64_t)uqr.quo); //PDB cast else - qr.quo = uqr.quo; + qr.quo = uqr.quo; return qr; } diff --git a/src/core/model/calendar-scheduler.cc b/src/core/model/calendar-scheduler.cc index d9d102042..1807579e2 100644 --- a/src/core/model/calendar-scheduler.cc +++ b/src/core/model/calendar-scheduler.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/src/core/model/calendar-scheduler.h b/src/core/model/calendar-scheduler.h index 650b1e956..ceb997423 100644 --- a/src/core/model/calendar-scheduler.h +++ b/src/core/model/calendar-scheduler.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2009 INRIA * diff --git a/src/core/model/callback.cc b/src/core/model/callback.cc index ffbc037ea..909bb30b9 100644 --- a/src/core/model/callback.cc +++ b/src/core/model/callback.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2005,2006 INRIA * diff --git a/src/core/model/callback.h b/src/core/model/callback.h index 6eea99102..662ca1f01 100644 --- a/src/core/model/callback.h +++ b/src/core/model/callback.h @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2005,2006 INRIA * diff --git a/src/core/model/command-line.cc b/src/core/model/command-line.cc index 0c1fa2b37..b8e37f1b4 100644 --- a/src/core/model/command-line.cc +++ b/src/core/model/command-line.cc @@ -1,4 +1,3 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ /* * Copyright (c) 2008 INRIA * @@ -117,7 +116,7 @@ CommandLine::CommandLine() NS_LOG_FUNCTION(this); } -CommandLine::CommandLine(const std::string filename) +CommandLine::CommandLine(const std::string& filename) : m_NNonOptions(0), m_nonOptionCount(0), m_usage() @@ -125,6 +124,7 @@ CommandLine::CommandLine(const std::string filename) NS_LOG_FUNCTION(this << filename); std::string basename = SystemPath::Split(filename).back(); m_shortName = basename.substr(0, basename.rfind(".cc")); + m_shortName = m_shortName.substr(basename.find_last_of('/') + 1); } CommandLine::CommandLine(const CommandLine& cmd) @@ -165,14 +165,6 @@ CommandLine::Clear() { NS_LOG_FUNCTION(this); - for (auto i : m_options) - { - delete i; - } - for (auto i : m_nonOptions) - { - delete i; - } m_options.clear(); m_nonOptions.clear(); m_NNonOptions = 0; @@ -181,7 +173,7 @@ CommandLine::Clear() } void -CommandLine::Usage(const std::string usage) +CommandLine::Usage(const std::string& usage) { m_usage = usage; } @@ -210,6 +202,8 @@ CommandLine::Parse(std::vector args) { args.erase(args.begin()); // discard the program name + HandleHardOptions(args); + for (const auto& param : args) { if (HandleOption(param)) @@ -232,8 +226,8 @@ CommandLine::Parse(std::vector args) #endif } -bool -CommandLine::HandleOption(const std::string& param) const +CommandLine::HasOptionName +CommandLine::GetOptionName(const std::string& param) const { // remove leading "--" or "-" std::string arg = param; @@ -252,9 +246,10 @@ CommandLine::HandleOption(const std::string& param) const else { // non-option argument? - return false; + return {false, param, ""}; } } + // find any value following '=' cur = arg.find('='); std::string name; @@ -269,6 +264,78 @@ CommandLine::HandleOption(const std::string& param) const name = arg.substr(0, cur); value = arg.substr(cur + 1, arg.size() - (cur + 1)); } + + return {true, name, value}; +} + +void +CommandLine::HandleHardOptions(const std::vector& args) const +{ + NS_LOG_FUNCTION(this << args.size() << args); + + for (const auto& param : args) + { + auto [isOpt, name, value] = GetOptionName(param); + if (!isOpt) + { + continue; + } + + // Hard-coded options + if (name == "PrintHelp" || name == "help") + { + // method below never returns. + PrintHelp(std::cout); + std::exit(0); + } + if (name == "PrintVersion" || name == "version") + { + // Print the version, then exit the program + PrintVersion(std::cout); + std::exit(0); + } + else if (name == "PrintGroups") + { + // method below never returns. + PrintGroups(std::cout); + std::exit(0); + } + else if (name == "PrintTypeIds") + { + // method below never returns. + PrintTypeIds(std::cout); + std::exit(0); + } + else if (name == "PrintGlobals") + { + // method below never returns. + PrintGlobals(std::cout); + std::exit(0); + } + else if (name == "PrintGroup") + { + // method below never returns. + PrintGroup(std::cout, value); + std::exit(0); + } + else if (name == "PrintAttributes") + { + // method below never returns. + PrintAttributes(std::cout, value); + std::exit(0); + } + } +} + +bool +CommandLine::HandleOption(const std::string& param) const +{ + auto [isOpt, name, value] = GetOptionName(param); + if (!isOpt) + { + return false; + } + HandleArgument(name, value); return true; @@ -284,7 +351,7 @@ CommandLine::HandleNonOption(const std::string& value) // Add an unspecified non-option as a string NS_LOG_LOGIC("adding StringItem, NOCount:" << m_nonOptionCount << ", NOSize:" << m_nonOptions.size()); - StringItem* item = new StringItem; + auto item = std::make_shared(); item->m_name = "extra-non-option-argument"; item->m_help = "Extra non-option argument encountered."; item->m_value = value; @@ -321,56 +388,43 @@ CommandLine::PrintHelp(std::ostream& os) const os << m_shortName << (m_options.size() ? " [Program Options]" : "") << (nonOptions.size() ? " [Program Arguments]" : "") << " [General Arguments]" << std::endl; - if (m_usage.length()) + if (!m_usage.empty()) { os << std::endl; os << m_usage << std::endl; } std::size_t width = 0; - for (auto it : m_options) - { - width = std::max(width, it->m_name.size()); - } - for (auto it : nonOptions) - { - width = std::max(width, it->m_name.size()); - } + auto max_width = [&width](const std::shared_ptr item) { + width = std::max(width, item->m_name.size()); + }; + std::for_each(m_options.begin(), m_options.end(), max_width); + std::for_each(nonOptions.begin(), nonOptions.end(), max_width); width += 3; // room for ": " between option and help + auto optionsHelp = [&os, width](const std::string& head, bool option, const Items& items) { + os << "\n" << head << "\n"; + for (const auto& item : items) + { + os << " " << (option ? "--" : " ") << std::left << std::setw(width) + << (item->m_name + ":") << std::right << item->m_help; + + if (item->HasDefault()) + { + os << " [" << item->GetDefault() << "]"; + } + os << "\n"; + } + }; + if (!m_options.empty()) { - os << std::endl; - os << "Program Options:" << std::endl; - for (auto i : m_options) - { - os << " --" << std::left << std::setw(width) << (i->m_name + ":") << std::right - << i->m_help; - - if (i->HasDefault()) - { - os << " [" << i->GetDefault() << "]"; - } - os << std::endl; - } + optionsHelp("Program Options:", true, m_options); } if (!nonOptions.empty()) { - width += 2; // account for "--" added above - os << std::endl; - os << "Program Arguments:" << std::endl; - for (auto i : nonOptions) - { - os << " " << std::left << std::setw(width) << (i->m_name + ":") << std::right - << i->m_help; - - if (i->HasDefault()) - { - os << " [" << i->GetDefault() << "]"; - } - os << std::endl; - } + optionsHelp("Program Arguments:", false, nonOptions); } os << std::endl; @@ -385,8 +439,6 @@ CommandLine::PrintHelp(std::ostream& os) const << std::endl; } -#include // getcwd - std::string CommandLine::GetVersion() const { @@ -435,14 +487,14 @@ CommandLine::PrintDoxygenUsage() const << "$ ./ns3 run \"" << m_shortName << (m_options.size() ? " [Program Options]" : "") << (nonOptions.size() ? " [Program Arguments]" : "") << "\"\n"; - if (m_usage.length()) + if (!m_usage.empty()) { os << Encode(m_usage) << "\n"; } - auto listOptions = [&os](Items items, std::string pre) { - os << "
\n"; - for (const auto i : items) + auto listOptions = [&os](const std::string& head, const Items& items, std::string pre) { + os << "\n

" << head << "

\n
\n"; + for (const auto& i : items) { os << "
" << pre << i->m_name << "
\n" << "
" << Encode(i->m_help); @@ -458,16 +510,12 @@ CommandLine::PrintDoxygenUsage() const if (!m_options.empty()) { - os << std::endl; - os << "

Program Options

\n"; - listOptions(m_options, "\\c --"); + listOptions("Program Options", m_options, "\\c --"); } if (!nonOptions.empty()) { - os << std::endl; - os << "

Program Arguments

\n"; - listOptions(nonOptions, "\\c "); + listOptions("Program Arguments", nonOptions, "\\c "); } os << "*/" << std::endl; @@ -634,83 +682,42 @@ CommandLine::PrintGroups(std::ostream& os) const } } -void +bool CommandLine::HandleArgument(const std::string& name, const std::string& value) const { NS_LOG_FUNCTION(this << name << value); NS_LOG_DEBUG("Handle arg name=" << name << " value=" << value); - // Hard-coded options - if (name == "PrintHelp" || name == "help") - { - // method below never returns. - PrintHelp(std::cout); - std::exit(0); - } - if (name == "PrintVersion" || name == "version") - { - // Print the version, then exit the program - PrintVersion(std::cout); - std::exit(0); - } - else if (name == "PrintGroups") - { - // method below never returns. - PrintGroups(std::cout); - std::exit(0); - } - else if (name == "PrintTypeIds") - { - // method below never returns. - PrintTypeIds(std::cout); - std::exit(0); - } - else if (name == "PrintGlobals") - { - // method below never returns. - PrintGlobals(std::cout); - std::exit(0); - } - else if (name == "PrintGroup") - { - // method below never returns. - PrintGroup(std::cout, value); - std::exit(0); - } - else if (name == "PrintAttributes") - { - // method below never returns. - PrintAttributes(std::cout, value); - std::exit(0); - } - else - { - for (auto i : m_options) + auto errorExit = [this, name, value]() { + std::cerr << "Invalid command-line argument: --" << name; + if (value != "") { - if (i->m_name == name) - { - if (!i->Parse(value)) - { - std::cerr << "Invalid argument value: " << name << "=" << value << std::endl; - PrintHelp(std::cerr); - std::exit(1); - } - else - { - return; - } - } + std::cerr << "=" << value; } - } - // Global or ConfigPath options - if (!Config::SetGlobalFailSafe(name, StringValue(value)) && - !Config::SetDefaultFailSafe(name, StringValue(value))) - { - std::cerr << "Invalid command-line arguments: --" << name << "=" << value << std::endl; - PrintHelp(std::cerr); + std::cerr << std::endl; + this->PrintHelp(std::cerr); std::exit(1); + }; + + auto item = std::find_if(m_options.begin(), m_options.end(), [name](std::shared_ptr it) { + return it->m_name == name; + }); + if (item != m_options.end()) + { + if (!(*item)->Parse(value)) + { + errorExit(); + } + return true; } + + // Global or ConfigPath options + if (!HandleAttribute(name, value)) + { + errorExit(); + } + return true; } bool @@ -726,22 +733,38 @@ CommandLine::CallbackItem::GetDefault() const } bool -CommandLine::CallbackItem::Parse(const std::string value) +CommandLine::CallbackItem::Parse(const std::string& value) const { NS_LOG_FUNCTION(this); NS_LOG_DEBUG("CommandLine::CallbackItem::Parse \"" << value << "\""); return m_callback(value); } +void +CommandLine::AddValue(const std::string& name, + const std::string& help, + char* value, + std::size_t num) +{ + NS_LOG_FUNCTION(this << name << help << value << num); + auto item = std::make_shared(); + item->m_name = name; + item->m_help = help; + item->m_buffer = value; + item->m_size = num; + item->m_default.assign(value); + m_options.push_back(item); +} + void CommandLine::AddValue(const std::string& name, const std::string& help, ns3::Callback callback, - std::string defaultValue /* = "" */) + const std::string& defaultValue /* = "" */) { NS_LOG_FUNCTION(this << &name << &help << &callback); - CallbackItem* item = new CallbackItem(); + auto item = std::make_shared(); item->m_name = name; item->m_help = help; item->m_callback = callback; @@ -785,7 +808,7 @@ CommandLine::GetExtraNonOption(std::size_t i) const if (m_nonOptions.size() >= i + m_NNonOptions) { - auto ip = dynamic_cast(m_nonOptions[i + m_NNonOptions]); + auto ip = std::dynamic_pointer_cast(m_nonOptions[i + m_NNonOptions]); if (ip != nullptr) { value = ip->m_value; @@ -809,15 +832,10 @@ CommandLine::GetNExtraNonOptions() const /* static */ bool -CommandLine::HandleAttribute(const std::string name, const std::string value) +CommandLine::HandleAttribute(const std::string& name, const std::string& value) { - bool success = true; - if (!Config::SetGlobalFailSafe(name, StringValue(value)) && - !Config::SetDefaultFailSafe(name, StringValue(value))) - { - success = false; - } - return success; + return Config::SetGlobalFailSafe(name, StringValue(value)) || + Config::SetDefaultFailSafe(name, StringValue(value)); } bool @@ -827,9 +845,9 @@ CommandLine::Item::HasDefault() const } bool -CommandLine::StringItem::Parse(const std::string value) +CommandLine::StringItem::Parse(const std::string& value) const { - m_value = value; + m_value = value; // mutable return true; } @@ -845,84 +863,116 @@ CommandLine::StringItem::GetDefault() const return ""; } +bool +CommandLine::CharStarItem::Parse(const std::string& value) const +{ + if (value.size() > m_size - 1) + { + std::cerr << "Value \"" << value << "\" (" << value.size() << " bytes) is too long for " + << m_name << " buffer (" << m_size << " bytes, including terminating null)." + << std::endl; + return false; + } + + std::strncpy(m_buffer, value.c_str(), m_size); + return true; +} + +bool +CommandLine::CharStarItem::HasDefault() const +{ + return true; +} + +std::string +CommandLine::CharStarItem::GetDefault() const +{ + return m_default; +} + template <> std::string -CommandLineHelper::GetDefault(const bool& val) +CommandLineHelper::GetDefault(const std::string& defaultValue) { + bool value; + std::istringstream iss(defaultValue); + iss >> value; std::ostringstream oss; - oss << std::boolalpha << val; + oss << std::boolalpha << value; return oss.str(); } template <> bool -CommandLineHelper::UserItemParse(const std::string value, bool& val) +CommandLineHelper::UserItemParse(const std::string& value, bool& dest) { + // No new value, so just toggle it + if (value.empty()) + { + dest = !dest; + return true; + } + std::string src = value; std::transform(src.begin(), src.end(), src.begin(), [](char c) { return static_cast(std::tolower(c)); }); - if (src.length() == 0) + if (src == "true" || src == "t") { - val = !val; + dest = true; return true; } - else if ((src == "true") || (src == "t")) + else if (src == "false" || src == "f") { - val = true; - return true; - } - else if ((src == "false") || (src == "f")) - { - val = false; + dest = false; return true; } else { std::istringstream iss; iss.str(src); - iss >> val; + iss >> dest; return !iss.bad() && !iss.fail(); } } template <> std::string -CommandLineHelper::GetDefault