diff --git a/.hgtags b/.hgtags index f72791391..c483b5975 100644 --- a/.hgtags +++ b/.hgtags @@ -56,3 +56,5 @@ def4153e27cd744f117acf8c509979617850da83 ns-3.9-RC3 63a8a4ed4054f1e1cd1756045abba657f6fd884c ns-3.10 440bbee145f096193abcdd67fe6c16de62935d89 ns-3.11-RC1 0a7a16b599e86ca7884e5b5772bf7c5cfe146603 ns-3.11-RC2 +e48ed3aabca6ad71c8c49e4604c0f83345eda6a8 ns-3.11-RC3 +9843c12351cb5ceb9613c9db390d94073b713284 ns-3.11 diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 1507d1fef..aec6aae95 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -14,22 +14,64 @@ Release 3.11 Availability ------------ -This release is not yet available. +This release is available from: +http://www.nsnam.org/releases/ns-allinone-3.11.tar.bz2 Supported platforms ------------------- +ns-3.11 has been tested on the following platforms. Not all features are +available on all platforms; check the Installation page on the project wiki. + +- Linux x86_64 Ubuntu 11.04 + - g++-4.5.2 +- Linux i686 Ubuntu 11.04 + - g++-4.5.2, g++-4.4.5 +- Linux x86_64 Fedora Core 15 + - g++-4.6.0 +- Linux x86_64 Fedora Core 14 + - g++-4.5.3, g++-4.4.6, g++-4.3.4 +- Linux x86_64 Fedora Core 10 + - g++-3.4.6, 4.0.4, 4.1.2, 4.2.4, 4.3.2, 4.4.0 +- OS X Snow Leopard + - g++-4.2.1 New user-visible features ------------------------- + - The build system has been modularized, and the source code reorganized, + to allow for modular libraries instead of a single monolithic ns-3 + library. User programs now link a number of smaller, per-module + libraries depending on the dependencies expressed to the build system. + Source code is now being maintained in individual modules with + consistent directory structures. + + - Python bindings have also been modularized, and the bindings are now + generated into a 'ns' namespace instead of 'ns3' for the old + (monolithic) bindings. By default the bindings are now modular, with + a backward compatibility layer for older programs. + + - By default, example and test programs are disabled from the build. + Users can enable them via the use of a waf command at configure time, + or automatically through the use of a new .ns3rc file. + - int64x64_t is a new type which allows portable and easy to write arithmetic calculations that require a high degree of fractional precision. - - interface to the Click Modular Router and an Ipv4ClickRouting - class to allow a node to use Click for external routing + - An interface to the Click Modular Router and an Ipv4ClickRouting + class has been added, to allow a node to use Click for external routing. - - interface to an OpenFlow software implementation distribution to allow the - simulation of OpenFlow switches in ns-3 + - An interface to an OpenFlow software implementation distribution has + been added to allow the simulation of OpenFlow switches in ns-3. + + - ns-3 coding style requirements have been applied to the entire coding + base, resulting in a large number of whitespace changes. The coding + style has been automatically enforced by running a style checking + program (utils/check-style.py) that uses the uncrustify (v. 0.58) + program to apply changes. + + - Some documentation reorganization to split documentation between + the ns-3 manual (primarily focusing on the ns-3 core) and a new + "model library" document has been started. Bugs fixed ---------- @@ -45,9 +87,11 @@ since ns-3.10, in many cases referencing the Bugzilla bug number. - ./waf --apiscan: fix bug in detection of whether the per-module - Remove the 'Modules to build' debug print - CsmaNetDevice ReceiveErrorModel was not dropping the packet + - Several "set but not used" bugs for newer compilers quick-fixed - bug 445 - Is the class name Scalar in nstime.h appropriate? - bug 699 - TestCase::DoRun probably should not return a bool + - bug 823 - Need finer-grained control over what goes into libns3 - bug 957 - Issue with test.py - bug 1017 - node --> internet-stack --> node - bug 1018 - mobility --> helper --> mobility circular dependency @@ -87,6 +131,7 @@ since ns-3.10, in many cases referencing the Bugzilla bug number. - bug 1094 - Object::GetObject upon dlopen - bug 1097 - AODV routing entry set to be VALID mistakenly. - bug 1098 - when to show users which modules are enabled? + - bug 1101 - Sqlite stats disappeared from configuration file src/wscript - bug 1103 - Useless assignment in omnet-data-output.cc - bug 1105 - Move topology helpers into separate per-device modules - bug 1106 - Remove "CanvasLocation" dependencies in p2p helpers @@ -98,6 +143,7 @@ since ns-3.10, in many cases referencing the Bugzilla bug number. - bug 1131 - Bug in Ipv4L3Protocol::RemoveAddress() - bug 1133 - DSDV: Possible bug in settling time calc - bug 1142 - Wrong 802.11p Slot time + - bug 1146 - help string for test.py with disabled tests Known issues ------------ diff --git a/doc/doxygen.conf b/doc/doxygen.conf index 2e971f095..497635256 100644 --- a/doc/doxygen.conf +++ b/doc/doxygen.conf @@ -607,9 +607,7 @@ EXCLUDE = src/olsr/model/olsr-state.h \ src/olsr/model/olsr-repositories.h \ src/core/model/high-precision.h \ src/core/model/high-precision-128.h \ - src/core/model/high-precision-double.h \ - src/visualizer/model/visual-simulator-impl.h \ - src/visualizer/model/pyviz.h + src/core/model/high-precision-double.h # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded diff --git a/doc/manual/source/conf.py b/doc/manual/source/conf.py index 00d857170..2575ed434 100644 --- a/doc/manual/source/conf.py +++ b/doc/manual/source/conf.py @@ -48,9 +48,9 @@ copyright = u'2010, ns-3 project' # built documents. # # The short X.Y version. -version = 'ns-3.10' +version = 'ns-3-dev' # The full version, including alpha/beta/rc tags. -release = 'ns-3.10' +release = 'ns-3-dev' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/manual/source/enable-modules.rst b/doc/manual/source/enable-modules.rst index 5e63438a8..d7fd025e2 100644 --- a/doc/manual/source/enable-modules.rst +++ b/doc/manual/source/enable-modules.rst @@ -12,7 +12,7 @@ How to enable a subset of |ns3|'s modules If shared libraries are being built, then enabling a module will cause at least one library to be built: :: - libns3-modulename.so. + libns3-modulename.so If the module has a test library and test libraries are being built, then :: diff --git a/doc/manual/source/new-models.rst b/doc/manual/source/new-models.rst index 189b8b301..f8788f6b2 100644 --- a/doc/manual/source/new-models.rst +++ b/doc/manual/source/new-models.rst @@ -189,7 +189,7 @@ Let's start with empty files error-model.h and error-model.cc, and add this to ``src/network/wscript``. It is really just a matter of adding the .cc file to the rest of the source files, and the .h file to the list of the header files. -Now, pop up to the top level directory and type "./waf --check". You +Now, pop up to the top level directory and type "./test.py". You shouldn't have broken anything by this operation. include guards diff --git a/doc/manual/source/new-modules.rst b/doc/manual/source/new-modules.rst index 75ab03017..35a09bd45 100644 --- a/doc/manual/source/new-modules.rst +++ b/doc/manual/source/new-modules.rst @@ -216,14 +216,14 @@ Step 7 - Specify which of your module's examples should be run If your new module has examples, then you must specify which of them should be run in your :: - src/new-module/tests/examples-to-run.py + src/new-module/test/examples-to-run.py file by modifying it with your text editor. These examples are run by test.py. As an example, the examples that are run by test.py for the core module are specified in :: - src/core/tests/examples-to-run + src/core/test/examples-to-run.py using the following two lists of C++ and Python examples: :: diff --git a/doc/manual/source/python.rst b/doc/manual/source/python.rst index f55c74b0e..9a1393b9f 100644 --- a/doc/manual/source/python.rst +++ b/doc/manual/source/python.rst @@ -1,9 +1,315 @@ .. include:: replace.txt -Python ------- +Using Python to Run |ns3| +------------------------- -**Placeholder chapter** +Python bindings allow the C++ code in |ns3| to be called from Python. -For now, please see the Python wiki page at +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. + +Introduction +************ + +The goal of Python bindings for |ns3| are two fold: + +#. Allow the programmer to write complete simulation scripts in Python (http://wwww.python.org); +#. Prototype new models (e.g. routing protocols). + +For the time being, the primary focus of the bindings is the first goal, but the second goal will eventually be supported as well. +Python bindings for |ns3| are being developed using a new tool called PyBindGen (http://code.google.com/p/pybindgen). + +An Example Python Script that Runs |ns3| +**************************************** + +Here is some example code that is written in Python and that runs |ns3|, which is written in C++. This Python example can be found in ``examples/tutorial/first.py``: + +:: + + import ns.applications + import ns.core + import ns.internet + import ns.network + import ns.point_to_point + + ns.core.LogComponentEnable("UdpEchoClientApplication", ns.core.LOG_LEVEL_INFO) + ns.core.LogComponentEnable("UdpEchoServerApplication", ns.core.LOG_LEVEL_INFO) + + nodes = ns.network.NodeContainer() + nodes.Create(2) + + pointToPoint = ns.point_to_point.PointToPointHelper() + pointToPoint.SetDeviceAttribute("DataRate", ns.core.StringValue("5Mbps")) + pointToPoint.SetChannelAttribute("Delay", ns.core.StringValue("2ms")) + + devices = pointToPoint.Install(nodes) + + stack = ns.internet.InternetStackHelper() + stack.Install(nodes) + + address = ns.internet.Ipv4AddressHelper() + address.SetBase(ns.network.Ipv4Address("10.1.1.0"), ns.network.Ipv4Mask("255.255.255.0")) + + interfaces = address.Assign (devices); + + echoServer = ns.applications.UdpEchoServerHelper(9) + + serverApps = echoServer.Install(nodes.Get(1)) + serverApps.Start(ns.core.Seconds(1.0)) + serverApps.Stop(ns.core.Seconds(10.0)) + + echoClient = ns.applications.UdpEchoClientHelper(interfaces.GetAddress(1), 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(nodes.Get(0)) + clientApps.Start(ns.core.Seconds(2.0)) + clientApps.Stop(ns.core.Seconds(10.0)) + + ns.core.Simulator.Run() + ns.core.Simulator.Destroy() + +Running Python Scripts +********************** + +waf contains some options that automatically update the python path to find the ns3 module. To run example programs, there are two ways to use waf to take care of this. One is to run a waf shell; e.g.: + +:: + + ./waf --shell + python examples/mixed-wireless.py + +and the other is to use the --pyrun option to waf: + +:: + + ./waf --pyrun examples/mixed-wireless.py + +To run a python script under the C debugger: + +:: + + ./waf --shell + gdb --args python examples/mixed-wireless.py + +To run your own Python script that calls |ns3| and that has this path, ``/path/to/your/example/my-script.py``, do the following: + +:: + + ./waf --shell + python /path/to/your/example/my-script.py + +Caveats +******* + +Python bindings for |ns3| are a work in progress, and some limitations are known by developers. Some of these limitations (not all) are listed here. + +Incomplete Coverage ++++++++++++++++++++ + +First of all, keep in mind that not 100% of the API is supported in Python. Some of the reasons are: + +#. some of the APIs involve pointers, which require knowledge of what kind of memory passing semantics (who owns what memory). Such knowledge is not part of the function signatures, and is either documented or sometimes not even documented. Annotations are needed to bind those functions; +#. Sometimes a unusual fundamental data type or C++ construct is used which is not yet supported by PyBindGen; +#. GCC-XML does not report template based classes unless they are instantiated. + +Most of the missing APIs can be wrapped, given enough time, patience, and expertise, and will likely be wrapped if bug reports are submitted. However, don't file a bug report saying "bindings are incomplete", because we do not have manpower to complete 100% of the bindings. + +Conversion Constructors ++++++++++++++++++++++++ + +Conversion constructors (http://publib.boulder.ibm.com/infocenter/compbgpl/v9v111/topic/com.ibm.xlcpp9.bg.doc/language_ref/cplr384.htm) are not fully supported yet by PyBindGen, and they always act as explicit constructors when translating an API into Python. For example, in C++ you can do this: + +:: + + Ipv4AddressHelper ipAddrs; + ipAddrs.SetBase ("192.168.0.0", "255.255.255.0"); + ipAddrs.Assign (backboneDevices); + +In Python, for the time being you have to do: + +:: + + ipAddrs = ns3.Ipv4AddressHelper() + ipAddrs.SetBase(ns3.Ipv4Address("192.168.0.0"), ns3.Ipv4Mask("255.255.255.0")) + ipAddrs.Assign(backboneDevices) + +CommandLine ++++++++++++ + +:cpp:func:`CommandLine::AddValue` works differently in Python than it does in |ns3|. In Python, the first parameter is a string that represents the command-line option name. When the option is set, an attribute with the same name as the option name is set on the :cpp:func:`CommandLine` object. Example: + +:: + + NUM_NODES_SIDE_DEFAULT = 3 + + cmd = ns3.CommandLine() + + cmd.NumNodesSide = None + cmd.AddValue("NumNodesSide", "Grid side number of nodes (total number of nodes will be this number squared)") + + cmd.Parse(argv) + + [...] + + if cmd.NumNodesSide is None: + num_nodes_side = NUM_NODES_SIDE_DEFAULT + else: + num_nodes_side = int(cmd.NumNodesSide) + +Tracing ++++++++ + +Callback based tracing is not yet properly supported for Python, as new |ns3| API needs to be provided for this to be supported. + +Pcap file writing is supported via the normal API. + +Ascii tracing is supported since |ns3|.4 via the normal C++ API translated to Python. However, ascii tracing requires the creation of an ostream object to pass into the ascii tracing methods. In Python, the C++ std::ofstream has been minimally wrapped to allow this. For example: + +:: + + ascii = ns3.ofstream("wifi-ap.tr") # create the file + ns3.YansWifiPhyHelper.EnableAsciiAll(ascii) + ns3.Simulator.Run() + ns3.Simulator.Destroy() + ascii.close() # close the file + +There is one caveat: you must not allow the file object to be garbage collected while |ns3| is still using it. That means that the 'ascii' variable above must not be allowed to go out of scope or else the program will crash. + +Cygwin limitation ++++++++++++++++++ + +Python bindings do not work on Cygwin. This is due to a gccxml bug. + +You might get away with it by re-scanning API definitions from within the +cygwin environment (./waf --python-scan). However the most likely solution +will probably have to be that we disable python bindings in CygWin. + +If you really care about Python bindings on Windows, try building with mingw and native +python instead. Or else, to build without python bindings, disable python bindings in the configuration stage: + +:: + + ./waf configure --disable-python + +Working with Python Bindings +**************************** + +There are currently two kinds of Python bindings in |ns3|: + +#. Monolithic bindings contain API definitions for all of the modules and can be found in a single directory, ``bindings/python``. +#. Modular bindings contain API definitions for a single module and can be found in each module's ``bindings`` directory. + +Python Bindings Workflow +++++++++++++++++++++++++ + +The process by which Python bindings are handled is the following: + +#. Periodically a developer uses a GCC-XML (http://www.gccxml.org) based API scanning script, which saves the scanned API definition as ``bindings/python/ns3_module_*.py`` files or as Python files in each modules' ``bindings`` directory. These files are kept under version control in the main |ns3| repository; +#. Other developers clone the repository and use the already scanned API definitions; +#. When configuring |ns3|, pybindgen will be automatically downloaded if not already installed. Released |ns3| tarballs will ship a copy of pybindgen. + +If something goes wrong with compiling Python bindings and you just want to ignore them and move on with C++, you can disable Python with: + +:: + + ./waf --disable-python + +Instructions for Handling New Files or Changed API's +**************************************************** + +So you have been changing existing |ns3| APIs and Python bindings no longer compile? Do not despair, you can rescan the bindings to create new bindings that reflect the changes to the |ns3| API. + +Depending on if you are using monolithic or modular bindings, see the discussions below to learn how to rescan your Python bindings. + +Monolithic Python Bindings +************************** + +Scanning the Monolithic Python Bindings ++++++++++++++++++++++++++++++++++++++++ + +To scan the monolithic Python bindings do the following: + +:: + + ./waf --python-scan + +Organization of the Monolithic Python Bindings +++++++++++++++++++++++++++++++++++++++++++++++ + +The monolithic Python API definitions are organized as follows. For each |ns3| module , the file ``bindings/python/ns3_module_.py`` describes its API. Each of those files have 3 toplevel functions: + +#. :cpp:func:`def register_types(module)`: this function takes care of registering new types (e.g. C++ classes, enums) that are defined in tha module; +#. :cpp:func:`def register_methods(module)`: this function calls, for each class , another function register_methods_Ns3(module). These latter functions add method definitions for each class; +#. :cpp:func:`def register_functions(module)`: this function registers |ns3| functions that belong to that module. + +Modular Python Bindings +*********************** + +Overview +++++++++ + +Since ns 3.11, the modular bindings are being added, in parallel to the old monolithic bindings. + +The new python bindings are generated into an 'ns' namespace, instead of 'ns3' for the old bindings. Example: + +:: + + from ns.network import Node + n1 = Node() + +With modular Python bindings: + +#. There is one separate Python extension module for each |ns3| module; +#. Scanning API definitions (apidefs) is done on a per ns- module basis; +#. Each module's apidefs files are stored in a 'bindings' subdirectory of the module directory; + +Scanning the Modular Python Bindings ++++++++++++++++++++++++++++++++++++++++ + +To scan the modular Python bindings for the core module, for example, do the following: + +:: + + ./waf --apiscan=core + +To scan the modular Python bindings for all of the modules, do the following: + +:: + + ./waf --apiscan=all + +Creating a New Module ++++++++++++++++++++++ + +If you are adding a new module, Python bindings will continue to compile but will not cover the new module. + +To cover a new module, you have to create a ``bindings/python/ns3_module_.py`` file, similar to the what is described in the previous sections, and register it in the variable :cpp:func:`LOCAL_MODULES` in ``bindings/python/ns3modulegen.py`` + +Adding Modular Bindings To A Existing Module +++++++++++++++++++++++++++++++++++++++++++++ + +To add support for modular bindings to an existing |ns3| module, simply add the following line to its wscript build() function: + +:: + + bld.ns3_python_bindings() + +Organization of the Modular Python Bindings ++++++++++++++++++++++++++++++++++++++++++++ + +The ``src//bindings`` directory may contain the following files, some of them optional: + +* ``callbacks_list.py``: this is a scanned file, DO NOT TOUCH. Contains a list of Callback<...> template instances found in the scanned headers; +* ``modulegen__gcc_LP64.py``: this is a scanned file, DO NOT TOUCH. Scanned API definitions for the GCC, LP64 architecture (64-bit) +* ``modulegen__gcc_ILP32.py``: this is a scanned file, DO NOT TOUCH. Scanned API definitions for the GCC, ILP32 architecture (32-bit) +* ``modulegen_customizations.py``: you may optionally add this file in order to customize the pybindgen code generation +* ``scan-header.h``: you may optionally add this file to customize what header file is scanned for the module. Basically this file is scanned instead of ns3/-module.h. Typically, the first statement is #include "ns3/-module.h", plus some other stuff to force template instantiations; +* ``module_helpers.cc``: you may add additional files, such as this, to be linked to python extension module, but they have to be registered in the wscript. Look at src/core/wscript for an example of how to do so; +* ``.py``: if this file exists, it becomes the "frontend" python module for the ns3 module, and the extension module (.so file) becomes _.so instead of .so. The .py file has to import all symbols from the module _ (this is more tricky than it sounds, see src/core/bindings/core.py for an example), and then can add some additional pure-python definitions. + +More Information for Developers +******************************* + +If you are a developer and need more information on |ns3|'s Python bindings, please see the Python Bindings wiki page at ``_. diff --git a/doc/models/Makefile b/doc/models/Makefile index 2dd3991bb..28e7c4577 100644 --- a/doc/models/Makefile +++ b/doc/models/Makefile @@ -16,14 +16,13 @@ SOURCES = \ source/organization.rst \ source/internet-models.rst \ source/network.rst \ - source/devices.rst \ - source/routing.rst \ source/emulation-overview.rst \ - source/support.rst \ + $(SRC)/aodv/doc/aodv.rst \ $(SRC)/applications/doc/applications.rst \ $(SRC)/bridge/doc/bridge.rst \ $(SRC)/click/doc/click.rst \ $(SRC)/csma/doc/csma.rst \ + $(SRC)/dsdv/doc/dsdv.rst \ $(SRC)/mpi/doc/distributed.rst \ $(SRC)/energy/doc/energy.rst \ $(SRC)/emu/doc/emu.rst \ @@ -44,6 +43,7 @@ SOURCES = \ $(SRC)/internet/doc/ipv6.rst \ $(SRC)/internet/doc/routing-overview.rst \ $(SRC)/internet/doc/tcp.rst \ + $(SRC)/olsr/doc/olsr.rst \ $(SRC)/openflow/doc/openflow-switch.rst \ $(SRC)/point-to-point/doc/point-to-point.rst \ $(SRC)/wifi/doc/wifi.rst \ @@ -83,7 +83,9 @@ SOURCEFIGS = \ $(SRC)/lte/doc/source/figures/lenaThrTestCase2.eps \ $(SRC)/lte/doc/source/figures/simulationTime.eps \ $(SRC)/lte/doc/source/figures/memoryUsage.eps \ - $(SRC)/uan/doc/auvmobility-classes.dia \ + $(SRC)/uan/doc/auvmobility-classes.dia \ + $(SRC)/stats/doc/Stat-framework-arch.png \ + $(SRC)/stats/doc/Wifi-default.png \ $(SRC)/netanim/doc/animation-dumbbell.png \ $(SRC)/netanim/doc/animation-dumbbell.pdf \ diff --git a/doc/models/source/conf.py b/doc/models/source/conf.py index 23a7278ce..790c68773 100644 --- a/doc/models/source/conf.py +++ b/doc/models/source/conf.py @@ -48,9 +48,9 @@ copyright = u'2011, ns-3 project' # built documents. # # The short X.Y version. -version = 'ns-3.11' +version = 'ns-3-dev' # The full version, including alpha/beta/rc tags. -release = 'ns-3.11' +release = 'ns-3-dev' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/models/source/devices.rst b/doc/models/source/devices.rst deleted file mode 100644 index 249603c2e..000000000 --- a/doc/models/source/devices.rst +++ /dev/null @@ -1,14 +0,0 @@ -Devices and Channels --------------------- - -.. toctree:: - - bridge - csma - lte - point-to-point - mesh - wifi - wimax - simple - uan diff --git a/doc/models/source/index.rst b/doc/models/source/index.rst index 36b28e678..1bbe1d082 100644 --- a/doc/models/source/index.rst +++ b/doc/models/source/index.rst @@ -19,13 +19,27 @@ This document is written in `reStructuredText `_ to find copies of the manual. Finally, additional documentation about various aspects of |ns3| may -exist on the `project wiki `_). - -We organize this model library documentation loosely as follows. -We start with the models found in the ``src/network`` module, as this -module contains some fundamental models for the simulator. -The packet model, models for different address formats, and abstract -base classes for objects such as nodes, net devices, channels, sockets, and -applications are discussed here. - -We next group documentation under the following major headings: - -* Devices and Channels -* Emulation -* Internet Models -* Applications -* Support +exist on the `project wiki `_. A sample outline of how to write model library documentation can be found in :mod:`src/template/doc`. + +The remainder of this document is organized alphabetically by module name. + +If you are new to |ns3|, you might first want to read below about the network +module, which contains some fundamental models for the simulator. +The packet model, models for different address formats, and abstract +base classes for objects such as nodes, net devices, channels, sockets, and +applications are discussed there. + + diff --git a/doc/models/source/routing.rst b/doc/models/source/routing.rst deleted file mode 100644 index b9eb41d0f..000000000 --- a/doc/models/source/routing.rst +++ /dev/null @@ -1,7 +0,0 @@ -Routing and Switching ---------------------- - -.. toctree:: - - click - openflow-switch diff --git a/doc/models/source/support.rst b/doc/models/source/support.rst deleted file mode 100644 index 367c193b3..000000000 --- a/doc/models/source/support.rst +++ /dev/null @@ -1,8 +0,0 @@ -Support -------- - -.. toctree:: - - flow-monitor - animation - statistics diff --git a/doc/modules b/doc/modules index f58e8f671..62974397e 100644 --- a/doc/modules +++ b/doc/modules @@ -30,28 +30,4 @@ * - a configuration class used to set and control all attributes and trace sources * in a simulation: ns3::Config. * - * @defgroup network Network - * The "network" module contains: - * - a packet class to create and manipulate simulation packets: - * ns3::Packet, ns3::Header, and ns3::Trailer. This packet class - * also supports per-packet ns3::Tag which are globs of data - * which can be attached to any packet. - * - a ns3::Node base class which should be subclassed by any new type of - * network Node. - * - models which abstract the MAC-layer from the IP layer protocols: - * ns3::NetDevice and ns3::Channel. - * - models which abstract the application-layer API: ns3::Application, - * ns3::Socket, ns3::SocketFactory, and, ns3::Udp - * - * @defgroup internet Internet - * - * The "internet" module contains: - * - an Ipv4 stack - * - an Ipv6 stack - * - an ARP module - * - a UDP and a TCP implementation - * - * @defgroup applications Applications - * - * @defgroup mobility Mobility */ diff --git a/doc/release_steps.txt b/doc/release_steps.txt index f1b710581..505c1ed42 100644 --- a/doc/release_steps.txt +++ b/doc/release_steps.txt @@ -3,44 +3,73 @@ Steps in doing an ns-3 release 1. check out a clean ns-3-dev somewhere using ns-3-allinone (you will need it) - hg clone http://code.nsnam.org/ns-3-allinone - ./download.py - - ./build.py + - ./build.py --enable-examples --enable-tests - confirm that the release builds cleanly. - cd ns-3-dev - ensure that tests pass (./test.py) 2. prepare the source files - revise and check in AUTHORS, if needed - - revise and check in RELEASE_NOTES. Make sure to add the Availability - section. + - revise and check in RELEASE_NOTES. Make sure to edit the Availability + section if this is a final release. - DO NOT change VERSION at this time - confirm that Doxygen builds cleanly (./waf doxygen), - and check in any necessary changes + and check in any necessary changes. Currently, doxygen does not build + cleanly, we need to fix this over time. 3. build an ns-3-allinone distribution - - change back into the allinone directory + - you may want to check out a clean ns-3-allinone and ns-3-dev somewhere, + otherwise the tarball will be huge + - change into the allinone directory - ./dist.py - this will create an ns-allinone-dev.tar.bz2 tarball 4. test dev tarball on release platforms - ./test.py - other scripts you can think of -5. once you are happy with the tarball and tag ns-3-dev +5. once you are happy with the tarball, tag ns-3-dev - cd into ns-3-dev - - hg tag "ns-3.x" - - hg push + - if release candidate + -- hg tag "ns-3.x-RCy" + -- hg push ssh://code@code.nsnam.org//home/code/repos/ns-3.x-RCy + - else if final release + -- hg tag "ns-3.x" + -- hg push ssh://code@code.nsnam.org//home/code/repos/ns-3.x 6. clone the tagged ns-3-dev and place it on the repository - ssh code.nsnam.org; sudo bash; su code; - - cp -r /home/code/repos/ns-3-dev /home/code/repos/ns-3.x - - cd /home/code/repos/ns-3.x/.hg and edit the hgrc appropriately: - "description = ns-3.x release - name = ns-3.x" -7. check out a clean version of the new release (ns-3.x) somewhere - - hg clone http://code.nsnam.org/ns-3.x -8. Update the VERSION for this new release + - if release candidate + -- cp -r /home/code/repos/ns-3-dev /home/code/repos/ns-3.x-RCy + -- cd /home/code/repos/ns-3.x-RCy/.hg and edit the hgrc appropriately: + [paths] + default = /home/code/repos/ns-3.x-RCy + [web] + description = ns-3.x-RCy release + name = ns-3.x-RCy + contact = + - else if final release + -- cp -r /home/code/repos/ns-3-dev /home/code/repos/ns-3.x + -- cd /home/code/repos/ns-3.x/.hg and edit the hgrc appropriately: + [paths] + default = /home/code/repos/ns-3.x + [web] + description = ns-3.x release + name = ns-3.x + contact = +7. If this is a final release (not RC) + - archive ns-3.x RCs in /home/code/archived-repos + - delete ns-3.x RCs from /home/code/repos +8. check out a clean version of the new release (ns-3.x) or (ns-3.x-RCy) somewhere + - hg clone http://code.nsnam.org/ns-3.x or (-RCy) +9. Update the VERSION for this new release - change the string 3-dev in the VERSION file to the real version (e.g. 3.7 or 3.7-RC1) This must agree with the version name you chose in the clone. - - hg commit -m "update VERSION to ns-3.x" + - change the version and release string for the documentation in + doc/manual/source, doc/tutorial/source, and doc/models/source conf.py files + This should hopefully be updated in the future to simply pull from the + VERSION file. + - hg commit -m "update VERSION to ns-3.x" or (-RCy), you get the point - hg push ssh://code@code.nsnam.org//home/code/repos/ns-3.x - -9. Run the tests on the new release (debug and optimized) like a user would - You need to use ns-3-allinone since you will use that to make the distro +10. Run the tests on the new release (debug and optimized) like a user would + You need to use ns-3-allinone since you will use that to make the distro + It is convenient to let buildbot do much of this work for you, the day of + the release - hg clone http://code.nsnam.org/ns-3-allinone ns-3-allinone-3.x-test - cd !$ - ./download.py -n ns-3.x @@ -53,7 +82,7 @@ Steps in doing an ns-3 release - ./test.py - ./test.py -g - There should be no test errors at this time -10. Create final tarballs +11. Create final tarballs You need to work with a clean ns-3-allinone-3.x directory - hg clone http://code.nsnam.org/ns-3-allinone ns-3-allinone-3.x - cd !$ @@ -61,46 +90,43 @@ Steps in doing an ns-3 release - ./dist.py - notice we did not build here - this will create an ns-allinone-3.x.tar.bz2 tarball -11. upload "ns-allinone-3.x.tar.bz2" to the /var/www/html/releases/ directory on + - test this tarball out somewhere just to make sure everything went ok +12. upload "ns-allinone-3.x.tar.bz2" to the /var/www/html/releases/ directory on the www.nsnam.org server - scp ns-allinone-3.x.tar.bz2 www.nsnam.org:~ - ssh www.nsnam.org - sudo cp ns-allinone-3.x.tar.bz2 /var/www/html/releases - cd !$ -12. give it 644 file permissions, and user/group = apache if it is not already +13. give it 644 file permissions, and user/group = apache if it is not already - sudo chown apache:apache ns-allinone-3.x.tar.bz2 - sudo chmod 644 ns-allinone-3.x.tar.bz2 -13. update web pages on www.nsnam.org (source is in the www/ module) +14. if this is a final release (not RC) + - delete RC releases from /var/www/html/releases +15. if final release (not RC) build release documentation + - sudo bash; su nsnam; cd /home/nsnam/bin + - edit ./update-manual-release, ./update-tutorial-release, + ./update-doxygen-release and make sure RELEASE variable is + set correctly + - run ./update-manual-release, ./update-tutorial-release, + ./update-doxygen-release +16. update web pages on www.nsnam.org (source is in the www/ module) - clone the source repo (hg clone http://code.nsnam.org/www) - update references to releases in html_src (consider "grep 'ns-3\.' *.html" for a new release) (consider "grep 'RCx' *.html" for a new RC) + (consider looking at past commits to www for changes) - update references to releases in scripts/ - - update roadmap on wiki - commit and push changes -14. update the server + - update roadmap on wiki +17. update the server - build and update HTML directory on the server -- ssh www.nsnam.org; sudo bash; su nsnam; -- run ~/bin/update-html - - build and update Doxygen directory on the server - -- edit ~/bin/update-doxygen-release file and change RELEASE variable - to the right version number - -- run ~/bin/update-doxygen-release -15. build release documentation - - if this is final release (not RC) - -- archive old release documentation in /var/www/html/docs/release - by creating release specific folder and moving current - documenation into this folder - -- from ns-3.x/doc, enter manual/ testing/ and tutorial directories - and build the documentation using make - -- copy this newly created documentation into - /var/www/html/docs/release making sure to copy only the - necessary files -16. Final checks - - check manual, testing, and tutorial documentation links +18. Final checks + - check manual, tutorial, model, and doxygen documentation links - download tarball from web, build and run tests for as many targets as you can - download release from mercurial, build and run tests for as many targets as you can - test and verify until you're confident the release is solid. -17. announce to ns-developers, with summary of release notes +19. announce to ns-developers, with summary of release notes diff --git a/doc/tutorial/source/building-topologies.rst b/doc/tutorial/source/building-topologies.rst index 3c4666f99..395e69616 100644 --- a/doc/tutorial/source/building-topologies.rst +++ b/doc/tutorial/source/building-topologies.rst @@ -100,7 +100,7 @@ entirely comfortable with the following code at this point in the tutorial. cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma); cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose); - cmd.Parse (argc,argv); + cmd.Parse (argc, argv); if (verbose) { diff --git a/doc/tutorial/source/conceptual-overview.rst b/doc/tutorial/source/conceptual-overview.rst index 06ee0f4a3..32545cefb 100644 --- a/doc/tutorial/source/conceptual-overview.rst +++ b/doc/tutorial/source/conceptual-overview.rst @@ -155,10 +155,12 @@ directory structure something like the following: :: - AUTHORS doc/ README utils/ wscript - bindings/ examples/ RELEASE_NOTES VERSION wutils.py - build/ LICENSE scratch/ waf* wutils.pyc - CHANGES.html ns3/ src waf.bat* + AUTHORS examples scratch utils waf.bat* + bindings LICENSE src utils.py waf-tools + build ns3 test.py* utils.pyc wscript + CHANGES.html README testpy-output VERSION wutils.py + doc RELEASE_NOTES testpy.supp waf* wutils.pyc + Change into the ``examples/tutorial`` directory. You should see a file named ``first.cc`` located there. This is a script that will create a simple @@ -735,7 +737,7 @@ the ``scratch`` directory after changing back into the top level directory. :: - cd .. + cd ../.. cp examples/tutorial/first.cc scratch/myfirst.cc Now build your first example script using waf: @@ -823,7 +825,7 @@ most of our *repositories* will look: -rw-r--r-- 2009-07-01 12:47 +0200 7673 wutils.py file | revisions | annotate Our example scripts are in the ``examples`` directory. If you click on ``examples`` -you will see a list of files. One of the files in that directory is ``first.cc``. If +you will see a list of subdirectories. One of the files in ``tutorial`` subdirectory is ``first.cc``. If you click on ``first.cc`` you will find the code you just walked through. The source code is mainly in the ``src`` directory. You can view source diff --git a/doc/tutorial/source/conf.py b/doc/tutorial/source/conf.py index 7c0a9a952..76a761fb1 100644 --- a/doc/tutorial/source/conf.py +++ b/doc/tutorial/source/conf.py @@ -48,9 +48,9 @@ copyright = u'2010, ns-3 project' # built documents. # # The short X.Y version. -version = 'ns-3.10' +version = 'ns-3-dev' # The full version, including alpha/beta/rc tags. -release = 'ns-3.10' +release = 'ns-3-dev' # 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 2c61b2573..2c8f3c7c4 100644 --- a/doc/tutorial/source/getting-started.rst +++ b/doc/tutorial/source/getting-started.rst @@ -91,8 +91,8 @@ you will see a number of repositories. Many are the private repositories of the |ns3| development team. The repositories of interest to you will be prefixed with "ns-3". Official releases of |ns3| will be numbered as ``ns-3..``. For example, a second hotfix to a -still hypothetical release nine of |ns3| would be numbered as -``ns-3.9.2``. +still hypothetical release forty two of |ns3| would be numbered as +``ns-3.42.2``. The current development snapshot (unreleased) of |ns3| may be found at http://code.nsnam.org/ns-3-dev/. The @@ -207,10 +207,9 @@ directory. You should see something like the following there: :: - AUTHORS examples/ RELEASE_NOTES VERSION wutils.py - bindings/ LICENSE scratch/ waf* - CHANGES.html ns3/ src/ waf.bat* - doc/ README utils/ wscript + AUTHORS doc ns3 scratch testpy.supp VERSION waf-tools + bindings examples README src utils waf* wscript + CHANGES.html LICENSE RELEASE_NOTES test.py* utils.py waf.bat* wutils.py You are now ready to build the |ns3| distribution. @@ -281,19 +280,19 @@ following magic words: 'build' finished successfully (2m30.586s) Modules built: - aodv applications bridge - click config-store core - csma csma-layout dsdv - emu energy flow-monitor - internet lte mesh - mobility mpi netanim - network nix-vector-routing ns3tcp - ns3wifi olsr openflow - point-to-point point-to-point-layout propagation - spectrum stats tap-bridge - test tools topology-read - uan virtual-net-device visualizer - wifi wimax + aodv applications bridge + click config-store core + csma csma-layout dsdv + emu energy flow-monitor + internet lte mesh + mobility mpi netanim + network nix-vector-routing ns3tcp + ns3wifi olsr openflow + point-to-point point-to-point-layout propagation + spectrum stats tap-bridge + template test tools + topology-read uan virtual-net-device + visualizer wifi wimax Once the project has built you can say goodbye to your old friends, the ``ns-3-allinone`` scripts. You got what you needed from them and will now @@ -459,19 +458,19 @@ You will also see output from the test runner and the output will actually look 'build' finished successfully (1.799s) Modules built: - aodv applications bridge - click config-store core - csma csma-layout dsdv - emu energy flow-monitor - internet lte mesh - mobility mpi netanim - network nix-vector-routing ns3tcp - ns3wifi olsr openflow - point-to-point point-to-point-layout propagation - spectrum stats tap-bridge - test tools topology-read - uan virtual-net-device visualizer - wifi wimax + aodv applications bridge + click config-store core + csma csma-layout dsdv + emu energy flow-monitor + internet lte mesh + mobility mpi netanim + network nix-vector-routing ns3tcp + ns3wifi olsr openflow + point-to-point point-to-point-layout propagation + spectrum stats tap-bridge + template test tools + topology-read uan virtual-net-device + visualizer wifi wimax PASS: TestSuite ns3-wifi-interference PASS: TestSuite histogram @@ -489,7 +488,7 @@ You will also see output from the test runner and the output will actually look PASS: TestSuite basic-random-number PASS: TestSuite object PASS: TestSuite random-number-generators - 47 of 47 tests passed (47 passed, 0 failed, 0 crashed, 0 valgrind errors) + 95 of 95 tests passed (95 passed, 0 failed, 0 crashed, 0 valgrind errors) This command is typically run by ``users`` to quickly verify that an |ns3| distribution has built correctly. diff --git a/doc/tutorial/source/index.rst b/doc/tutorial/source/index.rst index 708be4c78..54f4b6bd6 100644 --- a/doc/tutorial/source/index.rst +++ b/doc/tutorial/source/index.rst @@ -1,14 +1,15 @@ .. only:: html or latex -Welcome to ns-3's tutorial! +ns-3 Tutorial =========================== -This is the *ns-3 tutorial*. Primary documentation for the ns-3 project is +This is the *ns-3 Tutorial*. Primary documentation for the ns-3 project is available in four forms: * `ns-3 Doxygen `_: Documentation of the public APIs of the simulator * `Tutorial `_: *(this document)* -* `Reference Manual `_: +* `Manual `_: +* `Model Library `_: * `ns-3 wiki `_ This document is written in `reStructuredText `_ for `Sphinx `_ and is maintained in the diff --git a/doc/tutorial/source/introduction.rst b/doc/tutorial/source/introduction.rst index 2094ffef4..6ba74a79f 100644 --- a/doc/tutorial/source/introduction.rst +++ b/doc/tutorial/source/introduction.rst @@ -89,18 +89,15 @@ community to develop new models, debug or maintain existing ones, and share results. There are a few policies that we hope will encourage people to contribute to |ns3| like they have for ns-2: -* Open source licensing based on GNU GPLv2 compatibility; +* Open source licensing based on GNU GPLv2 compatibility * `wiki - `_; + `_ * `Contributed Code `_ page, similar to ns-2's popular Contributed Code `page - `_; + `_ * Open `bug tracker - `_; -* |ns3| developers will gladly help potential contributors to get - started with the simulator (please contact `one of us - `_). + `_ We realize that if you are reading this document, contributing back to the project is probably not your foremost concern at this point, but diff --git a/examples/energy/energy-model-example.cc b/examples/energy/energy-model-example.cc index 5730b0726..8f0037e43 100644 --- a/examples/energy/energy-model-example.cc +++ b/examples/energy/energy-model-example.cc @@ -90,7 +90,7 @@ void RemainingEnergy (double oldValue, double remainingEnergy) { NS_LOG_UNCOND (Simulator::Now ().GetSeconds () - << "s Current remaining energy = " << remainingEnergy << "J"); + << "s Current remaining energy = " << remainingEnergy << "J"); } /// Trace function for total energy consumption at node. @@ -98,7 +98,7 @@ void TotalEnergy (double oldValue, double totalEnergy) { NS_LOG_UNCOND (Simulator::Now ().GetSeconds () - << "s Total energy consumed by radio = " << totalEnergy << "J"); + << "s Total energy consumed by radio = " << totalEnergy << "J"); } int diff --git a/examples/error-model/simple-error-model.cc b/examples/error-model/simple-error-model.cc index 3f5afaf3b..f4c4ad873 100644 --- a/examples/error-model/simple-error-model.cc +++ b/examples/error-model/simple-error-model.cc @@ -116,12 +116,12 @@ main (int argc, char *argv[]) OnOffHelper onoff ("ns3::UdpSocketFactory", Address (InetSocketAddress (i3i2.GetAddress (1), port))); - onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable(1))); - onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable(0))); + onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); + onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); ApplicationContainer apps = onoff.Install (c.Get (0)); - apps.Start(Seconds(1.0)); - apps.Stop (Seconds(10.0)); + apps.Start (Seconds (1.0)); + apps.Stop (Seconds (10.0)); // Create an optional packet sink to receive these packets PacketSinkHelper sink ("ns3::UdpSocketFactory", @@ -134,8 +134,8 @@ main (int argc, char *argv[]) onoff.SetAttribute ("Remote", AddressValue (InetSocketAddress (i1i2.GetAddress (0), port))); apps = onoff.Install (c.Get (3)); - apps.Start(Seconds(1.1)); - apps.Stop (Seconds(10.0)); + apps.Start (Seconds (1.1)); + apps.Stop (Seconds (10.0)); // Create a packet sink to receive these packets sink.SetAttribute ("Local", diff --git a/examples/ipv6/fragmentation-ipv6.cc b/examples/ipv6/fragmentation-ipv6.cc index b80fc449e..dd0ad41b8 100644 --- a/examples/ipv6/fragmentation-ipv6.cc +++ b/examples/ipv6/fragmentation-ipv6.cc @@ -78,7 +78,7 @@ public: std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; nbRoutes = routing->GetNRoutes (); - for (uint32_t i = 0 ; i < nbRoutes ; i++) + for (uint32_t i = 0; i < nbRoutes; i++) { route = routing->GetRoute (i); std::cout << route.GetDest () << "\t" @@ -134,7 +134,7 @@ int main (int argc, char** argv) Ipv6InterfaceContainer i2 = ipv6.Assign (d2); i2.SetRouter (0, true); - stackHelper.PrintRoutingTable(n0); + stackHelper.PrintRoutingTable (n0); /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r */ uint32_t packetSize = 4096; diff --git a/examples/ipv6/icmpv6-redirect.cc b/examples/ipv6/icmpv6-redirect.cc index 7d9aaf4f5..1ac5e4bc0 100644 --- a/examples/ipv6/icmpv6-redirect.cc +++ b/examples/ipv6/icmpv6-redirect.cc @@ -78,7 +78,7 @@ public: std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; nbRoutes = routing->GetNRoutes (); - for(uint32_t i = 0 ; i < nbRoutes ; i++) + for(uint32_t i = 0; i < nbRoutes; i++) { route = routing->GetRoute (i); std::cout << route.GetDest () << "\t" @@ -112,11 +112,11 @@ int main (int argc, char **argv) #if 0 LogComponentEnable ("Icmpv6RedirectExample", LOG_LEVEL_INFO); LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_INFO); - LogComponentEnable("Ipv6L3Protocol", LOG_LEVEL_ALL); - LogComponentEnable("Ipv6StaticRouting", LOG_LEVEL_ALL); - LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL); - LogComponentEnable("Icmpv6L4Protocol", LOG_LEVEL_ALL); - LogComponentEnable("NdiscCache", LOG_LEVEL_ALL); + LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL); + LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL); + LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL); + LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL); + LogComponentEnable ("NdiscCache", LOG_LEVEL_ALL); #endif CommandLine cmd; @@ -127,9 +127,9 @@ int main (int argc, char **argv) Ptr r1 = CreateObject (); Ptr r2 = CreateObject (); Ptr sta2 = CreateObject (); - NodeContainer net1(sta1, r1, r2); - NodeContainer net2(r2, sta2); - NodeContainer all(sta1, r1, r2, sta2); + NodeContainer net1 (sta1, r1, r2); + NodeContainer net2 (r2, sta2); + NodeContainer all (sta1, r1, r2, sta2); StackHelper stackHelper; @@ -138,8 +138,8 @@ int main (int argc, char **argv) NS_LOG_INFO ("Create channels."); CsmaHelper csma; - csma.SetChannelAttribute ("DataRate", DataRateValue(5000000)); - csma.SetChannelAttribute ("Delay", TimeValue(MilliSeconds (2))); + csma.SetChannelAttribute ("DataRate", DataRateValue (5000000)); + csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); NetDeviceContainer ndc1 = csma.Install (net1); NetDeviceContainer ndc2 = csma.Install (net2); @@ -157,8 +157,8 @@ int main (int argc, char **argv) stackHelper.AddHostRouteTo (r1, iic2.GetAddress (1, 1), iic1.GetAddress (2, 1), iic1.GetInterfaceIndex (1)); - Simulator::Schedule(Seconds(0.0), &StackHelper::PrintRoutingTable, &stackHelper, r1); - Simulator::Schedule(Seconds(3.0), &StackHelper::PrintRoutingTable, &stackHelper, sta1); + Simulator::Schedule (Seconds (0.0), &StackHelper::PrintRoutingTable, &stackHelper, r1); + Simulator::Schedule (Seconds (3.0), &StackHelper::PrintRoutingTable, &stackHelper, sta1); NS_LOG_INFO ("Create Applications."); uint32_t packetSize = 1024; @@ -166,10 +166,10 @@ int main (int argc, char **argv) Time interPacketInterval = Seconds (1.); Ping6Helper ping6; - ping6.SetLocal (iic1.GetAddress(0, 1)); - ping6.SetRemote (iic2.GetAddress(1, 1)); + ping6.SetLocal (iic1.GetAddress (0, 1)); + ping6.SetRemote (iic2.GetAddress (1, 1)); ping6.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount)); - ping6.SetAttribute ("Interval", TimeValue(interPacketInterval)); + ping6.SetAttribute ("Interval", TimeValue (interPacketInterval)); ping6.SetAttribute ("PacketSize", UintegerValue (packetSize)); ApplicationContainer apps = ping6.Install (sta1); apps.Start (Seconds (2.0)); diff --git a/examples/ipv6/loose-routing-ipv6.cc b/examples/ipv6/loose-routing-ipv6.cc index 0e1c79cf6..1cdb88b31 100644 --- a/examples/ipv6/loose-routing-ipv6.cc +++ b/examples/ipv6/loose-routing-ipv6.cc @@ -51,13 +51,13 @@ NS_LOG_COMPONENT_DEFINE ("LooseRoutingIpv6Example"); int main (int argc, char **argv) { #if 0 - LogComponentEnable("Ipv6ExtensionLooseRouting", LOG_LEVEL_ALL); - LogComponentEnable("Ipv6Extension", LOG_LEVEL_ALL); - LogComponentEnable("Ipv6L3Protocol", LOG_LEVEL_ALL); - LogComponentEnable("Ipv6StaticRouting", LOG_LEVEL_ALL); - LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL); - LogComponentEnable("Ipv6Interface", LOG_LEVEL_ALL); - LogComponentEnable("NdiscCache", LOG_LEVEL_ALL); + LogComponentEnable ("Ipv6ExtensionLooseRouting", LOG_LEVEL_ALL); + LogComponentEnable ("Ipv6Extension", LOG_LEVEL_ALL); + LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL); + LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL); + LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL); + LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL); + LogComponentEnable ("NdiscCache", LOG_LEVEL_ALL); #endif CommandLine cmd; @@ -91,9 +91,9 @@ int main (int argc, char **argv) NS_LOG_INFO ("Create channels."); CsmaHelper csma; - csma.SetDeviceAttribute ("Mtu", UintegerValue(1500)); - csma.SetChannelAttribute ("DataRate", DataRateValue(5000000)); - csma.SetChannelAttribute ("Delay", TimeValue(MilliSeconds (2))); + csma.SetDeviceAttribute ("Mtu", UintegerValue (1500)); + csma.SetChannelAttribute ("DataRate", DataRateValue (5000000)); + csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); NetDeviceContainer d1 = csma.Install (net1); NetDeviceContainer d2 = csma.Install (net2); NetDeviceContainer d3 = csma.Install (net3); @@ -152,7 +152,7 @@ int main (int argc, char **argv) /* remote address is first routers in RH0 => source routing */ client.SetRemote (i1.GetAddress (1, 1)); client.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount)); - client.SetAttribute ("Interval", TimeValue(interPacketInterval)); + client.SetAttribute ("Interval", TimeValue (interPacketInterval)); client.SetAttribute ("PacketSize", UintegerValue (packetSize)); client.SetRoutersAddress (routersAddress); ApplicationContainer apps = client.Install (h0); diff --git a/examples/ipv6/radvd-two-prefix.cc b/examples/ipv6/radvd-two-prefix.cc index 669c37835..0e3d037f9 100644 --- a/examples/ipv6/radvd-two-prefix.cc +++ b/examples/ipv6/radvd-two-prefix.cc @@ -85,7 +85,7 @@ public: std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; nbRoutes = routing->GetNRoutes (); - for (uint32_t i = 0 ; i < nbRoutes ; i++) + for (uint32_t i = 0; i < nbRoutes; i++) { route = routing->GetRoute (i); std::cout << route.GetDest () << "\t" diff --git a/examples/ipv6/test-ipv6.cc b/examples/ipv6/test-ipv6.cc index ab90f1aa1..ea9d00ad2 100644 --- a/examples/ipv6/test-ipv6.cc +++ b/examples/ipv6/test-ipv6.cc @@ -50,7 +50,7 @@ main (int argc, char *argv[]) Ipv6Address prefix1 ("2001:1::"); NS_LOG_INFO ("prefix = " << prefix1); - for (uint32_t i = 0; i < 10 ; ++i) + for (uint32_t i = 0; i < 10; ++i) { NS_LOG_INFO ("address = " << m_addresses[i]); Ipv6Address ipv6address = Ipv6Address::MakeAutoconfiguredAddress (m_addresses[i], prefix1); @@ -60,7 +60,7 @@ main (int argc, char *argv[]) Ipv6Address prefix2 ("2002:1:1::"); NS_LOG_INFO ("prefix = " << prefix2); - for (uint32_t i = 0; i < 10 ; ++i) + for (uint32_t i = 0; i < 10; ++i) { Ipv6Address ipv6address = Ipv6Address::MakeAutoconfiguredAddress (m_addresses[i], prefix2); NS_LOG_INFO ("address = " << ipv6address); diff --git a/examples/naming/object-names.cc b/examples/naming/object-names.cc index d4e8bd03f..eab56ee25 100644 --- a/examples/naming/object-names.cc +++ b/examples/naming/object-names.cc @@ -81,7 +81,7 @@ main (int argc, char *argv[]) internet.Install (n); CsmaHelper csma; - csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate(5000000))); + csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); csma.SetDeviceAttribute ("Mtu", UintegerValue (1400)); NetDeviceContainer d = csma.Install (n); diff --git a/examples/realtime/realtime-udp-echo.cc b/examples/realtime/realtime-udp-echo.cc index 08ac9be61..3693aa8f5 100644 --- a/examples/realtime/realtime-udp-echo.cc +++ b/examples/realtime/realtime-udp-echo.cc @@ -67,7 +67,7 @@ main (int argc, char *argv[]) // NS_LOG_INFO ("Create channels."); CsmaHelper csma; - csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate(5000000))); + csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); csma.SetDeviceAttribute ("Mtu", UintegerValue (1400)); NetDeviceContainer d = csma.Install (n); @@ -87,7 +87,7 @@ main (int argc, char *argv[]) // uint16_t port = 9; // well-known echo port number UdpEchoServerHelper server (port); - ApplicationContainer apps = server.Install (n.Get(1)); + ApplicationContainer apps = server.Install (n.Get (1)); apps.Start (Seconds (1.0)); apps.Stop (Seconds (10.0)); diff --git a/examples/routing/global-injection-slash32.cc b/examples/routing/global-injection-slash32.cc index 87e8e0174..ca689dae9 100644 --- a/examples/routing/global-injection-slash32.cc +++ b/examples/routing/global-injection-slash32.cc @@ -68,9 +68,9 @@ main (int argc, char *argv[]) internet.Install (nAnB); Ipv4ListRoutingHelper staticonly; Ipv4ListRoutingHelper staticRouting; - staticonly.Add(staticRouting, 0); - internet.SetRoutingHelper(staticonly); // has effect on the next Install () - internet.Install(NodeContainer(nC)); + staticonly.Add (staticRouting, 0); + internet.SetRoutingHelper (staticonly); // has effect on the next Install () + internet.Install (NodeContainer (nC)); // We create the channels first without any IP addressing information PointToPointHelper p2p; @@ -124,18 +124,18 @@ main (int argc, char *argv[]) // ...and the host in network "C" globalRouterB->InjectRoute ("192.168.1.1", "255.255.255.255"); - Ipv4GlobalRoutingHelper::RecomputeRoutingTables(); + Ipv4GlobalRoutingHelper::RecomputeRoutingTables (); // In addition, nB needs a static route to nC so it knows what to do with stuff // going to 192.168.1.1 Ipv4StaticRoutingHelper ipv4RoutingHelper; - Ptr staticRoutingB = ipv4RoutingHelper.GetStaticRouting(ipv4B); + Ptr staticRoutingB = ipv4RoutingHelper.GetStaticRouting (ipv4B); staticRoutingB->AddHostRouteTo (Ipv4Address ("192.168.1.1"), Ipv4Address ("10.1.1.6"),2); // Create the OnOff application to send UDP datagrams of size // 210 bytes at a rate of 448 Kb/s uint16_t port = 9; // Discard port (RFC 863) OnOffHelper onoff ("ns3::UdpSocketFactory", - Address (InetSocketAddress (ifInAddrC.GetLocal(), port))); + Address (InetSocketAddress (ifInAddrC.GetLocal (), port))); onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000))); diff --git a/examples/routing/global-routing-slash32.cc b/examples/routing/global-routing-slash32.cc index c237dfe4f..798f75e0e 100644 --- a/examples/routing/global-routing-slash32.cc +++ b/examples/routing/global-routing-slash32.cc @@ -106,7 +106,7 @@ main (int argc, char *argv[]) // 210 bytes at a rate of 448 Kb/s uint16_t port = 9; // Discard port (RFC 863) OnOffHelper onoff ("ns3::UdpSocketFactory", - Address (InetSocketAddress (ifInAddrC.GetLocal(), port))); + Address (InetSocketAddress (ifInAddrC.GetLocal (), port))); onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000))); diff --git a/examples/routing/manet-routing-compare.cc b/examples/routing/manet-routing-compare.cc new file mode 100644 index 000000000..121e6c269 --- /dev/null +++ b/examples/routing/manet-routing-compare.cc @@ -0,0 +1,366 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011 University of Kansas + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Justin Rohrer + * + * James P.G. Sterbenz , director + * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets + * Information and Telecommunication Technology Center (ITTC) + * and Department of Electrical Engineering and Computer Science + * The University of Kansas Lawrence, KS USA. + * + * Work supported in part by NSF FIND (Future Internet Design) Program + * under grant CNS-0626918 (Postmodern Internet Architecture), + * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI), + * US Department of Defense (DoD), and ITTC at The University of Kansas. + */ + +/* + * This example program allows one to run ns-3 DSDV, AODV, or OLSR under + * a typical random waypoint mobility model. + * + * By default, the simulation runs for 200 simulated seconds, of which + * the first 50 are used for start-up time. The number of nodes is 50. + * Nodes move according to RandomWaypointMobilityModel with a speed of + * 20 m/s and no pause time within a 300x1500 m region. The WiFi is + * in ad hoc mode with a 2 Mb/s rate (802.11b) and a Friis loss model. + * The transmit power is set to 7.5 dBm. + * + * It is possible to change the mobility and density of the network by + * directly modifying the speed and the number of nodes. It is also + * possible to change the characteristics of the network by changing + * the transmit power (as power increases, the impact of mobility + * decreases and the effective density increases). + * + * By default, OLSR is used, but specifying a value of 2 for the protocol + * will cause AODV to be used, and specifying a value of 3 will cause + * DSDV to be used. + * + * By default, there are 10 source/sink data pairs sending UDP data + * at an application rate of 2.048 Kb/s each. This is typically done + * at a rate of 4 64-byte packets per second. Application data is + * started at a random time between 50 and 51 seconds and continues + * to the end of the simulation. + * + * The program outputs a few items: + * - packet receptions are notified to stdout such as: + * received one packet from + * - each second, the data reception statistics are tabulated and output + * to a comma-separated value (csv) file + * - some tracing and flow monitor configuration that used to work is + * left commented inline in the program + */ + +#include +#include +#include "ns3/core-module.h" +#include "ns3/network-module.h" +#include "ns3/internet-module.h" +#include "ns3/mobility-module.h" +#include "ns3/wifi-module.h" +#include "ns3/aodv-module.h" +#include "ns3/olsr-module.h" +#include "ns3/dsdv-module.h" +#include "ns3/applications-module.h" + +using namespace ns3; + +NS_LOG_COMPONENT_DEFINE ("manet-routing-compare"); + +class RoutingExperiment +{ +public: + RoutingExperiment (); + void Run (int nSinks, int protocol, double txp, std::string CSVfileName); + //static void SetMACParam (ns3::NetDeviceContainer & devices, + // int slotDistance); + std::string CommandSetup (int argc, char **argv); + +private: + Ptr SetupPacketReceive (Ipv4Address addr, Ptr node); + void ReceivePacket (Ptr socket); + void CheckThroughput (); + + uint32_t port; + uint32_t bytesTotal; + uint32_t packetsReceived; + + std::string m_CSVfileName; + int m_nSinks; + std::string m_protocolName; + double m_txp; +}; + +RoutingExperiment::RoutingExperiment () + : port (9), + bytesTotal (0), + packetsReceived (0), + m_CSVfileName ("manet-routing.output.csv") +{ +} + +void +RoutingExperiment::ReceivePacket (Ptr socket) +{ + Ptr packet; + while (packet = socket->Recv ()) + { + bytesTotal += packet->GetSize (); + packetsReceived += 1; + SocketAddressTag tag; + bool found; + found = packet->PeekPacketTag (tag); + if (found) + { + InetSocketAddress addr = InetSocketAddress::ConvertFrom (tag.GetAddress ()); + NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId () + << " received one packet from " << addr.GetIpv4 ()); + //cast addr to void, to suppress 'addr' set but not used + //compiler warning in optimized builds + (void) addr; + } + else + { + NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << " " << socket->GetNode ()->GetId () + << " received one packet!"); + } + } +} + +void +RoutingExperiment::CheckThroughput () +{ + double kbs = (bytesTotal * 8.0) / 1000; + bytesTotal = 0; + + std::ofstream out (m_CSVfileName.c_str (), std::ios::app); + + out << (Simulator::Now ()).GetSeconds () << "," + << kbs << "," + << packetsReceived << "," + << m_nSinks << "," + << m_protocolName << "," + << m_txp << "" + << std::endl; + + out.close (); + packetsReceived = 0; + Simulator::Schedule (Seconds (1.0), &RoutingExperiment::CheckThroughput, this); +} + +Ptr +RoutingExperiment::SetupPacketReceive (Ipv4Address addr, Ptr node) +{ + TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); + Ptr sink = Socket::CreateSocket (node, tid); + InetSocketAddress local = InetSocketAddress (addr, port); + sink->Bind (local); + sink->SetRecvCallback (MakeCallback (&RoutingExperiment::ReceivePacket, this)); + + return sink; +} + +std::string +RoutingExperiment::CommandSetup (int argc, char **argv) +{ + CommandLine cmd; + cmd.AddValue ("CSVfileName", "The name of the CSV output file name", m_CSVfileName); + cmd.Parse (argc, argv); + return m_CSVfileName; +} + +int +main (int argc, char *argv[]) +{ + RoutingExperiment experiment; + std::string CSVfileName = experiment.CommandSetup (argc,argv); + + //blank out the last output file and write the column headers + std::ofstream out (CSVfileName.c_str ()); + out << "SimulationSecond," << + "ReceiveRate," << + "PacketsReceived," << + "NumberOfSinks," << + "RoutingProtocol," << + "TransmissionPower" << + std::endl; + out.close (); + + int nSinks = 10; + int protocol = 2; + double txp = 7.5; + + experiment = RoutingExperiment (); + experiment.Run (nSinks, protocol, txp, CSVfileName); +} + +void +RoutingExperiment::Run (int nSinks, int protocol, double txp, std::string CSVfileName) +{ + Packet::EnablePrinting (); + m_nSinks = nSinks; + m_txp = txp; + m_CSVfileName = CSVfileName; + + int nWifis = 50; + + double TotalTime = 200.0; + std::string rate ("2048bps"); + std::string phyMode ("DsssRate11Mbps"); + std::string tr_name ("Brock"); + int nodeSpeed = 20; //in m/s + int nodePause = 0; //in s + m_protocolName = "protocol"; + + Config::SetDefault ("ns3::OnOffApplication::PacketSize",StringValue ("64")); + Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (rate)); + + //Set Non-unicastMode rate to unicast mode + Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode",StringValue (phyMode)); + + NodeContainer adhocNodes; + adhocNodes.Create (nWifis); + + // setting up wifi phy and channel using helpers + WifiHelper wifi; + wifi.SetStandard (WIFI_PHY_STANDARD_80211b); + + YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); + YansWifiChannelHelper wifiChannel; + wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); + wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel"); + wifiPhy.SetChannel (wifiChannel.Create ()); + + // Add a non-QoS upper mac, and disable rate control + NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); + wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", + "DataMode",StringValue (phyMode), + "ControlMode",StringValue (phyMode)); + + wifiPhy.Set ("TxPowerStart",DoubleValue (txp)); + wifiPhy.Set ("TxPowerEnd", DoubleValue (txp)); + + wifiMac.SetType ("ns3::AdhocWifiMac"); + NetDeviceContainer adhocDevices = wifi.Install (wifiPhy, wifiMac, adhocNodes); + + AodvHelper aodv; + OlsrHelper olsr; + DsdvHelper dsdv; + Ipv4ListRoutingHelper list; + + switch (protocol) + { + case 1: + list.Add (olsr, 100); + m_protocolName = "OLSR"; + break; + case 2: + list.Add (aodv, 100); + m_protocolName = "AODV"; + break; + case 3: + list.Add (dsdv, 100); + m_protocolName = "DSDV"; + break; + default: + NS_FATAL_ERROR ("No such protocol:" << protocol); + } + + InternetStackHelper internet; + internet.SetRoutingHelper (list); + internet.Install (adhocNodes); + + NS_LOG_INFO ("assigning ip address"); + + Ipv4AddressHelper addressAdhoc; + addressAdhoc.SetBase ("10.1.1.0", "255.255.255.0"); + Ipv4InterfaceContainer adhocInterfaces; + adhocInterfaces = addressAdhoc.Assign (adhocDevices); + + MobilityHelper mobilityAdhoc; + + ObjectFactory pos; + pos.SetTypeId ("ns3::RandomRectanglePositionAllocator"); + pos.Set ("X", RandomVariableValue (UniformVariable (0.0, 300.0))); + pos.Set ("Y", RandomVariableValue (UniformVariable (0.0, 1500.0))); + + Ptr taPositionAlloc = pos.Create ()->GetObject (); + mobilityAdhoc.SetMobilityModel ("ns3::RandomWaypointMobilityModel", + "Speed", RandomVariableValue (UniformVariable (0.0, nodeSpeed)), + "Pause", RandomVariableValue (ConstantVariable (nodePause)), + "PositionAllocator", PointerValue (taPositionAlloc)); + mobilityAdhoc.SetPositionAllocator (taPositionAlloc); + mobilityAdhoc.Install (adhocNodes); + + OnOffHelper onoff1 ("ns3::UdpSocketFactory",Address ()); + onoff1.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); + onoff1.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); + + for (int i = 0; i <= nSinks - 1; i++) + { + Ptr sink = SetupPacketReceive (adhocInterfaces.GetAddress (i), adhocNodes.Get (i)); + + AddressValue remoteAddress (InetSocketAddress (adhocInterfaces.GetAddress (i), port)); + onoff1.SetAttribute ("Remote", remoteAddress); + + UniformVariable var; + ApplicationContainer temp = onoff1.Install (adhocNodes.Get (i + nSinks)); + temp.Start (Seconds (var.GetValue (50.0,51.0))); + temp.Stop (Seconds (TotalTime)); + } + + std::stringstream ss; + ss << nWifis; + std::string nodes = ss.str (); + + std::stringstream ss2; + ss2 << nodeSpeed; + std::string sNodeSpeed = ss2.str (); + + std::stringstream ss3; + ss3 << nodePause; + std::string sNodePause = ss3.str (); + + std::stringstream ss4; + ss4 << rate; + std::string sRate = ss4.str (); + + //NS_LOG_INFO ("Configure Tracing."); + //tr_name = tr_name + "_" + m_protocolName +"_" + nodes + "nodes_" + sNodeSpeed + "speed_" + sNodePause + "pause_" + sRate + "rate"; + + //std::ofstream ascii; + //ascii.open ((tr_name+".tr").c_str()); + //YansWifiPhyHelper::EnableAsciiAll (ascii); + //MobilityHelper::EnableAsciiAll (ascii); + + //Ptr flowmon; + //FlowMonitorHelper flowmonHelper; + //flowmon = flowmonHelper.InstallAll (); + + + NS_LOG_INFO ("Run Simulation."); + + CheckThroughput (); + + Simulator::Stop (Seconds (TotalTime)); + Simulator::Run (); + + //flowmon->SerializeToXmlFile ((tr_name + ".flowmon").c_str(), false, false); + + Simulator::Destroy (); +} + diff --git a/examples/routing/simple-alternate-routing.cc b/examples/routing/simple-alternate-routing.cc index 2c0b185e3..78fd63e17 100644 --- a/examples/routing/simple-alternate-routing.cc +++ b/examples/routing/simple-alternate-routing.cc @@ -54,8 +54,8 @@ main (int argc, char *argv[]) // Users may find it convenient to turn on explicit debugging // for selected modules; the below lines suggest how to do this #if 0 - LogComponentEnable("GlobalRoutingHelper", LOG_LOGIC); - LogComponentEnable("GlobalRouter", LOG_LOGIC); + LogComponentEnable ("GlobalRoutingHelper", LOG_LOGIC); + LogComponentEnable ("GlobalRouter", LOG_LOGIC); #endif diff --git a/examples/routing/simple-global-routing.cc b/examples/routing/simple-global-routing.cc index 915e60f30..91c57b1c3 100644 --- a/examples/routing/simple-global-routing.cc +++ b/examples/routing/simple-global-routing.cc @@ -70,7 +70,7 @@ main (int argc, char *argv[]) // DefaultValue::Bind ()s at run-time, via command-line arguments CommandLine cmd; bool enableFlowMonitor = false; - cmd.AddValue("EnableMonitor", "Enable Flow Monitor", enableFlowMonitor); + cmd.AddValue ("EnableMonitor", "Enable Flow Monitor", enableFlowMonitor); cmd.Parse (argc, argv); // Here, we will explicitly create four nodes. In more sophisticated @@ -78,9 +78,9 @@ main (int argc, char *argv[]) NS_LOG_INFO ("Create nodes."); NodeContainer c; c.Create (4); - NodeContainer n0n2 = NodeContainer (c.Get(0), c.Get (2)); - NodeContainer n1n2 = NodeContainer (c.Get(1), c.Get (2)); - NodeContainer n3n2 = NodeContainer (c.Get(3), c.Get (2)); + NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2)); + NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2)); + NodeContainer n3n2 = NodeContainer (c.Get (3), c.Get (2)); InternetStackHelper internet; internet.Install (c); diff --git a/examples/routing/simple-routing-ping6.cc b/examples/routing/simple-routing-ping6.cc index 0a707fe1c..5eb7158e0 100644 --- a/examples/routing/simple-routing-ping6.cc +++ b/examples/routing/simple-routing-ping6.cc @@ -79,7 +79,7 @@ public: std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl; nbRoutes = routing->GetNRoutes (); - for (uint32_t i = 0 ; i < nbRoutes ; i++) + for (uint32_t i = 0; i < nbRoutes; i++) { route = routing->GetRoute (i); std::cout << route.GetDest () << "\t" @@ -135,7 +135,7 @@ int main (int argc, char** argv) Ipv6InterfaceContainer i2 = ipv6.Assign (d2); i2.SetRouter (0, true); - stackHelper.PrintRoutingTable(n0); + stackHelper.PrintRoutingTable (n0); /* Create a Ping6 application to send ICMPv6 echo request from n0 to n1 via r */ uint32_t packetSize = 1024; diff --git a/examples/routing/wscript b/examples/routing/wscript index 689b0940c..9d5231482 100644 --- a/examples/routing/wscript +++ b/examples/routing/wscript @@ -33,4 +33,8 @@ def build(bld): ['csma', 'internet']) obj.source = 'simple-routing-ping6.cc' + obj = bld.create_ns3_program('manet-routing-compare', + ['wifi', 'dsdv', 'aodv', 'olsr', 'internet', 'applications']) + obj.source = 'manet-routing-compare.cc' + bld.register_ns3_script('simple-routing-ping6.py', ['csma', 'internet', 'applications']) diff --git a/examples/socket/socket-bound-static-routing.cc b/examples/socket/socket-bound-static-routing.cc index 9226402c8..0eba0b2f1 100644 --- a/examples/socket/socket-bound-static-routing.cc +++ b/examples/socket/socket-bound-static-routing.cc @@ -156,7 +156,7 @@ main (int argc, char *argv[]) Simulator::Schedule (Seconds (0.1),&SendStuff, srcSocket, dstaddr, dstport); // Second via Rtr1 explicitly Simulator::Schedule (Seconds (1.0),&BindSock, srcSocket, SrcToRtr1); - Simulator::Schedule (Seconds( 1.1),&SendStuff, srcSocket, dstaddr, dstport); + Simulator::Schedule (Seconds ( 1.1),&SendStuff, srcSocket, dstaddr, dstport); // Third via Rtr2 explicitly Simulator::Schedule (Seconds (2.0),&BindSock, srcSocket, SrcToRtr2); Simulator::Schedule (Seconds (2.1),&SendStuff, srcSocket, dstaddr, dstport); @@ -172,7 +172,7 @@ main (int argc, char *argv[]) return 0; } -void SendStuff(Ptr sock, Ipv4Address dstaddr, uint16_t port) +void SendStuff (Ptr sock, Ipv4Address dstaddr, uint16_t port) { Ptr p = Create (); p->AddPaddingAtEnd (100); @@ -180,7 +180,7 @@ void SendStuff(Ptr sock, Ipv4Address dstaddr, uint16_t port) return; } -void BindSock(Ptr sock, Ptr netdev) +void BindSock (Ptr sock, Ptr netdev) { sock->BindToNetDevice (netdev); return; @@ -193,7 +193,7 @@ srcSocketRecv (Ptr socket) Ptr packet = socket->RecvFrom (from); packet->RemoveAllPacketTags (); packet->RemoveAllByteTags (); - NS_LOG_INFO ("Source Received " << packet->GetSize () << " bytes from " << InetSocketAddress::ConvertFrom (from).GetIpv4()); + NS_LOG_INFO ("Source Received " << packet->GetSize () << " bytes from " << InetSocketAddress::ConvertFrom (from).GetIpv4 ()); if (socket->GetBoundNetDevice ()) { NS_LOG_INFO ("Socket was bound"); @@ -214,5 +214,5 @@ dstSocketRecv (Ptr socket) InetSocketAddress address = InetSocketAddress::ConvertFrom (from); NS_LOG_INFO ("Destination Received " << packet->GetSize () << " bytes from " << address.GetIpv4 ()); NS_LOG_INFO ("Triggering packet back to source node's interface 1"); - SendStuff(socket, Ipv4Address ("10.1.1.1"), address.GetPort ()); + SendStuff (socket, Ipv4Address ("10.1.1.1"), address.GetPort ()); } diff --git a/examples/socket/socket-bound-tcp-static-routing.cc b/examples/socket/socket-bound-tcp-static-routing.cc index 95baaaa11..e262fd514 100644 --- a/examples/socket/socket-bound-tcp-static-routing.cc +++ b/examples/socket/socket-bound-tcp-static-routing.cc @@ -157,7 +157,7 @@ main (int argc, char *argv[]) uint16_t dstport = 12345; Ipv4Address dstaddr ("10.20.1.2"); - PacketSinkHelper sink ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny(), dstport)); + PacketSinkHelper sink ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dstport)); ApplicationContainer apps = sink.Install (nDst); apps.Start (Seconds (0.0)); apps.Stop (Seconds (10.0)); @@ -189,15 +189,15 @@ main (int argc, char *argv[]) return 0; } -void BindSock(Ptr sock, Ptr netdev) +void BindSock (Ptr sock, Ptr netdev) { - sock->BindToNetDevice(netdev); + sock->BindToNetDevice (netdev); return; } -void StartFlow(Ptr localSocket, - Ipv4Address servAddress, - uint16_t servPort) +void StartFlow (Ptr localSocket, + Ipv4Address servAddress, + uint16_t servPort) { NS_LOG_INFO ("Starting flow at time " << Simulator::Now ().GetSeconds ()); currentTxBytes = 0; diff --git a/examples/stats/wifi-example-apps.cc b/examples/stats/wifi-example-apps.cc index 98f284ca9..56220ea01 100644 --- a/examples/stats/wifi-example-apps.cc +++ b/examples/stats/wifi-example-apps.cc @@ -40,31 +40,31 @@ using namespace ns3; NS_LOG_COMPONENT_DEFINE ("WiFiDistanceApps"); TypeId -Sender::GetTypeId(void) +Sender::GetTypeId (void) { static TypeId tid = TypeId ("Sender") .SetParent () .AddConstructor () .AddAttribute ("PacketSize", "The size of packets transmitted.", - UintegerValue(64), - MakeUintegerAccessor(&Sender::m_pktSize), + UintegerValue (64), + MakeUintegerAccessor (&Sender::m_pktSize), + MakeUintegerChecker(1)) + .AddAttribute ("Destination", "Target host address.", + Ipv4AddressValue ("255.255.255.255"), + MakeIpv4AddressAccessor (&Sender::m_destAddr), + MakeIpv4AddressChecker ()) + .AddAttribute ("Port", "Destination app port.", + UintegerValue (1603), + MakeUintegerAccessor (&Sender::m_destPort), + MakeUintegerChecker()) + .AddAttribute ("NumPackets", "Total number of packets to send.", + UintegerValue (30), + MakeUintegerAccessor (&Sender::m_numPkts), MakeUintegerChecker(1)) - .AddAttribute("Destination", "Target host address.", - Ipv4AddressValue("255.255.255.255"), - MakeIpv4AddressAccessor(&Sender::m_destAddr), - MakeIpv4AddressChecker()) - .AddAttribute("Port", "Destination app port.", - UintegerValue(1603), - MakeUintegerAccessor(&Sender::m_destPort), - MakeUintegerChecker()) - .AddAttribute("NumPackets", "Total number of packets to send.", - UintegerValue(30), - MakeUintegerAccessor(&Sender::m_numPkts), - MakeUintegerChecker(1)) .AddAttribute ("Interval", "Delay between transmissions.", - RandomVariableValue(ConstantVariable(0.5)), - MakeRandomVariableAccessor(&Sender::m_interval), - MakeRandomVariableChecker()) + RandomVariableValue (ConstantVariable (0.5)), + MakeRandomVariableAccessor (&Sender::m_interval), + MakeRandomVariableChecker ()) .AddTraceSource ("Tx", "A new packet is created and is sent", MakeTraceSourceAccessor (&Sender::m_txTrace)) ; @@ -93,54 +93,54 @@ Sender::DoDispose (void) Application::DoDispose (); } -void Sender::StartApplication() +void Sender::StartApplication () { NS_LOG_FUNCTION_NOARGS (); if (m_socket == 0) { - Ptr socketFactory = GetNode()->GetObject - (UdpSocketFactory::GetTypeId()); + Ptr socketFactory = GetNode ()->GetObject + (UdpSocketFactory::GetTypeId ()); m_socket = socketFactory->CreateSocket (); m_socket->Bind (); } m_count = 0; - Simulator::Cancel(m_sendEvent); - m_sendEvent = Simulator::ScheduleNow(&Sender::SendPacket, this); + Simulator::Cancel (m_sendEvent); + m_sendEvent = Simulator::ScheduleNow (&Sender::SendPacket, this); // end Sender::StartApplication } -void Sender::StopApplication() +void Sender::StopApplication () { NS_LOG_FUNCTION_NOARGS (); - Simulator::Cancel(m_sendEvent); + Simulator::Cancel (m_sendEvent); // end Sender::StopApplication } -void Sender::SendPacket() +void Sender::SendPacket () { // NS_LOG_FUNCTION_NOARGS (); - NS_LOG_INFO("Sending packet at " << Simulator::Now() << " to " << - m_destAddr); + NS_LOG_INFO ("Sending packet at " << Simulator::Now () << " to " << + m_destAddr); Ptr packet = Create(m_pktSize); TimestampTag timestamp; - timestamp.SetTimestamp(Simulator::Now()); + timestamp.SetTimestamp (Simulator::Now ()); packet->AddByteTag (timestamp); // Could connect the socket since the address never changes; using SendTo // here simply because all of the standard apps do not. - m_socket->SendTo(packet, 0, InetSocketAddress(m_destAddr, m_destPort)); + m_socket->SendTo (packet, 0, InetSocketAddress (m_destAddr, m_destPort)); // Report the event to the trace. - m_txTrace(packet); + m_txTrace (packet); if (++m_count < m_numPkts) { - m_sendEvent = Simulator::Schedule(Seconds(m_interval.GetValue()), - &Sender::SendPacket, this); + m_sendEvent = Simulator::Schedule (Seconds (m_interval.GetValue ()), + &Sender::SendPacket, this); } // end Sender::SendPacket @@ -153,22 +153,22 @@ void Sender::SendPacket() //-- Receiver //------------------------------------------------------ TypeId -Receiver::GetTypeId(void) +Receiver::GetTypeId (void) { static TypeId tid = TypeId ("Receiver") .SetParent () .AddConstructor () - .AddAttribute("Port", "Listening port.", - UintegerValue(1603), - MakeUintegerAccessor(&Receiver::m_port), - MakeUintegerChecker()) + .AddAttribute ("Port", "Listening port.", + UintegerValue (1603), + MakeUintegerAccessor (&Receiver::m_port), + MakeUintegerChecker()) ; return tid; } Receiver::Receiver() : - m_calc(0), - m_delay(0) + m_calc (0), + m_delay (0) { NS_LOG_FUNCTION_NOARGS (); m_socket = 0; @@ -190,75 +190,75 @@ Receiver::DoDispose (void) } void -Receiver::StartApplication() +Receiver::StartApplication () { NS_LOG_FUNCTION_NOARGS (); if (m_socket == 0) { - Ptr socketFactory = GetNode()->GetObject - (UdpSocketFactory::GetTypeId()); - m_socket = socketFactory->CreateSocket(); + Ptr socketFactory = GetNode ()->GetObject + (UdpSocketFactory::GetTypeId ()); + m_socket = socketFactory->CreateSocket (); InetSocketAddress local = - InetSocketAddress(Ipv4Address::GetAny(), m_port); - m_socket->Bind(local); + InetSocketAddress (Ipv4Address::GetAny (), m_port); + m_socket->Bind (local); } - m_socket->SetRecvCallback(MakeCallback(&Receiver::Receive, this)); + m_socket->SetRecvCallback (MakeCallback (&Receiver::Receive, this)); // end Receiver::StartApplication } void -Receiver::StopApplication() +Receiver::StopApplication () { NS_LOG_FUNCTION_NOARGS (); if (m_socket != 0) { - m_socket->SetRecvCallback(MakeNullCallback > ()); + m_socket->SetRecvCallback (MakeNullCallback > ()); } // end Receiver::StopApplication } void -Receiver::SetCounter(Ptr > calc) +Receiver::SetCounter (Ptr > calc) { m_calc = calc; // end Receiver::SetCounter } void -Receiver::SetDelayTracker(Ptr delay) +Receiver::SetDelayTracker (Ptr delay) { m_delay = delay; // end Receiver::SetDelayTracker } void -Receiver::Receive(Ptr socket) +Receiver::Receive (Ptr socket) { // NS_LOG_FUNCTION (this << socket << packet << from); Ptr packet; Address from; - while (packet = socket->RecvFrom(from)) { + while (packet = socket->RecvFrom (from)) { if (InetSocketAddress::IsMatchingType (from)) { - NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " << - InetSocketAddress::ConvertFrom (from).GetIpv4()); + NS_LOG_INFO ("Received " << packet->GetSize () << " bytes from " << + InetSocketAddress::ConvertFrom (from).GetIpv4 ()); } TimestampTag timestamp; // Should never not be found since the sender is adding it, but // you never know. - if (packet->FindFirstMatchingByteTag(timestamp)) { - Time tx = timestamp.GetTimestamp(); + if (packet->FindFirstMatchingByteTag (timestamp)) { + Time tx = timestamp.GetTimestamp (); if (m_delay != 0) { - m_delay->Update(Simulator::Now() - tx); + m_delay->Update (Simulator::Now () - tx); } } if (m_calc != 0) { - m_calc->Update(); + m_calc->Update (); } // end receiving packets @@ -274,21 +274,21 @@ Receiver::Receive(Ptr socket) //-- TimestampTag //------------------------------------------------------ TypeId -TimestampTag::GetTypeId(void) +TimestampTag::GetTypeId (void) { static TypeId tid = TypeId ("TimestampTag") .SetParent () .AddConstructor () .AddAttribute ("Timestamp", "Some momentous point in time!", - EmptyAttributeValue(), - MakeTimeAccessor(&TimestampTag::GetTimestamp), - MakeTimeChecker()) + EmptyAttributeValue (), + MakeTimeAccessor (&TimestampTag::GetTimestamp), + MakeTimeChecker ()) ; return tid; } TypeId -TimestampTag::GetInstanceTypeId(void) const +TimestampTag::GetInstanceTypeId (void) const { return GetTypeId (); } @@ -301,30 +301,30 @@ TimestampTag::GetSerializedSize (void) const void TimestampTag::Serialize (TagBuffer i) const { - int64_t t = m_timestamp.GetNanoSeconds(); - i.Write((const uint8_t *)&t, 8); + int64_t t = m_timestamp.GetNanoSeconds (); + i.Write ((const uint8_t *)&t, 8); } void TimestampTag::Deserialize (TagBuffer i) { int64_t t; - i.Read((uint8_t *)&t, 8); - m_timestamp = NanoSeconds(t); + i.Read ((uint8_t *)&t, 8); + m_timestamp = NanoSeconds (t); } void -TimestampTag::SetTimestamp(Time time) +TimestampTag::SetTimestamp (Time time) { m_timestamp = time; } Time -TimestampTag::GetTimestamp(void) const +TimestampTag::GetTimestamp (void) const { return m_timestamp; } void -TimestampTag::Print(std::ostream &os) const +TimestampTag::Print (std::ostream &os) const { os << "t=" << m_timestamp; } diff --git a/examples/stats/wifi-example-apps.h b/examples/stats/wifi-example-apps.h index 564a952a8..862efac93 100644 --- a/examples/stats/wifi-example-apps.h +++ b/examples/stats/wifi-example-apps.h @@ -39,18 +39,18 @@ using namespace ns3; //------------------------------------------------------ class Sender : public Application { public: - static TypeId GetTypeId(void); + static TypeId GetTypeId (void); Sender(); virtual ~Sender(); protected: - virtual void DoDispose(void); + virtual void DoDispose (void); private: - virtual void StartApplication(void); - virtual void StopApplication(void); + virtual void StartApplication (void); + virtual void StopApplication (void); - void SendPacket(); + void SendPacket (); uint32_t m_pktSize; Ipv4Address m_destAddr; @@ -74,21 +74,21 @@ private: //------------------------------------------------------ class Receiver : public Application { public: - static TypeId GetTypeId(void); + static TypeId GetTypeId (void); Receiver(); virtual ~Receiver(); - void SetCounter(Ptr > calc); - void SetDelayTracker(Ptr delay); + void SetCounter (Ptr > calc); + void SetDelayTracker (Ptr delay); protected: - virtual void DoDispose(void); + virtual void DoDispose (void); private: - virtual void StartApplication(void); - virtual void StopApplication(void); + virtual void StartApplication (void); + virtual void StopApplication (void); - void Receive(Ptr socket); + void Receive (Ptr socket); Ptr m_socket; @@ -114,10 +114,10 @@ public: virtual void Deserialize (TagBuffer i); // these are our accessors to our tag structure - void SetTimestamp(Time time); - Time GetTimestamp(void) const; + void SetTimestamp (Time time); + Time GetTimestamp (void) const; - void Print(std::ostream &os) const; + void Print (std::ostream &os) const; private: Time m_timestamp; diff --git a/examples/stats/wifi-example-sim.cc b/examples/stats/wifi-example-sim.cc index aad5709d2..05f30aead 100644 --- a/examples/stats/wifi-example-sim.cc +++ b/examples/stats/wifi-example-sim.cc @@ -54,11 +54,11 @@ NS_LOG_COMPONENT_DEFINE ("WiFiDistanceExperiment"); -void TxCallback(Ptr > datac, - std::string path, Ptr packet) { - NS_LOG_INFO("Sent frame counted in " << - datac->GetKey()); - datac->Update(); +void TxCallback (Ptr > datac, + std::string path, Ptr packet) { + NS_LOG_INFO ("Sent frame counted in " << + datac->GetKey ()); + datac->Update (); // end TxCallback } @@ -68,52 +68,52 @@ void TxCallback(Ptr > datac, //---------------------------------------------------------------------- //-- main //---------------------------------------------- -int main(int argc, char *argv[]) { +int main (int argc, char *argv[]) { double distance = 50.0; - string format("omnet"); + string format ("omnet"); - string experiment("wifi-distance-test"); - string strategy("wifi-default"); + string experiment ("wifi-distance-test"); + string strategy ("wifi-default"); string input; string runID; { stringstream sstr; - sstr << "run-" << time(NULL); - runID = sstr.str(); + sstr << "run-" << time (NULL); + runID = sstr.str (); } // Set up command line parameters used to control the experiment. CommandLine cmd; - cmd.AddValue("distance", "Distance apart to place nodes (in meters).", - distance); - cmd.AddValue("format", "Format to use for data output.", - format); - cmd.AddValue("experiment", "Identifier for experiment.", - experiment); - cmd.AddValue("strategy", "Identifier for strategy.", - strategy); - cmd.AddValue("run", "Identifier for run.", - runID); + cmd.AddValue ("distance", "Distance apart to place nodes (in meters).", + distance); + cmd.AddValue ("format", "Format to use for data output.", + format); + cmd.AddValue ("experiment", "Identifier for experiment.", + experiment); + cmd.AddValue ("strategy", "Identifier for strategy.", + strategy); + cmd.AddValue ("run", "Identifier for run.", + runID); cmd.Parse (argc, argv); if (format != "omnet" && format != "db") { - NS_LOG_ERROR("Unknown output format '" << format << "'"); + NS_LOG_ERROR ("Unknown output format '" << format << "'"); return -1; } #ifndef STATS_HAS_SQLITE3 if (format == "db") { - NS_LOG_ERROR("sqlite support not compiled in."); + NS_LOG_ERROR ("sqlite support not compiled in."); return -1; } #endif { - stringstream sstr(""); + stringstream sstr (""); sstr << distance; - input = sstr.str(); + input = sstr.str (); } @@ -122,24 +122,24 @@ int main(int argc, char *argv[]) { //------------------------------------------------------------ //-- Create nodes and network stacks //-------------------------------------------- - NS_LOG_INFO("Creating nodes."); + NS_LOG_INFO ("Creating nodes."); NodeContainer nodes; - nodes.Create(2); + nodes.Create (2); - NS_LOG_INFO("Installing WiFi and Internet stack."); + NS_LOG_INFO ("Installing WiFi and Internet stack."); WifiHelper wifi = WifiHelper::Default (); NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifiMac.SetType ("ns3::AdhocWifiMac"); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); - NetDeviceContainer nodeDevices = wifi.Install(wifiPhy, wifiMac, nodes); + NetDeviceContainer nodeDevices = wifi.Install (wifiPhy, wifiMac, nodes); InternetStackHelper internet; - internet.Install(nodes); + internet.Install (nodes); Ipv4AddressHelper ipAddrs; - ipAddrs.SetBase("192.168.0.0", "255.255.255.0"); - ipAddrs.Assign(nodeDevices); + ipAddrs.SetBase ("192.168.0.0", "255.255.255.0"); + ipAddrs.Assign (nodeDevices); @@ -147,14 +147,14 @@ int main(int argc, char *argv[]) { //------------------------------------------------------------ //-- Setup physical layout //-------------------------------------------- - NS_LOG_INFO("Installing static mobility; distance " << distance << " ."); + NS_LOG_INFO ("Installing static mobility; distance " << distance << " ."); MobilityHelper mobility; Ptr positionAlloc = CreateObject(); - positionAlloc->Add(Vector(0.0, 0.0, 0.0)); - positionAlloc->Add(Vector(0.0, distance, 0.0)); - mobility.SetPositionAllocator(positionAlloc); - mobility.Install(nodes); + positionAlloc->Add (Vector (0.0, 0.0, 0.0)); + positionAlloc->Add (Vector (0.0, distance, 0.0)); + mobility.SetPositionAllocator (positionAlloc); + mobility.Install (nodes); @@ -163,15 +163,15 @@ int main(int argc, char *argv[]) { //-- Create a custom traffic source and sink //-------------------------------------------- NS_LOG_INFO ("Create traffic source & sink."); - Ptr appSource = NodeList::GetNode(0); + Ptr appSource = NodeList::GetNode (0); Ptr sender = CreateObject(); - appSource->AddApplication(sender); - sender->SetStartTime(Seconds(1)); + appSource->AddApplication (sender); + sender->SetStartTime (Seconds (1)); - Ptr appSink = NodeList::GetNode(1); + Ptr appSink = NodeList::GetNode (1); Ptr receiver = CreateObject(); - appSink->AddApplication(receiver); - receiver->SetStartTime(Seconds(0)); + appSink->AddApplication (receiver); + receiver->SetStartTime (Seconds (0)); // Config::Set("/NodeList/*/ApplicationList/*/$Sender/Destination", // Ipv4AddressValue("192.168.0.2")); @@ -185,13 +185,13 @@ int main(int argc, char *argv[]) { // Create a DataCollector object to hold information about this run. DataCollector data; - data.DescribeRun(experiment, - strategy, - input, - runID); + data.DescribeRun (experiment, + strategy, + input, + runID); // Add any information we wish to record about this run. - data.AddMetadata("author", "tjkopena"); + data.AddMetadata ("author", "tjkopena"); // Create a counter to track how many frames are generated. Updates @@ -200,11 +200,11 @@ int main(int argc, char *argv[]) { // TxCallback() glue function defined above. Ptr > totalTx = CreateObject >(); - totalTx->SetKey("wifi-tx-frames"); - totalTx->SetContext("node[0]"); - Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx", - MakeBoundCallback(&TxCallback, totalTx)); - data.AddDataCalculator(totalTx); + totalTx->SetKey ("wifi-tx-frames"); + totalTx->SetContext ("node[0]"); + Config::Connect ("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx", + MakeBoundCallback (&TxCallback, totalTx)); + data.AddDataCalculator (totalTx); // This is similar, but creates a counter to track how many frames // are received. Instead of our own glue function, this uses a @@ -212,12 +212,12 @@ int main(int argc, char *argv[]) { // trace signal generated by the WiFi MAC. Ptr totalRx = CreateObject(); - totalRx->SetKey("wifi-rx-frames"); - totalRx->SetContext("node[1]"); - Config::Connect("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx", - MakeCallback(&PacketCounterCalculator::PacketUpdate, - totalRx)); - data.AddDataCalculator(totalRx); + totalRx->SetKey ("wifi-rx-frames"); + totalRx->SetContext ("node[1]"); + Config::Connect ("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx", + MakeCallback (&PacketCounterCalculator::PacketUpdate, + totalRx)); + data.AddDataCalculator (totalRx); @@ -227,12 +227,12 @@ int main(int argc, char *argv[]) { // by our Sender class. Ptr appTx = CreateObject(); - appTx->SetKey("sender-tx-packets"); - appTx->SetContext("node[0]"); - Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx", - MakeCallback(&PacketCounterCalculator::PacketUpdate, - appTx)); - data.AddDataCalculator(appTx); + appTx->SetKey ("sender-tx-packets"); + appTx->SetContext ("node[0]"); + Config::Connect ("/NodeList/0/ApplicationList/*/$Sender/Tx", + MakeCallback (&PacketCounterCalculator::PacketUpdate, + appTx)); + data.AddDataCalculator (appTx); // Here a counter for received packets is directly manipulated by // one of the custom objects in our simulation, the Receiver @@ -240,10 +240,10 @@ int main(int argc, char *argv[]) { // counter and calls its Update() method whenever a packet arrives. Ptr > appRx = CreateObject >(); - appRx->SetKey("receiver-rx-packets"); - appRx->SetContext("node[1]"); - receiver->SetCounter(appRx); - data.AddDataCalculator(appRx); + appRx->SetKey ("receiver-rx-packets"); + appRx->SetContext ("node[1]"); + receiver->SetCounter (appRx); + data.AddDataCalculator (appRx); @@ -267,13 +267,13 @@ int main(int argc, char *argv[]) { // avg, total # bytes), although in this scenaro they're fixed. Ptr appTxPkts = CreateObject(); - appTxPkts->SetKey("tx-pkt-size"); - appTxPkts->SetContext("node[0]"); - Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx", - MakeCallback - (&PacketSizeMinMaxAvgTotalCalculator::PacketUpdate, - appTxPkts)); - data.AddDataCalculator(appTxPkts); + appTxPkts->SetKey ("tx-pkt-size"); + appTxPkts->SetContext ("node[0]"); + Config::Connect ("/NodeList/0/ApplicationList/*/$Sender/Tx", + MakeCallback + (&PacketSizeMinMaxAvgTotalCalculator::PacketUpdate, + appTxPkts)); + data.AddDataCalculator (appTxPkts); // Here we directly manipulate another DataCollector tracking min, @@ -282,10 +282,10 @@ int main(int argc, char *argv[]) { // timestamps to do this. Ptr delayStat = CreateObject(); - delayStat->SetKey("delay"); - delayStat->SetContext("."); - receiver->SetDelayTracker(delayStat); - data.AddDataCalculator(delayStat); + delayStat->SetKey ("delay"); + delayStat->SetContext ("."); + receiver->SetDelayTracker (delayStat); + data.AddDataCalculator (delayStat); @@ -293,9 +293,8 @@ int main(int argc, char *argv[]) { //------------------------------------------------------------ //-- Run the simulation //-------------------------------------------- - NS_LOG_INFO("Run Simulation."); - Simulator::Run(); - Simulator::Destroy(); + NS_LOG_INFO ("Run Simulation."); + Simulator::Run (); @@ -307,21 +306,24 @@ int main(int argc, char *argv[]) { // Pick an output writer based in the requested format. Ptr output = 0; if (format == "omnet") { - NS_LOG_INFO("Creating omnet formatted data output."); + NS_LOG_INFO ("Creating omnet formatted data output."); output = CreateObject(); } else if (format == "db") { #ifdef STATS_HAS_SQLITE3 - NS_LOG_INFO("Creating sqlite formatted data output."); + NS_LOG_INFO ("Creating sqlite formatted data output."); output = CreateObject(); #endif } else { - NS_LOG_ERROR("Unknown output format " << format); + NS_LOG_ERROR ("Unknown output format " << format); } // Finally, have that writer interrogate the DataCollector and save // the results. if (output != 0) - output->Output(data); + output->Output (data); + + // Free any memory here at the end of this example. + Simulator::Destroy (); // end main } diff --git a/examples/tcp/star.cc b/examples/tcp/star.cc index b85bb15a5..68aee3b75 100644 --- a/examples/tcp/star.cc +++ b/examples/tcp/star.cc @@ -57,7 +57,7 @@ main (int argc, char *argv[]) uint32_t nSpokes = 8; CommandLine cmd; - cmd.AddValue("nSpokes", "Number of nodes to place in the star", nSpokes); + cmd.AddValue ("nSpokes", "Number of nodes to place in the star", nSpokes); cmd.Parse (argc, argv); NS_LOG_INFO ("Build star topology."); diff --git a/examples/tcp/tcp-large-transfer.cc b/examples/tcp/tcp-large-transfer.cc index 37e7030dc..8e5378acd 100644 --- a/examples/tcp/tcp-large-transfer.cc +++ b/examples/tcp/tcp-large-transfer.cc @@ -61,7 +61,7 @@ uint8_t data[writeSize]; // implement a sending "Application", although not a proper ns3::Application // subclass. -void StartFlow(Ptr, Ipv4Address, uint16_t); +void StartFlow (Ptr, Ipv4Address, uint16_t); void WriteUntilBufferFull (Ptr, uint32_t); static void @@ -104,8 +104,8 @@ int main (int argc, char *argv[]) // First make and configure the helper, so that it will put the appropriate // attributes on the network interfaces and channels we are about to install. PointToPointHelper p2p; - p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate(10000000))); - p2p.SetChannelAttribute ("Delay", TimeValue (MilliSeconds(10))); + p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate (10000000))); + p2p.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (10))); // And then install devices and channels connecting our topology. NetDeviceContainer dev0 = p2p.Install (n0n1); @@ -176,7 +176,7 @@ int main (int argc, char *argv[]) // Finally, set up the simulator to run. The 1000 second hard limit is a // failsafe in case some change above causes the simulation to never end - Simulator::Stop (Seconds(1000)); + Simulator::Stop (Seconds (1000)); Simulator::Run (); Simulator::Destroy (); } @@ -186,11 +186,11 @@ int main (int argc, char *argv[]) //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //begin implementation of sending "Application" -void StartFlow(Ptr localSocket, - Ipv4Address servAddress, - uint16_t servPort) +void StartFlow (Ptr localSocket, + Ipv4Address servAddress, + uint16_t servPort) { - NS_LOG_LOGIC("Starting flow at time " << Simulator::Now ().GetSeconds ()); + NS_LOG_LOGIC ("Starting flow at time " << Simulator::Now ().GetSeconds ()); localSocket->Connect (InetSocketAddress (servAddress, servPort)); //connect // tell the tcp implementation to call WriteUntilBufferFull again diff --git a/examples/tcp/tcp-nsc-lfn.cc b/examples/tcp/tcp-nsc-lfn.cc index 453994c62..168adff4c 100644 --- a/examples/tcp/tcp-nsc-lfn.cc +++ b/examples/tcp/tcp-nsc-lfn.cc @@ -62,10 +62,10 @@ int main (int argc, char *argv[]) CommandLine cmd; // Here, we define additional command line options. // This allows a user to override the defaults set above from the command line. - cmd.AddValue("TCP_CONGESTION", "Linux 2.6.26 Tcp Congestion control algorithm to use", tcpCong); - cmd.AddValue("error-rate", "Error rate to apply to link", errRate); - cmd.AddValue("runtime", "How long the applications should send data (default 120 seconds)", runtime); - cmd.AddValue("nscstack", "Set name of NSC stack (shared library) to use (default liblinux2.6.26.so)", nscStack); + cmd.AddValue ("TCP_CONGESTION", "Linux 2.6.26 Tcp Congestion control algorithm to use", tcpCong); + cmd.AddValue ("error-rate", "Error rate to apply to link", errRate); + cmd.AddValue ("runtime", "How long the applications should send data (default 120 seconds)", runtime); + cmd.AddValue ("nscstack", "Set name of NSC stack (shared library) to use (default liblinux2.6.26.so)", nscStack); cmd.Parse (argc, argv); NodeContainer n; @@ -73,19 +73,19 @@ int main (int argc, char *argv[]) PointToPointHelper p2p; // create point-to-point link with a bandwidth of 6MBit/s and a large delay (0.5 seconds) - p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate(6 * 1000 * 1000))); - p2p.SetChannelAttribute ("Delay", TimeValue (MilliSeconds(500))); + p2p.SetDeviceAttribute ("DataRate", DataRateValue (DataRate (6 * 1000 * 1000))); + p2p.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (500))); NetDeviceContainer p2pInterfaces = p2p.Install (n); // The default MTU of the p2p link would be 65535, which doesn't work // well with our default errRate (most packets would arrive corrupted). - p2pInterfaces.Get(0)->SetMtu(1500); - p2pInterfaces.Get(1)->SetMtu(1500); + p2pInterfaces.Get (0)->SetMtu (1500); + p2pInterfaces.Get (1)->SetMtu (1500); InternetStackHelper internet; // The next statement switches the nodes to 'NSC'-Mode. // It disables the native ns-3 TCP model and loads the NSC library. - internet.SetTcp ("ns3::NscTcpL4Protocol","Library",StringValue(nscStack)); + internet.SetTcp ("ns3::NscTcpL4Protocol","Library",StringValue (nscStack)); internet.Install (n); if (tcpCong != "cubic") // make sure we only fail if both --nscstack and --TCP_CONGESTION are used @@ -100,16 +100,16 @@ int main (int argc, char *argv[]) ipv4.SetBase ("10.0.0.0", "255.255.255.0"); Ipv4InterfaceContainer ipv4Interfaces = ipv4.Assign (p2pInterfaces); - DoubleValue rate(errRate); - RandomVariableValue u01(UniformVariable (0.0, 1.0)); + DoubleValue rate (errRate); + RandomVariableValue u01 (UniformVariable (0.0, 1.0)); Ptr em1 = CreateObjectWithAttributes ("RanVar", u01, "ErrorRate", rate); Ptr em2 = CreateObjectWithAttributes ("RanVar", u01, "ErrorRate", rate); // This enables the specified errRate on both link endpoints. - p2pInterfaces.Get(0)->SetAttribute("ReceiveErrorModel", PointerValue (em1)); - p2pInterfaces.Get(1)->SetAttribute("ReceiveErrorModel", PointerValue (em2)); + p2pInterfaces.Get (0)->SetAttribute ("ReceiveErrorModel", PointerValue (em1)); + p2pInterfaces.Get (1)->SetAttribute ("ReceiveErrorModel", PointerValue (em2)); Ipv4GlobalRoutingHelper::PopulateRoutingTables (); @@ -123,11 +123,11 @@ int main (int argc, char *argv[]) // This sets up two TCP flows, one from A -> B, one from B -> A. for (int i = 0, j = 1; i < 2; j--, i++) { - Address remoteAddress(InetSocketAddress(ipv4Interfaces.GetAddress (i), servPort)); + Address remoteAddress (InetSocketAddress (ipv4Interfaces.GetAddress (i), servPort)); OnOffHelper clientHelper ("ns3::TcpSocketFactory", remoteAddress); clientHelper.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); clientHelper.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); - ApplicationContainer clientApp = clientHelper.Install(n.Get(j)); + ApplicationContainer clientApp = clientHelper.Install (n.Get (j)); clientApp.Start (Seconds (1.0 + i)); clientApp.Stop (Seconds (runtime + 1.0 + i)); } @@ -135,7 +135,7 @@ int main (int argc, char *argv[]) // This tells ns-3 to generate pcap traces. p2p.EnablePcapAll ("tcp-nsc-lfn"); - Simulator::Stop (Seconds(900)); + Simulator::Stop (Seconds (900)); Simulator::Run (); Simulator::Destroy (); diff --git a/examples/tcp/tcp-nsc-zoo.cc b/examples/tcp/tcp-nsc-zoo.cc index 2fef085a3..c8c958b63 100644 --- a/examples/tcp/tcp-nsc-zoo.cc +++ b/examples/tcp/tcp-nsc-zoo.cc @@ -41,7 +41,7 @@ using namespace ns3; NS_LOG_COMPONENT_DEFINE ("TcpNscZoo"); // Simulates a diverse network with various stacks supported by NSC. -int main(int argc, char *argv[]) +int main (int argc, char *argv[]) { CsmaHelper csma; unsigned int MaxNodes = 4; @@ -51,8 +51,8 @@ int main(int argc, char *argv[]) Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("8kbps")); CommandLine cmd; // this allows the user to raise the number of nodes using --nodes=X command-line argument. - cmd.AddValue("nodes", "Number of nodes in the network (must be > 1)", MaxNodes); - cmd.AddValue("runtime", "How long the applications should send data (default 3 seconds)", runtime); + cmd.AddValue ("nodes", "Number of nodes in the network (must be > 1)", MaxNodes); + cmd.AddValue ("runtime", "How long the applications should send data (default 3 seconds)", runtime); cmd.Parse (argc, argv); if (MaxNodes < 2) @@ -60,18 +60,18 @@ int main(int argc, char *argv[]) std::cerr << "--nodes: must be >= 2" << std::endl; return 1; } - csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate(100 * 1000 * 1000))); + csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (100 * 1000 * 1000))); csma.SetChannelAttribute ("Delay", TimeValue (MicroSeconds (200))); NodeContainer n; - n.Create(MaxNodes); + n.Create (MaxNodes); NetDeviceContainer ethInterfaces = csma.Install (n); InternetStackHelper internetStack; - internetStack.SetTcp ("ns3::NscTcpL4Protocol","Library",StringValue("liblinux2.6.26.so")); + internetStack.SetTcp ("ns3::NscTcpL4Protocol","Library",StringValue ("liblinux2.6.26.so")); // this switches nodes 0 and 1 to NSCs Linux 2.6.26 stack. - internetStack.Install (n.Get(0)); - internetStack.Install (n.Get(1)); + internetStack.Install (n.Get (0)); + internetStack.Install (n.Get (1)); // this disables TCP SACK, wscale and timestamps on node 1 (the attributes represent sysctl-values). Config::Set ("/NodeList/1/$ns3::Ns3NscStack/net.ipv4.tcp_sack", StringValue ("0")); Config::Set ("/NodeList/1/$ns3::Ns3NscStack/net.ipv4.tcp_timestamps", StringValue ("0")); @@ -79,16 +79,16 @@ int main(int argc, char *argv[]) if (MaxNodes > 2) { - internetStack.Install (n.Get(2)); + internetStack.Install (n.Get (2)); } if (MaxNodes > 3) { // the next statement doesn't change anything for the nodes 0, 1, and 2; since they // already have a stack assigned. - internetStack.SetTcp ("ns3::NscTcpL4Protocol","Library",StringValue("liblinux2.6.26.so")); + internetStack.SetTcp ("ns3::NscTcpL4Protocol","Library",StringValue ("liblinux2.6.26.so")); // this switches node 3 to NSCs Linux 2.6.26 stack. - internetStack.Install (n.Get(3)); + internetStack.Install (n.Get (3)); // and then agains disables sack/timestamps/wscale on node 3. Config::Set ("/NodeList/3/$ns3::Ns3NscStack/net.ipv4.tcp_sack", StringValue ("0")); Config::Set ("/NodeList/3/$ns3::Ns3NscStack/net.ipv4.tcp_timestamps", StringValue ("0")); @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) // internetStack.SetNscStack ("libfreebsd5.so"); for (unsigned int i =4; i < MaxNodes; i++) { - internetStack.Install (n.Get(i)); + internetStack.Install (n.Get (i)); } Ipv4AddressHelper ipv4; @@ -115,21 +115,21 @@ int main(int argc, char *argv[]) sinkApp.Stop (Seconds (30.0)); // This tells every node on the network to start a flow to all other nodes on the network ... - for (unsigned int i = 0 ; i < MaxNodes; i++) + for (unsigned int i = 0; i < MaxNodes; i++) { - for (unsigned int j = 0 ; j < MaxNodes; j++) + for (unsigned int j = 0; j < MaxNodes; j++) { if (i == j) { // ...but we don't want a node to talk to itself. continue; } - Address remoteAddress(InetSocketAddress(ipv4Interfaces.GetAddress (j), servPort)); + Address remoteAddress (InetSocketAddress (ipv4Interfaces.GetAddress (j), servPort)); OnOffHelper clientHelper ("ns3::TcpSocketFactory", remoteAddress); clientHelper.SetAttribute - ("OnTime", RandomVariableValue (ConstantVariable (1))); + ("OnTime", RandomVariableValue (ConstantVariable (1))); clientHelper.SetAttribute - ("OffTime", RandomVariableValue (ConstantVariable (0))); - ApplicationContainer clientApp = clientHelper.Install(n.Get(i)); + ("OffTime", RandomVariableValue (ConstantVariable (0))); + ApplicationContainer clientApp = clientHelper.Install (n.Get (i)); clientApp.Start (Seconds (j)); /* delay startup depending on node number */ clientApp.Stop (Seconds (j + runtime)); } @@ -137,7 +137,7 @@ int main(int argc, char *argv[]) csma.EnablePcapAll ("tcp-nsc-zoo", false); - Simulator::Stop (Seconds(100)); + Simulator::Stop (Seconds (100)); Simulator::Run (); Simulator::Destroy (); diff --git a/examples/tcp/tcp-star-server.cc b/examples/tcp/tcp-star-server.cc index 879d28da1..f0157d45e 100644 --- a/examples/tcp/tcp-star-server.cc +++ b/examples/tcp/tcp-star-server.cc @@ -78,24 +78,24 @@ main (int argc, char *argv[]) // Allow the user to override any of the defaults and the above // Config::SetDefault()s at run-time, via command-line arguments CommandLine cmd; - cmd.AddValue("nNodes", "Number of nodes to place in the star", N); + cmd.AddValue ("nNodes", "Number of nodes to place in the star", N); cmd.Parse (argc, argv); // Here, we will create N nodes in a star. NS_LOG_INFO ("Create nodes."); NodeContainer serverNode; NodeContainer clientNodes; - serverNode.Create(1); - clientNodes.Create(N-1); - NodeContainer allNodes = NodeContainer(serverNode, clientNodes); + serverNode.Create (1); + clientNodes.Create (N-1); + NodeContainer allNodes = NodeContainer (serverNode, clientNodes); // Install network stacks on the nodes InternetStackHelper internet; internet.Install (allNodes); //Collect an adjacency list of nodes for the p2p topology - std::vector nodeAdjacencyList(N-1); - for(uint32_t i=0; i nodeAdjacencyList (N-1); + for(uint32_t i=0; i deviceAdjacencyList(N-1); - for(uint32_t i=0; i deviceAdjacencyList (N-1); + for(uint32_t i=0; i interfaceAdjacencyList(N-1); - for(uint32_t i=0; i interfaceAdjacencyList (N-1); + for(uint32_t i=0; iSetStartTime (Seconds (1.)); app->SetStopTime (Seconds (20.)); - devices.Get (1)->TraceConnectWithoutContext("PhyRxDrop", MakeCallback (&RxDrop)); + devices.Get (1)->TraceConnectWithoutContext ("PhyRxDrop", MakeCallback (&RxDrop)); - Simulator::Stop (Seconds(20)); + Simulator::Stop (Seconds (20)); Simulator::Run (); Simulator::Destroy (); diff --git a/examples/tutorial/first.cc b/examples/tutorial/first.cc index cb1481028..36a05b403 100644 --- a/examples/tutorial/first.cc +++ b/examples/tutorial/first.cc @@ -27,8 +27,8 @@ NS_LOG_COMPONENT_DEFINE ("FirstScriptExample"); int main (int argc, char *argv[]) { - LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); - LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); NodeContainer nodes; nodes.Create (2); diff --git a/examples/tutorial/fourth.cc b/examples/tutorial/fourth.cc index f1284ce6f..01787da67 100644 --- a/examples/tutorial/fourth.cc +++ b/examples/tutorial/fourth.cc @@ -52,7 +52,7 @@ int main (int argc, char *argv[]) { Ptr myObject = CreateObject (); - myObject->TraceConnectWithoutContext ("MyInteger", MakeCallback(&IntTrace)); + myObject->TraceConnectWithoutContext ("MyInteger", MakeCallback (&IntTrace)); myObject->m_myInt = 1234; } diff --git a/examples/tutorial/second.cc b/examples/tutorial/second.cc index 7c85f5c58..a486f5141 100644 --- a/examples/tutorial/second.cc +++ b/examples/tutorial/second.cc @@ -49,8 +49,8 @@ main (int argc, char *argv[]) if (verbose) { - LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); - LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); } nCsma = nCsma == 0 ? 1 : nCsma; diff --git a/examples/tutorial/sixth.cc b/examples/tutorial/sixth.cc index c0822b83d..915f2dc13 100644 --- a/examples/tutorial/sixth.cc +++ b/examples/tutorial/sixth.cc @@ -171,7 +171,7 @@ static void RxDrop (Ptr file, Ptr p) { NS_LOG_UNCOND ("RxDrop at " << Simulator::Now ().GetSeconds ()); - file->Write(Simulator::Now(), p); + file->Write (Simulator::Now (), p); } int @@ -200,7 +200,7 @@ main (int argc, char *argv[]) Ipv4InterfaceContainer interfaces = address.Assign (devices); uint16_t sinkPort = 8080; - Address sinkAddress (InetSocketAddress(interfaces.GetAddress (1), sinkPort)); + Address sinkAddress (InetSocketAddress (interfaces.GetAddress (1), sinkPort)); PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort)); ApplicationContainer sinkApps = packetSinkHelper.Install (nodes.Get (1)); sinkApps.Start (Seconds (0.)); @@ -220,9 +220,9 @@ main (int argc, char *argv[]) PcapHelper pcapHelper; Ptr file = pcapHelper.CreateFile ("sixth.pcap", std::ios::out, PcapHelper::DLT_PPP); - devices.Get (1)->TraceConnectWithoutContext("PhyRxDrop", MakeBoundCallback (&RxDrop, file)); + devices.Get (1)->TraceConnectWithoutContext ("PhyRxDrop", MakeBoundCallback (&RxDrop, file)); - Simulator::Stop (Seconds(20)); + Simulator::Stop (Seconds (20)); Simulator::Run (); Simulator::Destroy (); diff --git a/examples/tutorial/third.cc b/examples/tutorial/third.cc index c63da3327..29b2671ae 100644 --- a/examples/tutorial/third.cc +++ b/examples/tutorial/third.cc @@ -54,8 +54,8 @@ main (int argc, char *argv[]) if (verbose) { - LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); - LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); } NodeContainer p2pNodes; diff --git a/examples/udp-client-server/udp-client-server.cc b/examples/udp-client-server/udp-client-server.cc index 3ab40991c..64f38fd0a 100644 --- a/examples/udp-client-server/udp-client-server.cc +++ b/examples/udp-client-server/udp-client-server.cc @@ -58,7 +58,7 @@ main (int argc, char *argv[]) // Explicitly create the channels required by the topology (shown above). // CsmaHelper csma; - csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate(5000000))); + csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); csma.SetDeviceAttribute ("Mtu", UintegerValue (1400)); NetDeviceContainer d = csma.Install (n); @@ -77,7 +77,7 @@ main (int argc, char *argv[]) // uint16_t port = 4000; UdpServerHelper server (port); - ApplicationContainer apps = server.Install (n.Get(1)); + ApplicationContainer apps = server.Install (n.Get (1)); apps.Start (Seconds (1.0)); apps.Stop (Seconds (10.0)); diff --git a/examples/udp-client-server/udp-trace-client-server.cc b/examples/udp-client-server/udp-trace-client-server.cc index bbb9222a4..0aa9b9502 100644 --- a/examples/udp-client-server/udp-trace-client-server.cc +++ b/examples/udp-client-server/udp-trace-client-server.cc @@ -57,7 +57,7 @@ main (int argc, char *argv[]) // Explicitly create the channels required by the topology (shown above). // CsmaHelper csma; - csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate(5000000))); + csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); csma.SetDeviceAttribute ("Mtu", UintegerValue (1500)); NetDeviceContainer d = csma.Install (n); @@ -76,7 +76,7 @@ main (int argc, char *argv[]) // uint16_t port = 4000; UdpServerHelper server (port); - ApplicationContainer apps = server.Install (n.Get(1)); + ApplicationContainer apps = server.Install (n.Get (1)); apps.Start (Seconds (1.0)); apps.Stop (Seconds (10.0)); diff --git a/examples/udp/udp-echo.cc b/examples/udp/udp-echo.cc index 8e0c071f7..e6d214921 100644 --- a/examples/udp/udp-echo.cc +++ b/examples/udp/udp-echo.cc @@ -44,8 +44,8 @@ main (int argc, char *argv[]) // #if 0 LogComponentEnable ("UdpEchoExample", LOG_LEVEL_INFO); - LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_ALL); - LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_ALL); + LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_ALL); + LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_ALL); #endif // // Allow the user to override any of the defaults and the above Bind() at @@ -68,7 +68,7 @@ main (int argc, char *argv[]) // Explicitly create the channels required by the topology (shown above). // CsmaHelper csma; - csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate(5000000))); + csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); csma.SetDeviceAttribute ("Mtu", UintegerValue (1400)); NetDeviceContainer d = csma.Install (n); @@ -87,7 +87,7 @@ main (int argc, char *argv[]) // uint16_t port = 9; // well-known echo port number UdpEchoServerHelper server (port); - ApplicationContainer apps = server.Install (n.Get(1)); + ApplicationContainer apps = server.Install (n.Get (1)); apps.Start (Seconds (1.0)); apps.Stop (Seconds (10.0)); @@ -111,12 +111,12 @@ main (int argc, char *argv[]) // Users may find it convenient to initialize echo packets with actual data; // the below lines suggest how to do this // - client.SetFill(apps.Get (0), "Hello World"); + client.SetFill (apps.Get (0), "Hello World"); - client.SetFill(apps.Get (0), 0xa5, 1024); + client.SetFill (apps.Get (0), 0xa5, 1024); uint8_t fill[] = { 0, 1, 2, 3, 4, 5, 6}; - client.SetFill(apps.Get (0), fill, sizeof(fill), 1024); + client.SetFill (apps.Get (0), fill, sizeof(fill), 1024); #endif AsciiTraceHelper ascii; diff --git a/examples/wireless/mixed-wireless.cc b/examples/wireless/mixed-wireless.cc index 1c7acdc20..a565f31aa 100644 --- a/examples/wireless/mixed-wireless.cc +++ b/examples/wireless/mixed-wireless.cc @@ -115,12 +115,12 @@ main (int argc, char *argv[]) // "--backboneNodes=20" // CommandLine cmd; - cmd.AddValue("backboneNodes", "number of backbone nodes", backboneNodes); + cmd.AddValue ("backboneNodes", "number of backbone nodes", backboneNodes); cmd.AddValue ("infraNodes", "number of leaf nodes", infraNodes); - cmd.AddValue("lanNodes", "number of LAN nodes", lanNodes); - cmd.AddValue("stopTime", "simulation stop time (seconds)", stopTime); - cmd.AddValue("useCourseChangeCallback", "whether to enable course change tracing", useCourseChangeCallback); - cmd.AddValue("enableTracing", "enable tracing", enableTracing); + cmd.AddValue ("lanNodes", "number of LAN nodes", lanNodes); + cmd.AddValue ("stopTime", "simulation stop time (seconds)", stopTime); + cmd.AddValue ("useCourseChangeCallback", "whether to enable course change tracing", useCourseChangeCallback); + cmd.AddValue ("enableTracing", "enable tracing", enableTracing); // // The system global variables and the local values added to the argument @@ -273,10 +273,10 @@ main (int argc, char *argv[]) NqosWifiMacHelper macInfra = NqosWifiMacHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); // Create unique ssids for these networks - std::string ssidString("wifi-infra"); + std::string ssidString ("wifi-infra"); std::stringstream ss; ss << i; - ssidString += ss.str(); + ssidString += ss.str (); Ssid ssid = Ssid (ssidString); wifiInfra.SetRemoteStationManager ("ns3::ArfWifiManager"); // setup stas @@ -359,7 +359,7 @@ main (int argc, char *argv[]) uint32_t lastNodeIndex = backboneNodes + backboneNodes*(lanNodes - 1) + backboneNodes*(infraNodes - 1) - 1; Ptr appSink = NodeList::GetNode (lastNodeIndex); // Let's fetch the IP address of the last node, which is on Ipv4Interface 1 - Ipv4Address remoteAddr = appSink->GetObject ()->GetAddress(1, 0).GetLocal (); + Ipv4Address remoteAddr = appSink->GetObject ()->GetAddress (1, 0).GetLocal (); OnOffHelper onoff ("ns3::UdpSocketFactory", Address (InetSocketAddress (remoteAddr, port))); diff --git a/examples/wireless/multirate.cc b/examples/wireless/multirate.cc index e2a4e2020..65a643f43 100644 --- a/examples/wireless/multirate.cc +++ b/examples/wireless/multirate.cc @@ -91,7 +91,7 @@ private: Vector GetPosition (Ptr node); Ptr SetupPacketReceive (Ptr node); - NodeContainer GenerateNeighbors(NodeContainer c, uint32_t senderId); + NodeContainer GenerateNeighbors (NodeContainer c, uint32_t senderId); void ApplicationSetup (Ptr client, Ptr server, double start, double stop); void AssignNeighbors (NodeContainer c); @@ -130,7 +130,7 @@ Experiment::Experiment (std::string name) : m_output (name), totalTime (0.3), expMean (0.1), //flows being exponentially distributed - bytesTotal(0), + bytesTotal (0), packetSize (2000), gridSize (10), //10x10 grid for a total of 100 nodes nodeDistance (30), @@ -166,12 +166,12 @@ Experiment::ReceivePacket (Ptr socket) Ptr packet; while (packet = socket->Recv ()) { - bytesTotal += packet->GetSize(); + bytesTotal += packet->GetSize (); } } void -Experiment::CheckThroughput() +Experiment::CheckThroughput () { double mbs = ((bytesTotal * 8.0) /1000000); bytesTotal = 0; @@ -205,13 +205,13 @@ Experiment::AssignNeighbors (NodeContainer c) //lower left quadrant if ( i < totalNodes/2 ) { - containerA.Add(c.Get(i)); + containerA.Add (c.Get (i)); } //upper left quadrant if ( i >= (uint32_t)(4*totalNodes)/10 ) { - containerC.Add(c.Get(i)); + containerC.Add (c.Get (i)); } } if ( (i % gridSize) >= (gridSize/2 - 1)) @@ -219,13 +219,13 @@ Experiment::AssignNeighbors (NodeContainer c) //lower right quadrant if ( i < totalNodes/2 ) { - containerB.Add(c.Get(i)); + containerB.Add (c.Get (i)); } //upper right quadrant if ( i >= (uint32_t)(4*totalNodes)/10 ) { - containerD.Add(c.Get(i)); + containerD.Add (c.Get (i)); } } } @@ -243,11 +243,11 @@ Experiment::GenerateNeighbors (NodeContainer c, uint32_t senderId) for (uint32_t i= senderId - 2; i <= limit; i++) { //must ensure the boundaries for other topologies - nc.Add(c.Get(i)); - nc.Add(c.Get(i + 10)); - nc.Add(c.Get(i + 20)); - nc.Add(c.Get(i - 10)); - nc.Add(c.Get(i - 20)); + nc.Add (c.Get (i)); + nc.Add (c.Get (i + 10)); + nc.Add (c.Get (i + 20)); + nc.Add (c.Get (i - 10)); + nc.Add (c.Get (i - 20)); } return nc; } @@ -260,13 +260,13 @@ Experiment::GenerateNeighbors (NodeContainer c, uint32_t senderId) void Experiment::SelectSrcDest (NodeContainer c) { - uint32_t totalNodes = c.GetN(); + uint32_t totalNodes = c.GetN (); UniformVariable uvSrc (0, totalNodes/2 -1); UniformVariable uvDest (totalNodes/2, totalNodes); for (uint32_t i=0; i < totalNodes/3; i++) { - ApplicationSetup (c.Get(uvSrc.RandomVariable::GetInteger()), c.Get(uvDest.RandomVariable::GetInteger()), 0, totalTime); + ApplicationSetup (c.Get (uvSrc.RandomVariable::GetInteger ()), c.Get (uvDest.RandomVariable::GetInteger ()), 0, totalTime); } } @@ -277,28 +277,28 @@ Experiment::SelectSrcDest (NodeContainer c) * */ void -Experiment::SendMultiDestinations(Ptr sender, NodeContainer c) +Experiment::SendMultiDestinations (Ptr sender, NodeContainer c) { // UniformVariable params: (Xrange, Yrange) - UniformVariable uv(0, c.GetN ()); + UniformVariable uv (0, c.GetN ()); // ExponentialVariable params: (mean, upperbound) - ExponentialVariable ev(expMean, totalTime); + ExponentialVariable ev (expMean, totalTime); double start=0.0, stop=totalTime; uint32_t destIndex; for (uint32_t i=0; i < c.GetN (); i++) { - stop = start + ev.GetValue(); - NS_LOG_DEBUG("Start=" << start << " Stop=" << stop); + stop = start + ev.GetValue (); + NS_LOG_DEBUG ("Start=" << start << " Stop=" << stop); do { - destIndex = (uint32_t) uv.GetValue(); - } while ( (c.Get(destIndex))->GetId () == sender->GetId ()); + destIndex = (uint32_t) uv.GetValue (); + } while ( (c.Get (destIndex))->GetId () == sender->GetId ()); - ApplicationSetup (sender, c.Get(destIndex), start, stop); + ApplicationSetup (sender, c.Get (destIndex), start, stop); start = stop; @@ -319,20 +319,20 @@ Experiment::ApplicationSetup (Ptr client, Ptr server, double start, Ptr ipv4Server = server->GetObject(); Ptr ipv4Client = client->GetObject(); - Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress(1,0); - Ipv4InterfaceAddress iaddrClient = ipv4Client->GetAddress(1,0); + Ipv4InterfaceAddress iaddrServer = ipv4Server->GetAddress (1,0); + Ipv4InterfaceAddress iaddrClient = ipv4Client->GetAddress (1,0); Ipv4Address ipv4AddrServer = iaddrServer.GetLocal (); Ipv4Address ipv4AddrClient = iaddrClient.GetLocal (); - NS_LOG_DEBUG("Set up Server Device " << (server->GetDevice(0))->GetAddress () - << " with ip " << ipv4AddrServer - << " position (" << serverPos.x << "," << serverPos.y << "," << serverPos.z << ")"); + NS_LOG_DEBUG ("Set up Server Device " << (server->GetDevice (0))->GetAddress () + << " with ip " << ipv4AddrServer + << " position (" << serverPos.x << "," << serverPos.y << "," << serverPos.z << ")"); - NS_LOG_DEBUG("Set up Client Device " << (client->GetDevice(0))->GetAddress () - << " with ip " << ipv4AddrClient - << " position (" << clientPos.x << "," << clientPos.y << "," << clientPos.z << ")" - << "\n"); + NS_LOG_DEBUG ("Set up Client Device " << (client->GetDevice (0))->GetAddress () + << " with ip " << ipv4AddrClient + << " position (" << clientPos.x << "," << clientPos.y << "," << clientPos.z << ")" + << "\n"); //cast serverPos,clientPos,iaddrClient to void, to suppress variable set but not //used compiler warning in optimized builds @@ -341,12 +341,12 @@ Experiment::ApplicationSetup (Ptr client, Ptr server, double start, (void) ipv4AddrClient; // Equipping the source node with OnOff Application used for sending - OnOffHelper onoff ("ns3::UdpSocketFactory", Address(InetSocketAddress(Ipv4Address("10.0.0.1"), port))); + OnOffHelper onoff ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address ("10.0.0.1"), port))); onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); onoff.SetAttribute ("DataRate", DataRateValue (DataRate (60000000))); onoff.SetAttribute ("PacketSize", UintegerValue (packetSize)); - onoff.SetAttribute ("Remote", AddressValue(InetSocketAddress (ipv4AddrServer, port))); + onoff.SetAttribute ("Remote", AddressValue (InetSocketAddress (ipv4AddrServer, port))); ApplicationContainer apps = onoff.Install (client); apps.Start (Seconds (start)); @@ -388,7 +388,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, if (enableRouting) { - internet.SetRoutingHelper(list); // has effect on the next Install () + internet.SetRoutingHelper (list); // has effect on the next Install () } internet.Install (c); @@ -397,7 +397,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, address.SetBase ("10.0.0.0", "255.255.255.0"); Ipv4InterfaceContainer ipInterfaces; - ipInterfaces = address.Assign(devices); + ipInterfaces = address.Assign (devices); MobilityHelper mobil= mobility; mobil.SetPositionAllocator ("ns3::GridPositionAllocator", @@ -426,7 +426,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, if ( scenario == 1 && enableRouting) { - SelectSrcDest(c); + SelectSrcDest (c); } else if ( scenario == 2) { @@ -438,21 +438,21 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, } else if ( scenario == 3) { - AssignNeighbors(c); + AssignNeighbors (c); //Note: these senders are hand-picked in order to ensure good coverage //for 10x10 grid, basically one sender for each quadrant //you might have to change these values for other grids - NS_LOG_DEBUG(">>>>>>>>>region A<<<<<<<<<"); - SendMultiDestinations(c.Get(22), containerA); + NS_LOG_DEBUG (">>>>>>>>>region A<<<<<<<<<"); + SendMultiDestinations (c.Get (22), containerA); - NS_LOG_DEBUG(">>>>>>>>>region B<<<<<<<<<"); - SendMultiDestinations(c.Get(26), containerB); + NS_LOG_DEBUG (">>>>>>>>>region B<<<<<<<<<"); + SendMultiDestinations (c.Get (26), containerB); - NS_LOG_DEBUG(">>>>>>>>>region C<<<<<<<<<"); - SendMultiDestinations(c.Get(72), containerC); + NS_LOG_DEBUG (">>>>>>>>>region C<<<<<<<<<"); + SendMultiDestinations (c.Get (72), containerC); - NS_LOG_DEBUG(">>>>>>>>>region D<<<<<<<<<"); - SendMultiDestinations(c.Get(76), containerD); + NS_LOG_DEBUG (">>>>>>>>>region D<<<<<<<<<"); + SendMultiDestinations (c.Get (76), containerD); } else if ( scenario == 4) { @@ -461,38 +461,38 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, //you might have to change these values for other grids NodeContainer c1, c2, c3, c4, c5, c6, c7, c8, c9; - c1 = GenerateNeighbors(c, 22); - c2 = GenerateNeighbors(c, 24);; - c3 = GenerateNeighbors(c, 26);; - c4 = GenerateNeighbors(c, 42);; - c5 = GenerateNeighbors(c, 44);; - c6 = GenerateNeighbors(c, 46);; - c7 = GenerateNeighbors(c, 62);; - c8 = GenerateNeighbors(c, 64);; - c9 = GenerateNeighbors(c, 66);; + c1 = GenerateNeighbors (c, 22); + c2 = GenerateNeighbors (c, 24);; + c3 = GenerateNeighbors (c, 26);; + c4 = GenerateNeighbors (c, 42);; + c5 = GenerateNeighbors (c, 44);; + c6 = GenerateNeighbors (c, 46);; + c7 = GenerateNeighbors (c, 62);; + c8 = GenerateNeighbors (c, 64);; + c9 = GenerateNeighbors (c, 66);; - SendMultiDestinations(c.Get(22), c1); - SendMultiDestinations(c.Get(24), c2); - SendMultiDestinations(c.Get(26), c3); - SendMultiDestinations(c.Get(42), c4); - SendMultiDestinations(c.Get(44), c5); - SendMultiDestinations(c.Get(46), c6); - SendMultiDestinations(c.Get(62), c7); - SendMultiDestinations(c.Get(64), c8); - SendMultiDestinations(c.Get(66), c9); + SendMultiDestinations (c.Get (22), c1); + SendMultiDestinations (c.Get (24), c2); + SendMultiDestinations (c.Get (26), c3); + SendMultiDestinations (c.Get (42), c4); + SendMultiDestinations (c.Get (44), c5); + SendMultiDestinations (c.Get (46), c6); + SendMultiDestinations (c.Get (62), c7); + SendMultiDestinations (c.Get (64), c8); + SendMultiDestinations (c.Get (66), c9); } CheckThroughput (); if (enablePcap) { - phy.EnablePcapAll(GetOutputFileName()); + phy.EnablePcapAll (GetOutputFileName ()); } if (enableTracing) { AsciiTraceHelper ascii; - phy.EnableAsciiAll (ascii.CreateFileStream (GetOutputFileName() + ".tr")); + phy.EnableAsciiAll (ascii.CreateFileStream (GetOutputFileName () + ".tr")); } Ptr flowmon; @@ -508,7 +508,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, if (enableFlowMon) { - flowmon->SerializeToXmlFile ((GetOutputFileName() + ".flomon"), false, false); + flowmon->SerializeToXmlFile ((GetOutputFileName () + ".flomon"), false, false); } Simulator::Destroy (); @@ -541,13 +541,13 @@ int main (int argc, char *argv[]) experiment = Experiment ("multirate"); //for commandline input - experiment.CommandSetup(argc, argv); + experiment.CommandSetup (argc, argv); // set value to 0 for enabling fragmentation Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2200")); - Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue (experiment.GetRtsThreshold())); + Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue (experiment.GetRtsThreshold ())); - std::ofstream outfile ((experiment.GetOutputFileName()+ ".plt").c_str()); + std::ofstream outfile ((experiment.GetOutputFileName ()+ ".plt").c_str ()); MobilityHelper mobility; Gnuplot gnuplot; @@ -560,16 +560,16 @@ int main (int argc, char *argv[]) Ssid ssid = Ssid ("Testbed"); wifiMac.SetType ("ns3::AdhocWifiMac", - "Ssid", SsidValue(ssid)); + "Ssid", SsidValue (ssid)); wifi.SetStandard (WIFI_PHY_STANDARD_holland); - wifi.SetRemoteStationManager (experiment.GetRateManager()); + wifi.SetRemoteStationManager (experiment.GetRateManager ()); NS_LOG_INFO ("Scenario: " << experiment.GetScenario ()); - NS_LOG_INFO ("Rts Threshold: " << experiment.GetRtsThreshold()); - NS_LOG_INFO ("Name: " << experiment.GetOutputFileName()); - NS_LOG_INFO ("Rate: " << experiment.GetRateManager()); - NS_LOG_INFO ("Routing: " << experiment.IsRouting()); - NS_LOG_INFO ("Mobility: " << experiment.IsMobility()); + NS_LOG_INFO ("Rts Threshold: " << experiment.GetRtsThreshold ()); + NS_LOG_INFO ("Name: " << experiment.GetOutputFileName ()); + NS_LOG_INFO ("Rate: " << experiment.GetRateManager ()); + NS_LOG_INFO ("Routing: " << experiment.IsRouting ()); + NS_LOG_INFO ("Mobility: " << experiment.IsMobility ()); dataset = experiment.Run (wifi, wifiPhy, wifiMac, wifiChannel, mobility); diff --git a/examples/wireless/ofdm-validation.cc b/examples/wireless/ofdm-validation.cc index 9cc417ddb..02c22c289 100644 --- a/examples/wireless/ofdm-validation.cc +++ b/examples/wireless/ofdm-validation.cc @@ -54,7 +54,7 @@ int main (int argc, char *argv[]) Ptr yans = CreateObject (); Ptr nist = CreateObject (); - for (uint32_t i = 0; i < modes.size(); i++) + for (uint32_t i = 0; i < modes.size (); i++) { std::cout << modes[i] << std::endl; Gnuplot2dDataset yansdataset (modes[i]); @@ -62,9 +62,9 @@ int main (int argc, char *argv[]) for (double snr = -5.0; snr <= 30.0; snr += 0.1) { - double ps = yans->GetChunkSuccessRate(WifiMode(modes[i]), pow(10.0,snr/10.0), FrameSize*8); + double ps = yans->GetChunkSuccessRate (WifiMode (modes[i]), pow (10.0,snr/10.0), FrameSize*8); yansdataset.Add (snr, ps); - ps = nist->GetChunkSuccessRate(WifiMode(modes[i]), pow(10.0,snr/10.0), FrameSize*8); + ps = nist->GetChunkSuccessRate (WifiMode (modes[i]), pow (10.0,snr/10.0), FrameSize*8); nistdataset.Add (snr, ps); } diff --git a/examples/wireless/wifi-adhoc.cc b/examples/wireless/wifi-adhoc.cc index 1caf2d906..1c15aa97a 100644 --- a/examples/wireless/wifi-adhoc.cc +++ b/examples/wireless/wifi-adhoc.cc @@ -138,7 +138,7 @@ Experiment::Run (const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, mobility.Install (c); PacketSocketAddress socket; - socket.SetSingleDevice(devices.Get (0)->GetIfIndex ()); + socket.SetSingleDevice (devices.Get (0)->GetIfIndex ()); socket.SetPhysicalAddress (devices.Get (1)->GetAddress ()); socket.SetProtocol (1); diff --git a/examples/wireless/wifi-ap.cc b/examples/wireless/wifi-ap.cc index a685e1dee..ae3443488 100644 --- a/examples/wireless/wifi-ap.cc +++ b/examples/wireless/wifi-ap.cc @@ -165,7 +165,7 @@ int main (int argc, char *argv[]) Simulator::Schedule (Seconds (1.0), &AdvancePosition, ap.Get (0)); PacketSocketAddress socket; - socket.SetSingleDevice(staDevs.Get (0)->GetIfIndex ()); + socket.SetSingleDevice (staDevs.Get (0)->GetIfIndex ()); socket.SetPhysicalAddress (staDevs.Get (1)->GetAddress ()); socket.SetProtocol (1); @@ -187,8 +187,8 @@ int main (int argc, char *argv[]) Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/State", MakeCallback (&PhyStateTrace)); AthstatsHelper athstats; - athstats.EnableAthstats("athstats-sta", stas); - athstats.EnableAthstats("athstats-ap", ap); + athstats.EnableAthstats ("athstats-sta", stas); + athstats.EnableAthstats ("athstats-ap", ap); Simulator::Run (); diff --git a/examples/wireless/wifi-clear-channel-cmu.cc b/examples/wireless/wifi-clear-channel-cmu.cc index 881572bdc..c5306a0c8 100644 --- a/examples/wireless/wifi-clear-channel-cmu.cc +++ b/examples/wireless/wifi-clear-channel-cmu.cc @@ -181,7 +181,7 @@ int main (int argc, char *argv[]) Gnuplot gnuplot = Gnuplot ("clear-channel.eps"); - for (uint32_t i = 0; i < modes.size(); i++) + for (uint32_t i = 0; i < modes.size (); i++) { std::cout << modes[i] << std::endl; Gnuplot2dDataset dataset (modes[i]); @@ -197,14 +197,14 @@ int main (int argc, char *argv[]) Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (modes[i])); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode",StringValue(modes[i]), - "ControlMode",StringValue(modes[i])); + "DataMode",StringValue (modes[i]), + "ControlMode",StringValue (modes[i])); wifiMac.SetType ("ns3::AdhocWifiMac"); YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default (); - YansWifiChannelHelper wifiChannel ; + YansWifiChannelHelper wifiChannel; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); - wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss)); + wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss)); NS_LOG_DEBUG (modes[i]); diff --git a/examples/wireless/wifi-hidden-terminal.cc b/examples/wireless/wifi-hidden-terminal.cc index 56d6ee490..f03443d4c 100644 --- a/examples/wireless/wifi-hidden-terminal.cc +++ b/examples/wireless/wifi-hidden-terminal.cc @@ -54,7 +54,7 @@ void experiment (bool enableCtsRts) // 2. Place nodes somehow, this is required by every wireless simulation for (size_t i = 0; i < 3; ++i) { - nodes.Get(i)->AggregateObject (CreateObject ()); + nodes.Get (i)->AggregateObject (CreateObject ()); } // 3. Create propagation loss matrix @@ -140,7 +140,7 @@ void experiment (bool enableCtsRts) // 8. Install FlowMonitor on all nodes FlowMonitorHelper flowmon; - Ptr monitor = flowmon.InstallAll(); + Ptr monitor = flowmon.InstallAll (); // 9. Run simulation for 10 seconds Simulator::Stop (Seconds (10)); diff --git a/examples/wireless/wifi-simple-adhoc-grid.cc b/examples/wireless/wifi-simple-adhoc-grid.cc index 4357a2051..5e5bb6a49 100644 --- a/examples/wireless/wifi-simple-adhoc-grid.cc +++ b/examples/wireless/wifi-simple-adhoc-grid.cc @@ -163,7 +163,7 @@ int main (int argc, char *argv[]) // ns-3 supports RadioTap and Prism tracing extensions for 802.11b wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - YansWifiChannelHelper wifiChannel ; + YansWifiChannelHelper wifiChannel; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel"); wifiPhy.SetChannel (wifiChannel.Create ()); @@ -172,8 +172,8 @@ int main (int argc, char *argv[]) NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifi.SetStandard (WIFI_PHY_STANDARD_80211b); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode",StringValue(phyMode), - "ControlMode",StringValue(phyMode)); + "DataMode",StringValue (phyMode), + "ControlMode",StringValue (phyMode)); // Set it to adhoc mode wifiMac.SetType ("ns3::AdhocWifiMac"); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c); diff --git a/examples/wireless/wifi-simple-adhoc.cc b/examples/wireless/wifi-simple-adhoc.cc index fb124351b..a898aa966 100644 --- a/examples/wireless/wifi-simple-adhoc.cc +++ b/examples/wireless/wifi-simple-adhoc.cc @@ -136,18 +136,18 @@ int main (int argc, char *argv[]) // ns-3 supports RadioTap and Prism tracing extensions for 802.11b wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - YansWifiChannelHelper wifiChannel ; + YansWifiChannelHelper wifiChannel; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); // The below FixedRssLossModel will cause the rss to be fixed regardless // of the distance between the two stations, and the transmit power - wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss)); + wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss)); wifiPhy.SetChannel (wifiChannel.Create ()); // Add a non-QoS upper mac, and disable rate control NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode",StringValue(phyMode), - "ControlMode",StringValue(phyMode)); + "DataMode",StringValue (phyMode), + "ControlMode",StringValue (phyMode)); // Set it to adhoc mode wifiMac.SetType ("ns3::AdhocWifiMac"); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c); diff --git a/examples/wireless/wifi-simple-infra.cc b/examples/wireless/wifi-simple-infra.cc index 34db660de..44ee4b52e 100644 --- a/examples/wireless/wifi-simple-infra.cc +++ b/examples/wireless/wifi-simple-infra.cc @@ -137,18 +137,18 @@ int main (int argc, char *argv[]) // ns-3 supports RadioTap and Prism tracing extensions for 802.11b wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - YansWifiChannelHelper wifiChannel ; + YansWifiChannelHelper wifiChannel; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); // The below FixedRssLossModel will cause the rss to be fixed regardless // of the distance between the two stations, and the transmit power - wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss)); + wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss)); wifiPhy.SetChannel (wifiChannel.Create ()); // Add a non-QoS upper mac, and disable rate control NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode",StringValue(phyMode), - "ControlMode",StringValue(phyMode)); + "DataMode",StringValue (phyMode), + "ControlMode",StringValue (phyMode)); // Setup the rest of the upper mac Ssid ssid = Ssid ("wifi-default"); @@ -156,12 +156,12 @@ int main (int argc, char *argv[]) wifiMac.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid), "ActiveProbing", BooleanValue (false)); - NetDeviceContainer staDevice = wifi.Install (wifiPhy, wifiMac, c.Get(0)); + NetDeviceContainer staDevice = wifi.Install (wifiPhy, wifiMac, c.Get (0)); NetDeviceContainer devices = staDevice; // setup ap. wifiMac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid)); - NetDeviceContainer apDevice = wifi.Install (wifiPhy, wifiMac, c.Get(1)); + NetDeviceContainer apDevice = wifi.Install (wifiPhy, wifiMac, c.Get (1)); devices.Add (apDevice); // Note that with FixedRssLossModel, the positions below are not diff --git a/examples/wireless/wifi-simple-interference.cc b/examples/wireless/wifi-simple-interference.cc index acdc55f31..fab85ba36 100644 --- a/examples/wireless/wifi-simple-interference.cc +++ b/examples/wireless/wifi-simple-interference.cc @@ -184,7 +184,7 @@ int main (int argc, char *argv[]) // ns-3 supports RadioTap and Prism tracing extensions for 802.11b wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - YansWifiChannelHelper wifiChannel ; + YansWifiChannelHelper wifiChannel; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel"); wifiPhy.SetChannel (wifiChannel.Create ()); @@ -192,8 +192,8 @@ int main (int argc, char *argv[]) // Add a non-QoS upper mac, and disable rate control NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode",StringValue(phyMode), - "ControlMode",StringValue(phyMode)); + "DataMode",StringValue (phyMode), + "ControlMode",StringValue (phyMode)); // Set it to adhoc mode wifiMac.SetType ("ns3::AdhocWifiMac"); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c.Get (0)); @@ -226,7 +226,7 @@ int main (int argc, char *argv[]) TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); Ptr recvSink = Socket::CreateSocket (c.Get (0), tid); - InetSocketAddress local = InetSocketAddress (Ipv4Address("10.1.1.1"), 80); + InetSocketAddress local = InetSocketAddress (Ipv4Address ("10.1.1.1"), 80); recvSink->Bind (local); recvSink->SetRecvCallback (MakeCallback (&ReceivePacket)); diff --git a/src/aodv/doc/aodv.h b/src/aodv/doc/aodv.h index 37853a9ca..9aebb6cbc 100644 --- a/src/aodv/doc/aodv.h +++ b/src/aodv/doc/aodv.h @@ -31,55 +31,8 @@ /** * \defgroup aodv AODV Routing - * - * This model implements the base specification of the Ad hoc on demand distance vector (AODV) - * protocol. Implementation is based on RFC3561. - * - * Class aodv::RoutingProtocol implements all functionality of service packet exchange and inherits Ipv4RoutingProtocol. - * Base class defines two virtual functions for packet routing and forwarding. The first one, - * RouteOutput(), is used for locally originated packets, and the second one, RouteInput(), is used for forwarding - * and/or delivering received packets. - * - * Protocol operation depends on the many adjustable parameters. Parameters for this functionality are attributes of - * aodv::RoutingProtocol. We support parameters, with their default values, from RFC and parameters that enable/disable - * protocol features, such as broadcasting HELLO messages, broadcasting data packets and so on. - * - * AODV discovers routes on demand. Therefore, our AODV model buffer all packets, while a route request packet (RREQ) - * is disseminated. We implement a packet queue in aodv-rqueue.cc. Smart pointer to packet, Ipv4RoutingProtocol::ErrorCallback, - * Ipv4RoutingProtocol::UnicastForwardCallback and IP header are stored in this queue. The packet queue implements garbage collection of old - * packets and a queue size limit. - * - * Routing table implementation support garbage collection of old entries and state machine, defined in standard. - * It implements as a STL map container. The key is a destination IP address. - * - * Some moments of protocol operation aren't described in RFC. This moments generally concern cooperation of different OSI model layers. - * We use following heuristics: - * - * 1) This AODV implementation can detect the presence of unidirectional links and avoid them if necessary. - * If the node we received a RREQ for is a neighbor we are probably facing a unidirectional link... - * This heuristic is taken from AODV-UU implementation and can be disabled. - * - * 2) Protocol operation strongly depends on broken link detection mechanism. We implements two such heuristics. - * First, this implementation support HELLO messages. However HELLO messages are not a good way to do neighbor sensing - * in a wireless environment (at least not over 802.11). Therefore, you may experience bad performance when running over wireless. - * There are several reasons for this: - * -# HELLO messages are broadcasted. In 802.11, broadcasting is done at a lower bit rate than unicasting, - * thus HELLO messages travel further than data. - * -# HELLO messages are small, thus less prone to bit errors than data transmissions. - * -# Broadcast transmissions are not guaranteed to be bidirectional, unlike unicast transmissions. - * Second, we use layer 2 feedback when possible. Link considered to be broken, if frame transmission results in a transmission - * failure for all retries. This mechanism meant for active links and work much more faster, than first method. - * Layer 2 feedback implementation relies on TxErrHeader trace source, currently it is supported in AdhocWifiMac only. - * - * 3) Duplicate packet detection. We use special class DuplicatePacketDetection for this purpose. - * - * Following optional protocol optimizations aren't implemented: - * - Expanding ring search. - * - Local link repair. - * - RREP, RREQ and HELLO message extensions. - * This techniques require direct access to IP header, which contradict assertion from AODV RFC that AODV works over UDP. Our model use UDP - * for simplicity, but this disable us to implement protocol optimizations. We don't use low layer raw socket, because they are not portable. * + * This section documents the API of the ns-3 AODV module. For a generic functional description, please refer to the ns-3 manual. */ #endif /* AODV_H */ diff --git a/src/aodv/doc/aodv.rst b/src/aodv/doc/aodv.rst new file mode 100644 index 000000000..66f0f6efc --- /dev/null +++ b/src/aodv/doc/aodv.rst @@ -0,0 +1,131 @@ +.. include:: replace.txt + +Ad Hoc On-Demand Distance Vector (AODV) +--------------------------------------- + +This model implements the base specification of the Ad Hoc On-Demand +Distance Vector (AODV) protocol. The implementation is based on +[rfc3561]_. + +The model was written by Elena Buchatskaia and Pavel Boyko of ITTP RAS, +and is based on the ns-2 AODV model developed by the CMU/MONARCH group +and optimized and tuned by Samir Das and Mahesh Marina, University of +Cincinnati, and also on the AODV-UU implementation by Erik Nordström of +Uppsala University. + +Model Description +***************** + +The source code for the AODV model lives in the directory `src/aodv`. + +Design +++++++ + +Class ``ns3::aodv::RoutingProtocol`` implements all functionality of +service packet exchange and inherits from ``ns3::Ipv4RoutingProtocol``. +The base class defines two virtual functions for packet routing and +forwarding. The first one, ``ns3::aodv::RouteOutput``, is used for +locally originated packets, and the second one, ``ns3::aodv::RouteInput``, +is used for forwarding and/or delivering received packets. + +Protocol operation depends on many adjustable parameters. Parameters for +this functionality are attributes of ``ns3::aodv::RoutingProtocol``. +Parameter default values are drawn from the RFC and allow the +enabling/disabling protocol features, such as broadcasting HELLO messages, +broadcasting data packets and so on. + +AODV discovers routes on demand. Therefore, the AODV model buffers all +packets while a route request packet (RREQ) is disseminated. +A packet queue is implemented in aodv-rqueue.cc. A smart pointer to +the packet, ``ns3::Ipv4RoutingProtocol::ErrorCallback``, +``ns3::Ipv4RoutingProtocol::UnicastForwardCallback``, and the IP header +are stored in this queue. The packet queue implements garbage collection +of old packets and a queue size limit. + +The routing table implementation supports garbage collection of +old entries and state machine, defined in the standard. +It is implemented as a STL map container. The key is a destination IP address. + +Some elements of protocol operation aren't described in the RFC. These +elements generally concern cooperation of different OSI model layers. +The model uses the following heuristics: + +* This AODV implementation can detect the presence of unidirectional + links and avoid them if necessary. If the node the model receives an + RREQ for is a neighbor, the cause may be a unidirectional link. + This heuristic is taken from AODV-UU implementation and can be disabled. +* Protocol operation strongly depends on broken link detection mechanism. + The model implements two such heuristics. First, this implementation + support HELLO messages. However HELLO messages are not a good way to + perform neighbor sensing in a wireless environment (at least not over + 802.11). Therefore, one may experience bad performance when running over + wireless. There are several reasons for this: 1) HELLO messages are + broadcasted. In 802.11, broadcasting is often done at a + lower bit rate than unicasting, thus HELLO messages can travel further + than unicast data. 2) HELLO messages are small, thus less prone to + bit errors than data transmissions, and 3) Broadcast transmissions are + not guaranteed to be bidirectional, unlike unicast transmissions. + Second, we use layer 2 feedback when possible. Link are considered to be + broken if frame transmission results in a transmission failure for all + retries. This mechanism is meant for active links and works faster than + the first method. + +The layer 2 feedback implementation relies on the ``TxErrHeader`` trace source, +currently supported in AdhocWifiMac only. + +Scope and Limitations ++++++++++++++++++++++ + +The model is for IPv4 only. The following optional protocol optimizations +are not implemented: + +#. Expanding ring search. +#. Local link repair. +#. RREP, RREQ and HELLO message extensions. + +These techniques require direct access to IP header, which contradicts +the assertion from the AODV RFC that AODV works over UDP. This model uses +UDP for simplicity, hindering the ability to implement certain protocol +optimizations. The model doesn't use low layer raw sockets because they +are not portable. + +Future Work ++++++++++++ + +No announced plans. + +References +++++++++++ + +.. [rfc3561] RFC 3561 *Ad hoc On-Demand Distance Vector (AODV) Routing* + +Usage +***** + +Examples +++++++++ + +Helpers ++++++++ + +Attributes +++++++++++ + +Tracing ++++++++ + +Logging ++++++++ + +Caveats ++++++++ + +Validation +********** + +Unit tests +++++++++++ + +Larger-scale performance tests +++++++++++++++++++++++++++++++ + diff --git a/src/aodv/examples/aodv.cc b/src/aodv/examples/aodv.cc index 0fcd5ec63..3e8c56973 100644 --- a/src/aodv/examples/aodv.cc +++ b/src/aodv/examples/aodv.cc @@ -85,7 +85,7 @@ private: int main (int argc, char **argv) { AodvExample test; - if (!test.Configure(argc, argv)) + if (!test.Configure (argc, argv)) NS_FATAL_ERROR ("Configuration failed. Aborted."); test.Run (); @@ -109,7 +109,7 @@ AodvExample::Configure (int argc, char **argv) // Enable AODV logs by default. Comment this if too noisy // LogComponentEnable("AodvRoutingProtocol", LOG_LEVEL_ALL); - SeedManager::SetSeed(12345); + SeedManager::SetSeed (12345); CommandLine cmd; cmd.AddValue ("pcap", "Write PCAP traces.", pcap); @@ -213,7 +213,7 @@ AodvExample::InstallApplications () ApplicationContainer p = ping.Install (nodes.Get (0)); p.Start (Seconds (0)); - p.Stop (Seconds (totalTime) - Seconds(0.001)); + p.Stop (Seconds (totalTime) - Seconds (0.001)); // move node away Ptr node = nodes.Get (size/2); diff --git a/src/aodv/model/aodv-dpd.cc b/src/aodv/model/aodv-dpd.cc index 58d8ca898..73ca2c071 100644 --- a/src/aodv/model/aodv-dpd.cc +++ b/src/aodv/model/aodv-dpd.cc @@ -30,18 +30,18 @@ namespace aodv bool DuplicatePacketDetection::IsDuplicate (Ptr p, const Ipv4Header & header) { - return m_idCache.IsDuplicate (header.GetSource (), p->GetUid() ); + return m_idCache.IsDuplicate (header.GetSource (), p->GetUid () ); } void DuplicatePacketDetection::SetLifetime (Time lifetime) { - m_idCache.SetLifetime(lifetime); + m_idCache.SetLifetime (lifetime); } Time DuplicatePacketDetection::GetLifetime () const { - return m_idCache.GetLifeTime(); + return m_idCache.GetLifeTime (); } diff --git a/src/aodv/model/aodv-dpd.h b/src/aodv/model/aodv-dpd.h index 97722b056..b0b9461c1 100644 --- a/src/aodv/model/aodv-dpd.h +++ b/src/aodv/model/aodv-dpd.h @@ -44,7 +44,7 @@ class DuplicatePacketDetection { public: /// C-tor - DuplicatePacketDetection (Time lifetime) : m_idCache(lifetime) {} + DuplicatePacketDetection (Time lifetime) : m_idCache (lifetime) {} /// Check that the packet is duplicated. If not, save information about this packet. bool IsDuplicate (Ptr p, const Ipv4Header & header); /// Set duplicate records lifetimes diff --git a/src/aodv/model/aodv-neighbor.cc b/src/aodv/model/aodv-neighbor.cc index a9320b907..4c94ec957 100644 --- a/src/aodv/model/aodv-neighbor.cc +++ b/src/aodv/model/aodv-neighbor.cc @@ -39,8 +39,8 @@ namespace aodv Neighbors::Neighbors (Time delay) : m_ntimer (Timer::CANCEL_ON_DESTROY) { - m_ntimer.SetDelay(delay); - m_ntimer.SetFunction(&Neighbors::Purge, this); + m_ntimer.SetDelay (delay); + m_ntimer.SetFunction (&Neighbors::Purge, this); m_txErrorCallback = MakeCallback (&Neighbors::ProcessTxError, this); } diff --git a/src/aodv/model/aodv-neighbor.h b/src/aodv/model/aodv-neighbor.h index 28748cc6a..e7bddb2b7 100644 --- a/src/aodv/model/aodv-neighbor.h +++ b/src/aodv/model/aodv-neighbor.h @@ -87,7 +87,7 @@ public: ///\name Handle link failure callback //\{ - void SetCallback (Callback cb) { m_handleLinkFailure = cb;} + void SetCallback (Callback cb) { m_handleLinkFailure = cb; } Callback GetCallback () const { return m_handleLinkFailure; } //\} private: diff --git a/src/aodv/model/aodv-packet.cc b/src/aodv/model/aodv-packet.cc index d752d3b1f..263ba059b 100644 --- a/src/aodv/model/aodv-packet.cc +++ b/src/aodv/model/aodv-packet.cc @@ -141,8 +141,8 @@ operator<< (std::ostream & os, TypeHeader const & h) //----------------------------------------------------------------------------- RreqHeader::RreqHeader (uint8_t flags, uint8_t reserved, uint8_t hopCount, uint32_t requestID, Ipv4Address dst, uint32_t dstSeqNo, Ipv4Address origin, uint32_t originSeqNo) : - m_flags (flags), m_reserved (reserved), m_hopCount (hopCount), m_requestID (requestID), m_dst(dst), - m_dstSeqNo (dstSeqNo), m_origin(origin), m_originSeqNo (originSeqNo) + m_flags (flags), m_reserved (reserved), m_hopCount (hopCount), m_requestID (requestID), m_dst (dst), + m_dstSeqNo (dstSeqNo), m_origin (origin), m_originSeqNo (originSeqNo) { } @@ -585,7 +585,7 @@ RerrHeader::AddUnDestination (Ipv4Address dst, uint32_t seqNo ) if (m_unreachableDstSeqNo.find (dst) != m_unreachableDstSeqNo.end ()) return true; - NS_ASSERT (GetDestCount() < 255); // can't support more than 255 destinations in single RERR + NS_ASSERT (GetDestCount () < 255); // can't support more than 255 destinations in single RERR m_unreachableDstSeqNo.insert (std::make_pair (dst, seqNo)); return true; } diff --git a/src/aodv/model/aodv-packet.h b/src/aodv/model/aodv-packet.h index 5cc181a6a..9ffacfdf3 100644 --- a/src/aodv/model/aodv-packet.h +++ b/src/aodv/model/aodv-packet.h @@ -317,9 +317,9 @@ public: */ bool RemoveUnDestination (std::pair & un); /// Clear header - void Clear(); + void Clear (); /// Return number of unreachable destinations in RERR message - uint8_t GetDestCount () const { return (uint8_t)m_unreachableDstSeqNo.size(); } + uint8_t GetDestCount () const { return (uint8_t)m_unreachableDstSeqNo.size (); } bool operator== (RerrHeader const & o) const; private: uint8_t m_flag; ///< No delete flag diff --git a/src/aodv/model/aodv-routing-protocol.cc b/src/aodv/model/aodv-routing-protocol.cc index 87b6500aa..23a952921 100644 --- a/src/aodv/model/aodv-routing-protocol.cc +++ b/src/aodv/model/aodv-routing-protocol.cc @@ -58,7 +58,7 @@ struct DeferredRouteOutputTag : public Tag /// Positive if output device is fixed in RouteOutput int32_t oif; - DeferredRouteOutputTag (int32_t o = -1) : Tag(), oif (o) {} + DeferredRouteOutputTag (int32_t o = -1) : Tag (), oif (o) {} static TypeId GetTypeId () { @@ -103,14 +103,14 @@ RoutingProtocol::RoutingProtocol () : NetTraversalTime (Time ((2 * NetDiameter) * NodeTraversalTime)), PathDiscoveryTime ( Time (2 * NetTraversalTime)), MyRouteTimeout (Time (2 * std::max (PathDiscoveryTime, ActiveRouteTimeout))), - HelloInterval(Seconds (1)), + HelloInterval (Seconds (1)), AllowedHelloLoss (2), - DeletePeriod (Time(5 * std::max(ActiveRouteTimeout, HelloInterval))), + DeletePeriod (Time (5 * std::max (ActiveRouteTimeout, HelloInterval))), NextHopWait (NodeTraversalTime + MilliSeconds (10)), TimeoutBuffer (2), - BlackListTimeout(Time (RreqRetries * NetTraversalTime)), + BlackListTimeout (Time (RreqRetries * NetTraversalTime)), MaxQueueLen (64), - MaxQueueTime (Seconds(30)), + MaxQueueTime (Seconds (30)), DestinationOnly (false), GratuitousReply (true), EnableHello (true), @@ -120,7 +120,7 @@ RoutingProtocol::RoutingProtocol () : m_seqNo (0), m_rreqIdCache (PathDiscoveryTime), m_dpd (PathDiscoveryTime), - m_nb(HelloInterval), + m_nb (HelloInterval), m_rreqCount (0), m_rerrCount (0), m_htimer (Timer::CANCEL_ON_DESTROY), @@ -270,7 +270,7 @@ RoutingProtocol::DoDispose () void RoutingProtocol::PrintRoutingTable (Ptr stream) const { - *stream->GetStream () << "Node: " << m_ipv4->GetObject ()->GetId () << " Time: " << Simulator::Now().GetSeconds () << "s "; + *stream->GetStream () << "Node: " << m_ipv4->GetObject ()->GetId () << " Time: " << Simulator::Now ().GetSeconds () << "s "; m_routingTable.Print (stream); } @@ -316,7 +316,7 @@ RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, { route = rt.GetRoute (); NS_ASSERT (route != 0); - NS_LOG_DEBUG ("Exist route to " << route->GetDestination() << " from interface " << route->GetSource()); + NS_LOG_DEBUG ("Exist route to " << route->GetDestination () << " from interface " << route->GetSource ()); if (oif != 0 && route->GetOutputDevice () != oif) { NS_LOG_DEBUG ("Output device doesn't match. Dropped."); @@ -351,12 +351,12 @@ RoutingProtocol::DeferredRouteOutput (Ptr p, const Ipv4Header & he bool result = m_queue.Enqueue (newEntry); if (result) { - NS_LOG_LOGIC ("Add packet " << p->GetUid() << " to queue. Protocol " << (uint16_t) header.GetProtocol ()); + NS_LOG_LOGIC ("Add packet " << p->GetUid () << " to queue. Protocol " << (uint16_t) header.GetProtocol ()); RoutingTableEntry rt; - bool result = m_routingTable.LookupRoute(header.GetDestination (), rt); - if(!result || ((rt.GetFlag() != IN_SEARCH) && result)) + bool result = m_routingTable.LookupRoute (header.GetDestination (), rt); + if(!result || ((rt.GetFlag () != IN_SEARCH) && result)) { - NS_LOG_LOGIC ("Send RREQ to" < p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) { - NS_LOG_FUNCTION (this << p->GetUid() << header.GetDestination() << idev->GetAddress()); + NS_LOG_FUNCTION (this << p->GetUid () << header.GetDestination () << idev->GetAddress ()); if (m_socketAddresses.empty ()) { NS_LOG_LOGIC ("No aodv interfaces"); @@ -496,7 +496,7 @@ RoutingProtocol::Forwarding (Ptr p, const Ipv4Header & header, if (toDst.GetFlag () == VALID) { Ptr route = toDst.GetRoute (); - NS_LOG_LOGIC (route->GetSource()<<" forwarding to " << dst << " from " << origin << " packet " << p->GetUid ()); + NS_LOG_LOGIC (route->GetSource ()<<" forwarding to " << dst << " from " << origin << " packet " << p->GetUid ()); /* * Each time a route is used to forward a data packet, its Active Route @@ -666,7 +666,7 @@ RoutingProtocol::NotifyAddAddress (uint32_t i, Ipv4InterfaceAddress address) socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvAodv,this)); socket->BindToNetDevice (l3->GetNetDevice (i)); // Bind to any IP address so that broadcasts can be received - socket->Bind (InetSocketAddress (Ipv4Address::GetAny(), AODV_PORT)); + socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), AODV_PORT)); socket->SetAllowBroadcast (true); m_socketAddresses.insert (std::make_pair (socket, iface)); @@ -704,7 +704,7 @@ RoutingProtocol::NotifyRemoveAddress (uint32_t i, Ipv4InterfaceAddress address) NS_ASSERT (socket != 0); socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvAodv, this)); // Bind to any IP address so that broadcasts can be received - socket->Bind (InetSocketAddress (Ipv4Address::GetAny(), AODV_PORT)); + socket->Bind (InetSocketAddress (Ipv4Address::GetAny (), AODV_PORT)); socket->SetAllowBroadcast (true); m_socketAddresses.insert (std::make_pair (socket, iface)); @@ -787,7 +787,7 @@ RoutingProtocol::LoopbackRoute (const Ipv4Header & hdr, Ptr oif) cons { rt->SetSource (j->second.GetLocal ()); } - NS_ASSERT_MSG (rt->GetSource() != Ipv4Address (), "Valid AODV source address not found"); + NS_ASSERT_MSG (rt->GetSource () != Ipv4Address (), "Valid AODV source address not found"); rt->SetGateway (Ipv4Address ("127.0.0.1")); rt->SetOutputDevice (m_lo); return rt; @@ -819,15 +819,15 @@ RoutingProtocol::SendRequest (Ipv4Address dst) else rreqHeader.SetUnknownSeqno (true); rt.SetFlag (IN_SEARCH); - m_routingTable.AddRoute (rt); + m_routingTable.Update (rt); } else { rreqHeader.SetUnknownSeqno (true); Ptr dev = 0; RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ dst, /*validSeqNo=*/ false, /*seqno=*/ 0, - /*iface=*/ Ipv4InterfaceAddress(),/*hop=*/ 0, - /*nextHop=*/ Ipv4Address(), /*lifeTime=*/ Seconds(0)); + /*iface=*/ Ipv4InterfaceAddress (),/*hop=*/ 0, + /*nextHop=*/ Ipv4Address (), /*lifeTime=*/ Seconds (0)); newEntry.SetFlag (IN_SEARCH); m_routingTable.AddRoute (newEntry); } @@ -867,6 +867,7 @@ RoutingProtocol::SendRequest (Ipv4Address dst) { destination = iface.GetBroadcast (); } + NS_LOG_DEBUG ("Send RREQ with id " << rreqHeader.GetId () << " to socket"); socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT)); } ScheduleRreqRetry (dst); @@ -894,6 +895,7 @@ RoutingProtocol::ScheduleRreqRetry (Ipv4Address dst) rt.IncrementRreqCnt (); m_routingTable.Update (rt); m_addressReqTimer[dst].Schedule (Time (rt.GetRreqCnt () * NetTraversalTime)); + NS_LOG_LOGIC ("Scheduled RREQ retry in " << Time (rt.GetRreqCnt () * NetTraversalTime).GetSeconds () << " seconds"); } void @@ -912,7 +914,7 @@ RoutingProtocol::RecvAodv (Ptr socket) packet->RemoveHeader (tHeader); if (!tHeader.IsValid ()) { - NS_LOG_DEBUG ("AODV message " << packet->GetUid() << " with unknown type received: " << tHeader.Get() << ". Drop"); + NS_LOG_DEBUG ("AODV message " << packet->GetUid () << " with unknown type received: " << tHeader.Get () << ". Drop"); return; // drop } switch (tHeader.Get ()) @@ -1002,7 +1004,10 @@ RoutingProtocol::RecvRequest (Ptr p, Ipv4Address receiver, Ipv4Address s if (m_routingTable.LookupRoute (src, toPrev)) { if (toPrev.IsUnidirectional ()) - return; + { + NS_LOG_DEBUG ("Ignoring RREQ from node in blacklist"); + return; + } } uint32_t id = rreqHeader.GetId (); @@ -1014,6 +1019,7 @@ RoutingProtocol::RecvRequest (Ptr p, Ipv4Address receiver, Ipv4Address s */ if (m_rreqIdCache.IsDuplicate (origin, id)) { + NS_LOG_DEBUG ("Ignoring RREQ due to duplicate"); return; } @@ -1054,17 +1060,20 @@ RoutingProtocol::RecvRequest (Ptr p, Ipv4Address receiver, Ipv4Address s toOrigin.SetOutputDevice (m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (receiver))); toOrigin.SetInterface (m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0)); toOrigin.SetHop (hop); - toOrigin.SetLifeTime (std::max (Time(2 * NetTraversalTime - 2 * hop * NodeTraversalTime), + toOrigin.SetLifeTime (std::max (Time (2 * NetTraversalTime - 2 * hop * NodeTraversalTime), toOrigin.GetLifeTime ())); m_routingTable.Update (toOrigin); } - NS_LOG_LOGIC (receiver << " receive RREQ to destination " << rreqHeader.GetDst ()); + NS_LOG_LOGIC (receiver << " receive RREQ with hop count " << static_cast(rreqHeader.GetHopCount ()) + << " ID " << rreqHeader.GetId () + << " to destination " << rreqHeader.GetDst ()); // A node generates a RREP if either: // (i) it is itself the destination, if (IsMyOwnAddress (rreqHeader.GetDst ())) { m_routingTable.LookupRoute (origin, toOrigin); + NS_LOG_DEBUG ("Send reply since I am the destination"); SendReply (rreqHeader, toOrigin); return; } @@ -1093,7 +1102,7 @@ RoutingProtocol::RecvRequest (Ptr p, Ipv4Address receiver, Ipv4Address s if ((rreqHeader.GetUnknownSeqno () || (int32_t (toDst.GetSeqNo ()) - int32_t (rreqHeader.GetDstSeqno ()) >= 0)) && toDst.GetValidSeqNo () ) { - if (!rreqHeader.GetDestinationOnly () && toDst.GetFlag() == VALID) + if (!rreqHeader.GetDestinationOnly () && toDst.GetFlag () == VALID) { m_routingTable.LookupRoute (origin, toOrigin); SendReplyByIntermediateNode (toDst, toOrigin, rreqHeader.GetGratiousRrep ()); @@ -1129,7 +1138,7 @@ RoutingProtocol::RecvRequest (Ptr p, Ipv4Address receiver, Ipv4Address s if (EnableHello) { m_htimer.Cancel (); - m_htimer.Schedule (HelloInterval - Time (0.1 * MilliSeconds(UniformVariable().GetInteger (0, 10)))); + m_htimer.Schedule (HelloInterval - Time (0.1 * MilliSeconds (UniformVariable ().GetInteger (0, 10)))); } } @@ -1197,7 +1206,7 @@ RoutingProtocol::SendReplyByIntermediateNode (RoutingTableEntry & toDst, Routing packetToDst->AddHeader (type); Ptr socket = FindSocketWithInterfaceAddress (toDst.GetInterface ()); NS_ASSERT (socket); - NS_LOG_LOGIC ("Send gratuitous RREP " << packet->GetUid()); + NS_LOG_LOGIC ("Send gratuitous RREP " << packet->GetUid ()); socket->SendTo (packetToDst, 0, InetSocketAddress (toDst.GetNextHop (), AODV_PORT)); } } @@ -1221,11 +1230,11 @@ RoutingProtocol::SendReplyAck (Ipv4Address neighbor) void RoutingProtocol::RecvReply (Ptr p, Ipv4Address receiver, Ipv4Address sender) { - NS_LOG_FUNCTION(this << " src " << sender); + NS_LOG_FUNCTION (this << " src " << sender); RrepHeader rrepHeader; p->RemoveHeader (rrepHeader); Ipv4Address dst = rrepHeader.GetDst (); - NS_LOG_LOGIC("RREP destination " << dst << " RREP origin " << rrepHeader.GetOrigin()); + NS_LOG_LOGIC ("RREP destination " << dst << " RREP origin " << rrepHeader.GetOrigin ()); uint8_t hop = rrepHeader.GetHopCount () + 1; rrepHeader.SetHopCount (hop); @@ -1349,18 +1358,18 @@ RoutingProtocol::RecvReplyAck (Ipv4Address neighbor) { NS_LOG_FUNCTION (this); RoutingTableEntry rt; - if(m_routingTable.LookupRoute(neighbor, rt)) + if(m_routingTable.LookupRoute (neighbor, rt)) { rt.m_ackTimer.Cancel (); rt.SetFlag (VALID); - m_routingTable.Update(rt); + m_routingTable.Update (rt); } } void RoutingProtocol::ProcessHello (RrepHeader const & rrepHeader, Ipv4Address receiver ) { - NS_LOG_FUNCTION(this << "from " << rrepHeader.GetDst ()); + NS_LOG_FUNCTION (this << "from " << rrepHeader.GetDst ()); /* * Whenever a node receives a Hello message from a neighbor, the node * SHOULD make sure that it has an active route to the neighbor, and @@ -1453,7 +1462,7 @@ RoutingProtocol::RecvError (Ptr p, Ipv4Address src ) void RoutingProtocol::RouteRequestTimerExpire (Ipv4Address dst) { - NS_LOG_LOGIC(this); + NS_LOG_LOGIC (this); RoutingTableEntry toDst; if (m_routingTable.LookupValidRoute (dst, toDst)) { @@ -1468,25 +1477,25 @@ RoutingProtocol::RouteRequestTimerExpire (Ipv4Address dst) */ if (toDst.GetRreqCnt () == RreqRetries) { - NS_LOG_LOGIC("route discovery to " << dst << " has been attempted RreqRetries times"); + NS_LOG_LOGIC ("route discovery to " << dst << " has been attempted RreqRetries (" << RreqRetries << ") times"); m_addressReqTimer.erase (dst); m_routingTable.DeleteRoute (dst); - NS_LOG_DEBUG ("Route not found. Drop packet with dst " << dst); + NS_LOG_DEBUG ("Route not found. Drop all packets with dst " << dst); m_queue.DropPacketWithDst (dst); return; } if (toDst.GetFlag () == IN_SEARCH) { - NS_LOG_LOGIC ("Send new RREQ to " << dst << " ttl " << NetDiameter); + NS_LOG_LOGIC ("Resend RREQ to " << dst << " ttl " << NetDiameter); SendRequest (dst); } else { NS_LOG_DEBUG ("Route down. Stop search. Drop packet with destination " << dst); - m_addressReqTimer.erase(dst); - m_routingTable.DeleteRoute(dst); - m_queue.DropPacketWithDst(dst); + m_addressReqTimer.erase (dst); + m_routingTable.DeleteRoute (dst); + m_queue.DropPacketWithDst (dst); } } @@ -1496,7 +1505,7 @@ RoutingProtocol::HelloTimerExpire () NS_LOG_FUNCTION (this); SendHello (); m_htimer.Cancel (); - Time t = Time (0.01 * MilliSeconds(UniformVariable().GetInteger (0, 100))); + Time t = Time (0.01 * MilliSeconds (UniformVariable ().GetInteger (0, 100))); m_htimer.Schedule (HelloInterval - t); } @@ -1576,7 +1585,7 @@ RoutingProtocol::SendPacketFromQueue (Ipv4Address dst, Ptr route) UnicastForwardCallback ucb = queueEntry.GetUnicastForwardCallback (); Ipv4Header header = queueEntry.GetIpv4Header (); header.SetSource (route->GetSource ()); - header.SetTtl (header.GetTtl() + 1); // compensate extra TTL decrement by fake loopback routing + header.SetTtl (header.GetTtl () + 1); // compensate extra TTL decrement by fake loopback routing ucb (route, p, header); } } @@ -1666,7 +1675,7 @@ RoutingProtocol::SendRerrWhenNoRouteToForward (Ipv4Address dst, Ptr socket = i->first; Ipv4InterfaceAddress iface = i->second; NS_ASSERT (socket); - NS_LOG_LOGIC ("Broadcast RERR message from interface " << iface.GetLocal()); + NS_LOG_LOGIC ("Broadcast RERR message from interface " << iface.GetLocal ()); // Send to all-hosts broadcast if on /32 addr, subnet-directed otherwise Ipv4Address destination; if (iface.GetMask () == Ipv4Mask::GetOnes ()) @@ -1711,7 +1720,7 @@ RoutingProtocol::SendRerrMessage (Ptr packet, std::vector p { Ptr socket = FindSocketWithInterfaceAddress (toPrecursor.GetInterface ()); NS_ASSERT (socket); - NS_LOG_LOGIC ("one precursor => unicast RERR to " << toPrecursor.GetDestination() << " from " << toPrecursor.GetInterface ().GetLocal ()); + NS_LOG_LOGIC ("one precursor => unicast RERR to " << toPrecursor.GetDestination () << " from " << toPrecursor.GetInterface ().GetLocal ()); socket->SendTo (packet, 0, InetSocketAddress (precursors.front (), AODV_PORT)); m_rerrCount++; } @@ -1734,7 +1743,7 @@ RoutingProtocol::SendRerrMessage (Ptr packet, std::vector p { Ptr socket = FindSocketWithInterfaceAddress (*i); NS_ASSERT (socket); - NS_LOG_LOGIC ("Broadcast RERR message from interface " << i->GetLocal()); + NS_LOG_LOGIC ("Broadcast RERR message from interface " << i->GetLocal ()); // Send to all-hosts broadcast if on /32 addr, subnet-directed otherwise Ipv4Address destination; if (i->GetMask () == Ipv4Mask::GetOnes ()) diff --git a/src/aodv/model/aodv-routing-protocol.h b/src/aodv/model/aodv-routing-protocol.h index f9ba43a08..edaf275d5 100644 --- a/src/aodv/model/aodv-routing-protocol.h +++ b/src/aodv/model/aodv-routing-protocol.h @@ -226,7 +226,7 @@ private: /// Initiate RERR void SendRerrWhenBreaksLinkToNextHop (Ipv4Address nextHop); /// Forward RERR - void SendRerrMessage(Ptr packet, std::vector precursors); + 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 diff --git a/src/aodv/model/aodv-rqueue.h b/src/aodv/model/aodv-rqueue.h index a7e165a04..7c3199e6b 100644 --- a/src/aodv/model/aodv-rqueue.h +++ b/src/aodv/model/aodv-rqueue.h @@ -69,10 +69,10 @@ public: void SetErrorCallback (ErrorCallback ecb) { m_ecb = ecb; } Ptr GetPacket () const { return m_packet; } void SetPacket (Ptr p) { m_packet = p; } - Ipv4Header GetIpv4Header() const { return m_header; } + Ipv4Header GetIpv4Header () const { return m_header; } void SetIpv4Header (Ipv4Header h) { m_header = h; } - void SetExpireTime (Time exp) { m_expire = exp + Simulator::Now(); } - Time GetExpireTime () const { return m_expire - Simulator::Now(); } + void SetExpireTime (Time exp) { m_expire = exp + Simulator::Now (); } + Time GetExpireTime () const { return m_expire - Simulator::Now (); } //\} private: /// Data packet diff --git a/src/aodv/model/aodv-rtable.cc b/src/aodv/model/aodv-rtable.cc index a10e0ca5b..0105a05ff 100644 --- a/src/aodv/model/aodv-rtable.cc +++ b/src/aodv/model/aodv-rtable.cc @@ -158,7 +158,7 @@ RoutingTableEntry::Invalidate (Time badLinkLifetime) void RoutingTableEntry::Print (Ptr stream) const { - std::ostream* os = stream->GetStream(); + std::ostream* os = stream->GetStream (); *os << m_ipv4Route->GetDestination () << "\t" << m_ipv4Route->GetGateway () << "\t" << m_iface.GetLocal () << "\t"; switch (m_flag) diff --git a/src/aodv/model/aodv-rtable.h b/src/aodv/model/aodv-rtable.h index 89b0251a3..02fb661b0 100644 --- a/src/aodv/model/aodv-rtable.h +++ b/src/aodv/model/aodv-rtable.h @@ -60,9 +60,9 @@ class RoutingTableEntry { public: /// c-to - RoutingTableEntry (Ptr dev = 0,Ipv4Address dst = Ipv4Address(), bool vSeqNo = false, uint32_t m_seqNo = 0, - Ipv4InterfaceAddress iface = Ipv4InterfaceAddress(), uint16_t hops = 0, - Ipv4Address nextHop = Ipv4Address(), Time lifetime = Simulator::Now()); + RoutingTableEntry (Ptr dev = 0,Ipv4Address dst = Ipv4Address (), bool vSeqNo = false, uint32_t m_seqNo = 0, + Ipv4InterfaceAddress iface = Ipv4InterfaceAddress (), uint16_t hops = 0, + Ipv4Address nextHop = Ipv4Address (), Time lifetime = Simulator::Now ()); ~RoutingTableEntry (); @@ -103,14 +103,14 @@ public: void Invalidate (Time badLinkLifetime); ///\name Fields //\{ - Ipv4Address GetDestination () const { return m_ipv4Route->GetDestination(); } + Ipv4Address GetDestination () const { return m_ipv4Route->GetDestination (); } Ptr GetRoute () const { return m_ipv4Route; } void SetRoute (Ptr r) { m_ipv4Route = r; } - void SetNextHop (Ipv4Address nextHop) { m_ipv4Route->SetGateway(nextHop); } - Ipv4Address GetNextHop () const { return m_ipv4Route->GetGateway(); } - void SetOutputDevice (Ptr dev) { m_ipv4Route->SetOutputDevice(dev); } - Ptr GetOutputDevice () const { return m_ipv4Route->GetOutputDevice(); } - Ipv4InterfaceAddress GetInterface () const { return m_iface;} + void SetNextHop (Ipv4Address nextHop) { m_ipv4Route->SetGateway (nextHop); } + Ipv4Address GetNextHop () const { return m_ipv4Route->GetGateway (); } + void SetOutputDevice (Ptr dev) { m_ipv4Route->SetOutputDevice (dev); } + Ptr GetOutputDevice () const { return m_ipv4Route->GetOutputDevice (); } + Ipv4InterfaceAddress GetInterface () const { return m_iface; } void SetInterface (Ipv4InterfaceAddress iface) { m_iface = iface; } void SetValidSeqNo (bool s) { m_validSeqNo = s; } bool GetValidSeqNo () const { return m_validSeqNo; } @@ -118,8 +118,8 @@ public: uint32_t GetSeqNo () const { return m_seqNo; } void SetHop (uint16_t hop) { m_hops = hop; } uint16_t GetHop () const { return m_hops; } - void SetLifeTime (Time lt) { m_lifeTime = lt + Simulator::Now(); } - Time GetLifeTime () const { return m_lifeTime - Simulator::Now(); } + void SetLifeTime (Time lt) { m_lifeTime = lt + Simulator::Now (); } + Time GetLifeTime () const { return m_lifeTime - Simulator::Now (); } void SetFlag (RouteFlags flag) { m_flag = flag; } RouteFlags GetFlag () const { return m_flag; } void SetRreqCnt (uint8_t n) { m_reqCount = n; } @@ -141,7 +141,7 @@ public: { return (m_ipv4Route->GetDestination () == dst); } - void Print(Ptr stream) const; + void Print (Ptr stream) const; private: /// Valid Destination Sequence Number flag @@ -241,9 +241,9 @@ public: * \param blacklistTimeout - time for which the neighboring node is put into the blacklist * \return true on success */ - bool MarkLinkAsUnidirectional(Ipv4Address neighbor, Time blacklistTimeout); + bool MarkLinkAsUnidirectional (Ipv4Address neighbor, Time blacklistTimeout); /// Print routing table - void Print(Ptr stream) const; + void Print (Ptr stream) const; private: std::map m_ipv4AddressEntry; diff --git a/src/aodv/test/aodv-chain-regression-test-0-0.pcap b/src/aodv/test/aodv-chain-regression-test-0-0.pcap index 4a1bbfd88..a586ee47f 100644 Binary files a/src/aodv/test/aodv-chain-regression-test-0-0.pcap and b/src/aodv/test/aodv-chain-regression-test-0-0.pcap differ diff --git a/src/aodv/test/aodv-chain-regression-test-1-0.pcap b/src/aodv/test/aodv-chain-regression-test-1-0.pcap index dcbfa12a3..e3290531a 100644 Binary files a/src/aodv/test/aodv-chain-regression-test-1-0.pcap and b/src/aodv/test/aodv-chain-regression-test-1-0.pcap differ diff --git a/src/aodv/test/aodv-chain-regression-test-2-0.pcap b/src/aodv/test/aodv-chain-regression-test-2-0.pcap index 4674b3286..61591279c 100644 Binary files a/src/aodv/test/aodv-chain-regression-test-2-0.pcap and b/src/aodv/test/aodv-chain-regression-test-2-0.pcap differ diff --git a/src/aodv/test/aodv-chain-regression-test-3-0.pcap b/src/aodv/test/aodv-chain-regression-test-3-0.pcap index 12a17f3d5..5ce41e6ed 100644 Binary files a/src/aodv/test/aodv-chain-regression-test-3-0.pcap and b/src/aodv/test/aodv-chain-regression-test-3-0.pcap differ diff --git a/src/aodv/test/aodv-chain-regression-test-4-0.pcap b/src/aodv/test/aodv-chain-regression-test-4-0.pcap index d2a101d23..dd300867f 100644 Binary files a/src/aodv/test/aodv-chain-regression-test-4-0.pcap and b/src/aodv/test/aodv-chain-regression-test-4-0.pcap differ diff --git a/src/aodv/test/aodv-id-cache-test-suite.cc b/src/aodv/test/aodv-id-cache-test-suite.cc index b0fd2da15..466352bfb 100644 --- a/src/aodv/test/aodv-id-cache-test-suite.cc +++ b/src/aodv/test/aodv-id-cache-test-suite.cc @@ -39,9 +39,9 @@ namespace aodv /// Unit test for id cache struct IdCacheTest : public TestCase { - IdCacheTest () : TestCase ("Id Cache"), cache (Seconds(10)) + IdCacheTest () : TestCase ("Id Cache"), cache (Seconds (10)) {} - virtual void DoRun(); + virtual void DoRun (); void CheckTimeout1 (); void CheckTimeout2 (); void CheckTimeout3 (); @@ -52,22 +52,22 @@ struct IdCacheTest : public TestCase void IdCacheTest::DoRun () { - NS_TEST_EXPECT_MSG_EQ (cache.GetLifeTime(), Seconds(10), "Lifetime"); + NS_TEST_EXPECT_MSG_EQ (cache.GetLifeTime (), Seconds (10), "Lifetime"); NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("1.2.3.4"), 3), false, "Unknown ID & address"); NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("1.2.3.4"), 4), false, "Unknown ID"); NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("4.3.2.1"), 3), false, "Unknown address"); NS_TEST_EXPECT_MSG_EQ (cache.IsDuplicate (Ipv4Address ("1.2.3.4"), 3), true, "Known address & ID"); - cache.SetLifetime(Seconds(15)); - NS_TEST_EXPECT_MSG_EQ (cache.GetLifeTime(), Seconds(15), "New lifetime"); + cache.SetLifetime (Seconds (15)); + NS_TEST_EXPECT_MSG_EQ (cache.GetLifeTime (), Seconds (15), "New lifetime"); cache.IsDuplicate (Ipv4Address ("1.1.1.1"), 4); cache.IsDuplicate (Ipv4Address ("1.1.1.1"), 4); cache.IsDuplicate (Ipv4Address ("2.2.2.2"), 5); cache.IsDuplicate (Ipv4Address ("3.3.3.3"), 6); NS_TEST_EXPECT_MSG_EQ (cache.GetSize (), 6, "trivial"); - Simulator::Schedule (Seconds(5), &IdCacheTest::CheckTimeout1, this); - Simulator::Schedule (Seconds(11), &IdCacheTest::CheckTimeout2, this); - Simulator::Schedule (Seconds(30), &IdCacheTest::CheckTimeout3, this); + Simulator::Schedule (Seconds (5), &IdCacheTest::CheckTimeout1, this); + Simulator::Schedule (Seconds (11), &IdCacheTest::CheckTimeout2, this); + Simulator::Schedule (Seconds (30), &IdCacheTest::CheckTimeout3, this); Simulator::Run (); Simulator::Destroy (); } diff --git a/src/aodv/test/aodv-regression.cc b/src/aodv/test/aodv-regression.cc index ee620dd1c..285225898 100644 --- a/src/aodv/test/aodv-regression.cc +++ b/src/aodv/test/aodv-regression.cc @@ -92,7 +92,7 @@ ChainRegressionTest::~ChainRegressionTest () void ChainRegressionTest::DoRun () { - SeedManager::SetSeed(12345); + SeedManager::SetSeed (12345); Config::SetDefault ("ns3::ArpCache::AliveTimeout", TimeValue (m_arpAliveTimeout)); CreateNodes (); @@ -175,9 +175,9 @@ ChainRegressionTest::CheckResults () os1 << NS_TEST_SOURCEDIR << m_prefix << "-" << i << "-0.pcap"; os2 << GetTempDir () << m_prefix << "-" << i << "-0.pcap"; - uint32_t sec(0), usec(0); - bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); - NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() + uint32_t sec (0), usec (0); + bool diff = PcapFile::Diff (os1.str (), os2.str (), sec, usec); + NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str () << " and " << os2.str () << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/aodv/test/aodv-regression.h b/src/aodv/test/aodv-regression.h index 09f615f05..9584c0173 100644 --- a/src/aodv/test/aodv-regression.h +++ b/src/aodv/test/aodv-regression.h @@ -131,22 +131,21 @@ namespace aodv { | | <--|--> | | Hello | | | <--|------>| Hello <------|------>| | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=0, ID=2, org_seqno=2) src = 10.1.1.1 - |<------|--> | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=1, ID=2, org_seqno=1) src = 10.1.1.2 + |<------|--> | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=1, ID=2, org_seqno=2) src = 10.1.1.2 | | | |<------|------> Hello | | | <--|------>| Hello | | <--|--> | | Hello - <------|------>| | | | Hello - <------|------>| | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=0, ID=3, org_seqno=3) src = 10.1.1.1 |<------|--> | | | Hello - |<------|--> | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=1, ID=3, org_seqno=3) src = 10.1.1.2 + <------|------>| | | | Hello | | | |======>| RERR (unreachable dst 10.1.1.1 & 10.1.1.3) src=10.1.1.4 | | | |<------|------> Hello | | | <--|------>| Hello | | <--|--> | | Hello |<------|--> | | | Hello <------|------>| | | | Hello - <------|------>| | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=0, ID=4, org_seqno=4) src = 10.1.1.1 - |<------|--> | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=1, ID=4, org_seqno=4) src = 10.1.1.2 + | | | |<------|------> Hello + <------|------>| | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=0, ID=4, org_seqno=3) src = 10.1.1.1 + |<------|--> | | | RREQ (orig 10.1.1.1, dst 10.1.1.5, G=1, hop=1, ID=4, org_seqno=3) src = 10.1.1.2 .................................................................. * \endverbatim diff --git a/src/aodv/test/aodv-test-suite.cc b/src/aodv/test/aodv-test-suite.cc index 997382836..da8c2b1e7 100644 --- a/src/aodv/test/aodv-test-suite.cc +++ b/src/aodv/test/aodv-test-suite.cc @@ -214,13 +214,13 @@ struct RrepAckHeaderTest : public TestCase RrepAckHeaderTest () : TestCase ("AODV RREP-ACK") { } - virtual void DoRun() + virtual void DoRun () { RrepAckHeader h; Ptr p = Create (); p->AddHeader (h); RrepAckHeader h2; - uint32_t bytes = p->RemoveHeader(h2); + uint32_t bytes = p->RemoveHeader (h2); NS_TEST_EXPECT_MSG_EQ (bytes, 1, "ACK is 1 byte long"); NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works"); } @@ -232,24 +232,24 @@ struct RerrHeaderTest : public TestCase RerrHeaderTest () : TestCase ("AODV RERR") { } - virtual void DoRun() + virtual void DoRun () { RerrHeader h; - h.SetNoDelete(true); - NS_TEST_EXPECT_MSG_EQ(h.GetNoDelete(), true, "trivial"); - Ipv4Address dst = Ipv4Address("1.2.3.4"); - NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst, 12), true, "trivial"); - NS_TEST_EXPECT_MSG_EQ(h.GetDestCount(), 1, "trivial"); - NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst, 13), true, "trivial"); - Ipv4Address dst2 = Ipv4Address("4.3.2.1"); - NS_TEST_EXPECT_MSG_EQ(h.AddUnDestination(dst2, 12), true, "trivial"); - NS_TEST_EXPECT_MSG_EQ(h.GetDestCount(), 2, "trivial"); + h.SetNoDelete (true); + NS_TEST_EXPECT_MSG_EQ (h.GetNoDelete (), true, "trivial"); + Ipv4Address dst = Ipv4Address ("1.2.3.4"); + NS_TEST_EXPECT_MSG_EQ (h.AddUnDestination (dst, 12), true, "trivial"); + NS_TEST_EXPECT_MSG_EQ (h.GetDestCount (), 1, "trivial"); + NS_TEST_EXPECT_MSG_EQ (h.AddUnDestination (dst, 13), true, "trivial"); + Ipv4Address dst2 = Ipv4Address ("4.3.2.1"); + NS_TEST_EXPECT_MSG_EQ (h.AddUnDestination (dst2, 12), true, "trivial"); + NS_TEST_EXPECT_MSG_EQ (h.GetDestCount (), 2, "trivial"); Ptr p = Create (); p->AddHeader (h); RerrHeader h2; - uint32_t bytes = p->RemoveHeader(h2); - NS_TEST_EXPECT_MSG_EQ (bytes, h.GetSerializedSize(), "(De)Serialized size match"); + uint32_t bytes = p->RemoveHeader (h2); + NS_TEST_EXPECT_MSG_EQ (bytes, h.GetSerializedSize (), "(De)Serialized size match"); NS_TEST_EXPECT_MSG_EQ (h, h2, "Round trip serialization works"); } }; @@ -262,7 +262,7 @@ struct QueueEntryTest : public TestCase void Error (Ptr, const Ipv4Header &, Socket::SocketErrno) {} void Unicast2 (Ptr route, Ptr packet, const Ipv4Header & header) {} void Error2 (Ptr, const Ipv4Header &, Socket::SocketErrno) {} - virtual void DoRun() + virtual void DoRun () { Ptr packet = Create (); Ipv4Header h; @@ -273,14 +273,14 @@ struct QueueEntryTest : public TestCase QueueEntry entry (packet, h, ucb, ecb, Seconds (1)); NS_TEST_EXPECT_MSG_EQ (h.GetDestination (), entry.GetIpv4Header ().GetDestination (), "trivial"); NS_TEST_EXPECT_MSG_EQ (h.GetSource (), entry.GetIpv4Header ().GetSource (), "trivial"); - NS_TEST_EXPECT_MSG_EQ (ucb.IsEqual(entry.GetUnicastForwardCallback ()), true, "trivial"); - NS_TEST_EXPECT_MSG_EQ (ecb.IsEqual(entry.GetErrorCallback ()), true, "trivial"); + NS_TEST_EXPECT_MSG_EQ (ucb.IsEqual (entry.GetUnicastForwardCallback ()), true, "trivial"); + NS_TEST_EXPECT_MSG_EQ (ecb.IsEqual (entry.GetErrorCallback ()), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (1), "trivial"); NS_TEST_EXPECT_MSG_EQ (entry.GetPacket (), packet, "trivial"); entry.SetExpireTime (Seconds (3)); NS_TEST_EXPECT_MSG_EQ (entry.GetExpireTime (), Seconds (3), "trivial"); Ipv4Header h2; - h2.SetDestination(Ipv4Address ("1.1.1.1")); + h2.SetDestination (Ipv4Address ("1.1.1.1")); entry.SetIpv4Header (h2); NS_TEST_EXPECT_MSG_EQ (entry.GetIpv4Header ().GetDestination (), Ipv4Address ("1.1.1.1"), "trivial"); Ipv4RoutingProtocol::UnicastForwardCallback ucb2 = MakeCallback (&QueueEntryTest::Unicast2, this); @@ -312,7 +312,7 @@ AodvRqueueTest::DoRun () q.SetMaxQueueLen (32); NS_TEST_EXPECT_MSG_EQ (q.GetMaxQueueLen (), 32, "trivial"); NS_TEST_EXPECT_MSG_EQ (q.GetQueueTimeout (), Seconds (30), "trivial"); - q.SetQueueTimeout (Seconds(10)); + q.SetQueueTimeout (Seconds (10)); NS_TEST_EXPECT_MSG_EQ (q.GetQueueTimeout (), Seconds (10), "trivial"); Ptr packet = Create (); @@ -338,7 +338,7 @@ AodvRqueueTest::DoRun () q.Enqueue (e2); Ptr packet2 = Create (); QueueEntry e3 (packet2, h, ucb, ecb, Seconds (1)); - NS_TEST_EXPECT_MSG_EQ (q.Dequeue (Ipv4Address("3.3.3.3"), e3), false, "trivial"); + NS_TEST_EXPECT_MSG_EQ (q.Dequeue (Ipv4Address ("3.3.3.3"), e3), false, "trivial"); NS_TEST_EXPECT_MSG_EQ (q.Dequeue (Ipv4Address ("2.2.2.2"), e3), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (q.Find (Ipv4Address ("2.2.2.2")), false, "trivial"); q.Enqueue (e2); @@ -350,7 +350,7 @@ AodvRqueueTest::DoRun () q.Enqueue (e4); NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 3, "trivial"); q.DropPacketWithDst (Ipv4Address ("1.2.3.4")); - NS_TEST_EXPECT_MSG_EQ (q.GetSize(), 1, "trivial"); + NS_TEST_EXPECT_MSG_EQ (q.GetSize (), 1, "trivial"); CheckSizeLimit (); @@ -392,12 +392,12 @@ AodvRqueueTest::CheckTimeout () struct AodvRtableEntryTest : public TestCase { AodvRtableEntryTest () : TestCase ("RtableEntry") {} - virtual void DoRun() + virtual void DoRun () { Ptr dev; Ipv4InterfaceAddress iface; - RoutingTableEntry rt (/*output device*/ dev, /*dst*/ Ipv4Address("1.2.3.4"), /*validSeqNo*/ true, /*seqNo*/ 10, - /*interface*/ iface, /*hop*/ 5, /*next hop*/ Ipv4Address("3.3.3.3"), /*lifetime*/ Seconds(10)); + RoutingTableEntry rt (/*output device*/ dev, /*dst*/ Ipv4Address ("1.2.3.4"), /*validSeqNo*/ true, /*seqNo*/ 10, + /*interface*/ iface, /*hop*/ 5, /*next hop*/ Ipv4Address ("3.3.3.3"), /*lifetime*/ Seconds (10)); NS_TEST_EXPECT_MSG_EQ (rt.GetOutputDevice (), dev, "trivial"); NS_TEST_EXPECT_MSG_EQ (rt.GetDestination (), Ipv4Address ("1.2.3.4"), "trivial"); NS_TEST_EXPECT_MSG_EQ (rt.GetValidSeqNo (), true, "trivial"); @@ -471,7 +471,7 @@ struct AodvRtableEntryTest : public TestCase struct AodvRtableTest : public TestCase { AodvRtableTest () : TestCase ("Rtable") {} - virtual void DoRun() + virtual void DoRun () { RoutingTable rtable (Seconds (2)); NS_TEST_EXPECT_MSG_EQ (rtable.GetBadLinkLifetime (), Seconds (2), "trivial"); @@ -479,12 +479,12 @@ struct AodvRtableTest : public TestCase NS_TEST_EXPECT_MSG_EQ (rtable.GetBadLinkLifetime (), Seconds (1), "trivial"); Ptr dev; Ipv4InterfaceAddress iface; - RoutingTableEntry rt (/*output device*/ dev, /*dst*/ Ipv4Address("1.2.3.4"), /*validSeqNo*/ true, /*seqNo*/ 10, - /*interface*/ iface, /*hop*/ 5, /*next hop*/ Ipv4Address("1.1.1.1"), /*lifetime*/ Seconds(10)); + RoutingTableEntry rt (/*output device*/ dev, /*dst*/ Ipv4Address ("1.2.3.4"), /*validSeqNo*/ true, /*seqNo*/ 10, + /*interface*/ iface, /*hop*/ 5, /*next hop*/ Ipv4Address ("1.1.1.1"), /*lifetime*/ Seconds (10)); NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt), false, "trivial"); - RoutingTableEntry rt2 (/*output device*/ dev, /*dst*/ Ipv4Address("4.3.2.1"), /*validSeqNo*/ false, /*seqNo*/ 0, - /*interface*/ iface, /*hop*/ 15, /*next hop*/ Ipv4Address("1.1.1.1"), /*lifetime*/ Seconds(1)); + RoutingTableEntry rt2 (/*output device*/ dev, /*dst*/ Ipv4Address ("4.3.2.1"), /*validSeqNo*/ false, /*seqNo*/ 0, + /*interface*/ iface, /*hop*/ 15, /*next hop*/ Ipv4Address ("1.1.1.1"), /*lifetime*/ Seconds (1)); NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rt2), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rtable.LookupRoute (rt2.GetDestination (), rt), true, "trivial"); NS_TEST_EXPECT_MSG_EQ (rt2.GetDestination (), rt.GetDestination (), "trivial"); diff --git a/src/aodv/test/bug-606-test-0-0.pcap b/src/aodv/test/bug-606-test-0-0.pcap index 95d805fc8..00dba9e4f 100644 Binary files a/src/aodv/test/bug-606-test-0-0.pcap and b/src/aodv/test/bug-606-test-0-0.pcap differ diff --git a/src/aodv/test/bug-606-test-1-0.pcap b/src/aodv/test/bug-606-test-1-0.pcap index 7bd6597be..bad346549 100644 Binary files a/src/aodv/test/bug-606-test-1-0.pcap and b/src/aodv/test/bug-606-test-1-0.pcap differ diff --git a/src/aodv/test/bug-606-test-2-0.pcap b/src/aodv/test/bug-606-test-2-0.pcap index ae59d806a..979511752 100644 Binary files a/src/aodv/test/bug-606-test-2-0.pcap and b/src/aodv/test/bug-606-test-2-0.pcap differ diff --git a/src/aodv/test/bug-772.cc b/src/aodv/test/bug-772.cc index de274b81d..a6a12d11a 100644 --- a/src/aodv/test/bug-772.cc +++ b/src/aodv/test/bug-772.cc @@ -73,7 +73,7 @@ Bug772ChainTest::~Bug772ChainTest () void Bug772ChainTest::DoRun () { - SeedManager::SetSeed(12345); + SeedManager::SetSeed (12345); CreateNodes (); CreateDevices (); @@ -158,9 +158,9 @@ Bug772ChainTest::CheckResults () os1 << NS_TEST_SOURCEDIR << m_prefix << "-" << i << "-0.pcap"; os2 << GetTempDir () << m_prefix << "-" << i << "-0.pcap"; - uint32_t sec(0), usec(0); - bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); - NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() + uint32_t sec (0), usec (0); + bool diff = PcapFile::Diff (os1.str (), os2.str (), sec, usec); + NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str () << " and " << os2.str () << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/aodv/test/loopback.cc b/src/aodv/test/loopback.cc index b07755890..ccba734f6 100644 --- a/src/aodv/test/loopback.cc +++ b/src/aodv/test/loopback.cc @@ -61,7 +61,7 @@ LoopbackTestCase::DoRun () nodes.Create (1); Ptr m = CreateObject (); m->SetPosition (Vector (0, 0, 0)); - nodes.Get(0)->AggregateObject (m); + nodes.Get (0)->AggregateObject (m); // Setup WiFi NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifiMac.SetType ("ns3::AdhocWifiMac"); @@ -84,7 +84,7 @@ LoopbackTestCase::DoRun () // Setup ping Ptr ping = CreateObject (); ping->SetAttribute ("Remote", Ipv4AddressValue (Ipv4Address::GetLoopback ())); - nodes.Get(0)->AddApplication (ping); + nodes.Get (0)->AddApplication (ping); ping->SetStartTime (Seconds (0)); ping->SetStopTime (Seconds (4)); Names::Add ("ping", ping); diff --git a/src/aodv/test/tcp-chain-test-0-0.pcap b/src/aodv/test/tcp-chain-test-0-0.pcap index ce2941517..b6a27c094 100644 Binary files a/src/aodv/test/tcp-chain-test-0-0.pcap and b/src/aodv/test/tcp-chain-test-0-0.pcap differ diff --git a/src/aodv/test/tcp-chain-test-9-0.pcap b/src/aodv/test/tcp-chain-test-9-0.pcap index f0858e412..0f756630e 100644 Binary files a/src/aodv/test/tcp-chain-test-9-0.pcap and b/src/aodv/test/tcp-chain-test-9-0.pcap differ diff --git a/src/aodv/test/udp-chain-test-0-0.pcap b/src/aodv/test/udp-chain-test-0-0.pcap index 85cdd12db..6f3653eca 100644 Binary files a/src/aodv/test/udp-chain-test-0-0.pcap and b/src/aodv/test/udp-chain-test-0-0.pcap differ diff --git a/src/aodv/test/udp-chain-test-9-0.pcap b/src/aodv/test/udp-chain-test-9-0.pcap index 4477e8efa..a906b5aec 100644 Binary files a/src/aodv/test/udp-chain-test-9-0.pcap and b/src/aodv/test/udp-chain-test-9-0.pcap differ diff --git a/src/applications/doc/applications.h b/src/applications/doc/applications.h new file mode 100644 index 000000000..8c008c2ca --- /dev/null +++ b/src/applications/doc/applications.h @@ -0,0 +1,27 @@ +/* -*- 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 + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef APPLICATIONS_H +#define APPLICATIONS_H + +/** + * \defgroup applications Applications + * + * This section documents the API of the ns-3 applications module. For a generic functional description, please refer to the ns-3 manual. + */ + +#endif /* APPLICATIONS_H */ diff --git a/src/applications/helper/ping6-helper.h b/src/applications/helper/ping6-helper.h index c71080e7a..c4a0bdd20 100644 --- a/src/applications/helper/ping6-helper.h +++ b/src/applications/helper/ping6-helper.h @@ -82,7 +82,7 @@ public: * \brief Set routers addresses for routing type 0. * \param routers routers addresses */ - void SetRoutersAddress(std::vector routers); + void SetRoutersAddress (std::vector routers); private: /** diff --git a/src/applications/helper/udp-client-server-helper.h b/src/applications/helper/udp-client-server-helper.h index e65832e09..2f71c70e2 100644 --- a/src/applications/helper/udp-client-server-helper.h +++ b/src/applications/helper/udp-client-server-helper.h @@ -69,7 +69,7 @@ public: * NodeContainer. */ ApplicationContainer Install (NodeContainer c); - Ptr GetServer(void); + Ptr GetServer (void); private: ObjectFactory m_factory; Ptr m_server; diff --git a/src/applications/helper/udp-echo-helper.cc b/src/applications/helper/udp-echo-helper.cc index e4d471848..acb13cb60 100644 --- a/src/applications/helper/udp-echo-helper.cc +++ b/src/applications/helper/udp-echo-helper.cc @@ -28,7 +28,7 @@ namespace ns3 { UdpEchoServerHelper::UdpEchoServerHelper (uint16_t port) { m_factory.SetTypeId (UdpEchoServer::GetTypeId ()); - SetAttribute ("Port", UintegerValue(port)); + SetAttribute ("Port", UintegerValue (port)); } void diff --git a/src/applications/model/onoff-application.cc b/src/applications/model/onoff-application.cc index 69aa76d14..32aed33e6 100644 --- a/src/applications/model/onoff-application.cc +++ b/src/applications/model/onoff-application.cc @@ -105,7 +105,7 @@ OnOffApplication::~OnOffApplication() } void -OnOffApplication::SetMaxBytes(uint32_t maxBytes) +OnOffApplication::SetMaxBytes (uint32_t maxBytes) { NS_LOG_FUNCTION (this << maxBytes); m_maxBytes = maxBytes; @@ -129,14 +129,14 @@ OnOffApplication::DoDispose (void) } // Application Methods -void OnOffApplication::StartApplication() // Called at time specified by Start +void OnOffApplication::StartApplication () // Called at time specified by Start { NS_LOG_FUNCTION_NOARGS (); // Create the socket if not already if (!m_socket) { - m_socket = Socket::CreateSocket (GetNode(), m_tid); + m_socket = Socket::CreateSocket (GetNode (), m_tid); m_socket->Bind (); m_socket->Connect (m_peer); m_socket->SetAllowBroadcast (true); @@ -147,10 +147,10 @@ void OnOffApplication::StartApplication() // Called at time specified by Start // If we are not yet connected, there is nothing to do here // The ConnectionComplete upcall will start timers at that time //if (!m_connected) return; - ScheduleStartEvent(); + ScheduleStartEvent (); } -void OnOffApplication::StopApplication() // Called at time specified by Stop +void OnOffApplication::StopApplication () // Called at time specified by Stop { NS_LOG_FUNCTION_NOARGS (); @@ -161,7 +161,7 @@ void OnOffApplication::StopApplication() // Called at time specified by Stop } else { - NS_LOG_WARN("OnOffApplication found null socket to close in StopApplication"); + NS_LOG_WARN ("OnOffApplication found null socket to close in StopApplication"); } } @@ -172,33 +172,33 @@ void OnOffApplication::CancelEvents () if (m_sendEvent.IsRunning ()) { // Cancel the pending send packet event // Calculate residual bits since last packet sent - Time delta(Simulator::Now() - m_lastStartTime); - int64x64_t bits = delta.To(Time::S) * m_cbrRate.GetBitRate (); + Time delta (Simulator::Now () - m_lastStartTime); + int64x64_t bits = delta.To (Time::S) * m_cbrRate.GetBitRate (); m_residualBits += bits.GetHigh (); } - Simulator::Cancel(m_sendEvent); - Simulator::Cancel(m_startStopEvent); + Simulator::Cancel (m_sendEvent); + Simulator::Cancel (m_startStopEvent); } // Event handlers -void OnOffApplication::StartSending() +void OnOffApplication::StartSending () { NS_LOG_FUNCTION_NOARGS (); - m_lastStartTime = Simulator::Now(); - ScheduleNextTx(); // Schedule the send packet event - ScheduleStopEvent(); + m_lastStartTime = Simulator::Now (); + ScheduleNextTx (); // Schedule the send packet event + ScheduleStopEvent (); } -void OnOffApplication::StopSending() +void OnOffApplication::StopSending () { NS_LOG_FUNCTION_NOARGS (); - CancelEvents(); + CancelEvents (); - ScheduleStartEvent(); + ScheduleStartEvent (); } // Private helpers -void OnOffApplication::ScheduleNextTx() +void OnOffApplication::ScheduleNextTx () { NS_LOG_FUNCTION_NOARGS (); @@ -206,60 +206,60 @@ void OnOffApplication::ScheduleNextTx() { uint32_t bits = m_pktSize * 8 - m_residualBits; NS_LOG_LOGIC ("bits = " << bits); - Time nextTime(Seconds (bits / - static_cast(m_cbrRate.GetBitRate()))); // Time till next packet + Time nextTime (Seconds (bits / + static_cast(m_cbrRate.GetBitRate ()))); // Time till next packet NS_LOG_LOGIC ("nextTime = " << nextTime); - m_sendEvent = Simulator::Schedule(nextTime, - &OnOffApplication::SendPacket, this); + m_sendEvent = Simulator::Schedule (nextTime, + &OnOffApplication::SendPacket, this); } else { // All done, cancel any pending events - StopApplication(); + StopApplication (); } } -void OnOffApplication::ScheduleStartEvent() +void OnOffApplication::ScheduleStartEvent () { // Schedules the event to start sending data (switch to the "On" state) NS_LOG_FUNCTION_NOARGS (); - Time offInterval = Seconds(m_offTime.GetValue()); + Time offInterval = Seconds (m_offTime.GetValue ()); NS_LOG_LOGIC ("start at " << offInterval); - m_startStopEvent = Simulator::Schedule(offInterval, &OnOffApplication::StartSending, this); + m_startStopEvent = Simulator::Schedule (offInterval, &OnOffApplication::StartSending, this); } -void OnOffApplication::ScheduleStopEvent() +void OnOffApplication::ScheduleStopEvent () { // Schedules the event to stop sending data (switch to "Off" state) NS_LOG_FUNCTION_NOARGS (); - Time onInterval = Seconds(m_onTime.GetValue()); + Time onInterval = Seconds (m_onTime.GetValue ()); NS_LOG_LOGIC ("stop at " << onInterval); - m_startStopEvent = Simulator::Schedule(onInterval, &OnOffApplication::StopSending, this); + m_startStopEvent = Simulator::Schedule (onInterval, &OnOffApplication::StopSending, this); } -void OnOffApplication::SendPacket() +void OnOffApplication::SendPacket () { NS_LOG_FUNCTION_NOARGS (); - NS_LOG_LOGIC ("sending packet at " << Simulator::Now()); + NS_LOG_LOGIC ("sending packet at " << Simulator::Now ()); NS_ASSERT (m_sendEvent.IsExpired ()); Ptr packet = Create (m_pktSize); m_txTrace (packet); m_socket->Send (packet); m_totBytes += m_pktSize; - m_lastStartTime = Simulator::Now(); + m_lastStartTime = Simulator::Now (); m_residualBits = 0; - ScheduleNextTx(); + ScheduleNextTx (); } -void OnOffApplication::ConnectionSucceeded(Ptr) +void OnOffApplication::ConnectionSucceeded (Ptr) { NS_LOG_FUNCTION_NOARGS (); m_connected = true; - ScheduleStartEvent(); + ScheduleStartEvent (); } -void OnOffApplication::ConnectionFailed(Ptr) +void OnOffApplication::ConnectionFailed (Ptr) { NS_LOG_FUNCTION_NOARGS (); cout << "OnOffApplication, Connection Failed" << endl; diff --git a/src/applications/model/onoff-application.h b/src/applications/model/onoff-application.h index 3df52593b..8cfc0c5d2 100644 --- a/src/applications/model/onoff-application.h +++ b/src/applications/model/onoff-application.h @@ -148,12 +148,12 @@ private: TracedCallback > m_txTrace; private: - void ScheduleNextTx(); - void ScheduleStartEvent(); - void ScheduleStopEvent(); - void ConnectionSucceeded(Ptr); - void ConnectionFailed(Ptr); - void Ignore(Ptr); + void ScheduleNextTx (); + void ScheduleStartEvent (); + void ScheduleStopEvent (); + void ConnectionSucceeded (Ptr); + void ConnectionFailed (Ptr); + void Ignore (Ptr); }; } // namespace ns3 diff --git a/src/applications/model/packet-loss-counter.cc b/src/applications/model/packet-loss-counter.cc index 9983d6566..357cadb40 100644 --- a/src/applications/model/packet-loss-counter.cc +++ b/src/applications/model/packet-loss-counter.cc @@ -53,7 +53,7 @@ void PacketLossCounter::SetBitMapSize (uint16_t winSize) { - NS_ASSERT_MSG(winSize%8==0,"The packet window size should be a multiple of 8"); + NS_ASSERT_MSG (winSize%8==0,"The packet window size should be a multiple of 8"); m_bitMapSize = winSize/8; if (m_receiveBitMap!=0) { @@ -70,13 +70,13 @@ PacketLossCounter::GetLost () const } bool -PacketLossCounter::GetBit(uint32_t seqNum) +PacketLossCounter::GetBit (uint32_t seqNum) { return ((m_receiveBitMap[(seqNum%(m_bitMapSize*8))/8] >> (7-(seqNum%8)))&0x01); } void -PacketLossCounter::SetBit(uint32_t seqNum, bool val) +PacketLossCounter::SetBit (uint32_t seqNum, bool val) { if (val) { @@ -105,14 +105,14 @@ PacketLossCounter::NotifyReceived (uint32_t seqNum) { for (uint32_t i=m_lastMaxSeqNum+1; i<=seqNum; i++) { - if (GetBit(i)!=1) + if (GetBit (i)!=1) { NS_LOG_INFO ("Packet lost: " << i-(m_bitMapSize*8)); m_lost++; } - SetBit(i, 0); + SetBit (i, 0); } - SetBit(seqNum, 1); + SetBit (seqNum, 1); if (seqNum>m_lastMaxSeqNum) { m_lastMaxSeqNum = seqNum; diff --git a/src/applications/model/packet-sink.cc b/src/applications/model/packet-sink.cc index 0e966768c..57b817727 100644 --- a/src/applications/model/packet-sink.cc +++ b/src/applications/model/packet-sink.cc @@ -70,7 +70,7 @@ PacketSink::~PacketSink() NS_LOG_FUNCTION (this); } -uint32_t PacketSink::GetTotalRx() const +uint32_t PacketSink::GetTotalRx () const { return m_totalRx; } @@ -101,13 +101,13 @@ void PacketSink::DoDispose (void) // Application Methods -void PacketSink::StartApplication() // Called at time specified by Start +void PacketSink::StartApplication () // Called at time specified by Start { NS_LOG_FUNCTION (this); // Create the socket if not already if (!m_socket) { - m_socket = Socket::CreateSocket (GetNode(), m_tid); + m_socket = Socket::CreateSocket (GetNode (), m_tid); m_socket->Bind (m_local); m_socket->Listen (); m_socket->ShutdownSend (); @@ -126,23 +126,23 @@ void PacketSink::StartApplication() // Called at time specified by Start } } - m_socket->SetRecvCallback (MakeCallback(&PacketSink::HandleRead, this)); + m_socket->SetRecvCallback (MakeCallback (&PacketSink::HandleRead, this)); m_socket->SetAcceptCallback ( MakeNullCallback, const Address &> (), - MakeCallback(&PacketSink::HandleAccept, this)); + MakeCallback (&PacketSink::HandleAccept, this)); m_socket->SetCloseCallbacks ( - MakeCallback(&PacketSink::HandlePeerClose, this), - MakeCallback(&PacketSink::HandlePeerError, this)); + MakeCallback (&PacketSink::HandlePeerClose, this), + MakeCallback (&PacketSink::HandlePeerError, this)); } -void PacketSink::StopApplication() // Called at time specified by Stop +void PacketSink::StopApplication () // Called at time specified by Stop { NS_LOG_FUNCTION (this); - while(!m_socketList.empty()) //these are accepted sockets, close them + while(!m_socketList.empty ()) //these are accepted sockets, close them { - Ptr acceptedSocket = m_socketList.front(); - m_socketList.pop_front(); - acceptedSocket->Close(); + Ptr acceptedSocket = m_socketList.front (); + m_socketList.pop_front (); + acceptedSocket->Close (); } if (m_socket) { @@ -158,16 +158,16 @@ void PacketSink::HandleRead (Ptr socket) Address from; while (packet = socket->RecvFrom (from)) { - if (packet->GetSize() == 0) + if (packet->GetSize () == 0) { //EOF break; } if (InetSocketAddress::IsMatchingType (from)) { - m_totalRx += packet->GetSize(); + m_totalRx += packet->GetSize (); InetSocketAddress address = InetSocketAddress::ConvertFrom (from); - NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " << - address.GetIpv4() << " [" << address << "]" + NS_LOG_INFO ("Received " << packet->GetSize () << " bytes from " << + address.GetIpv4 () << " [" << address << "]" << " total Rx " << m_totalRx); //cast address to void , to suppress 'address' set but not used //compiler warning in optimized builds @@ -179,19 +179,19 @@ void PacketSink::HandleRead (Ptr socket) void PacketSink::HandlePeerClose (Ptr socket) { - NS_LOG_INFO("PktSink, peerClose"); + NS_LOG_INFO ("PktSink, peerClose"); } void PacketSink::HandlePeerError (Ptr socket) { - NS_LOG_INFO("PktSink, peerError"); + NS_LOG_INFO ("PktSink, peerError"); } void PacketSink::HandleAccept (Ptr s, const Address& from) { NS_LOG_FUNCTION (this << s << from); - s->SetRecvCallback (MakeCallback(&PacketSink::HandleRead, this)); + s->SetRecvCallback (MakeCallback (&PacketSink::HandleRead, this)); m_socketList.push_back (s); } diff --git a/src/applications/model/packet-sink.h b/src/applications/model/packet-sink.h index 78c7b23f5..d3b32f1af 100644 --- a/src/applications/model/packet-sink.h +++ b/src/applications/model/packet-sink.h @@ -97,8 +97,8 @@ private: void HandleRead (Ptr); void HandleAccept (Ptr, const Address& from); - void HandlePeerClose(Ptr); - void HandlePeerError(Ptr); + void HandlePeerClose (Ptr); + void HandlePeerError (Ptr); // In the case of TCP, each socket accept returns a new socket, so the // listening socket is stored seperately from the accepted sockets diff --git a/src/applications/model/ping6.h b/src/applications/model/ping6.h index 52107106a..84662d8e4 100644 --- a/src/applications/model/ping6.h +++ b/src/applications/model/ping6.h @@ -85,7 +85,7 @@ public: * \brief Set routers for routing type 0 (loose routing). * \param routers routers addresses */ - void SetRouters(std::vector routers); + void SetRouters (std::vector routers); protected: /** diff --git a/src/applications/model/radvd-interface.cc b/src/applications/model/radvd-interface.cc index 506569a31..a12f28e47 100644 --- a/src/applications/model/radvd-interface.cc +++ b/src/applications/model/radvd-interface.cc @@ -76,7 +76,7 @@ RadvdInterface::RadvdInterface (uint32_t interface, uint32_t maxRtrAdvInterval, RadvdInterface::~RadvdInterface () { /* clear prefixes */ - for (RadvdPrefixListI it = m_prefixes.begin () ; it != m_prefixes.end () ; ++it) + for (RadvdPrefixListI it = m_prefixes.begin (); it != m_prefixes.end (); ++it) { (*it) = 0; } diff --git a/src/applications/model/radvd.cc b/src/applications/model/radvd.cc index a55c682c2..22e446a70 100644 --- a/src/applications/model/radvd.cc +++ b/src/applications/model/radvd.cc @@ -60,7 +60,7 @@ Radvd::Radvd () Radvd::~Radvd () { NS_LOG_FUNCTION_NOARGS (); - for (RadvdInterfaceListI it = m_configurations.begin () ; it != m_configurations.end () ; ++it) + for (RadvdInterfaceListI it = m_configurations.begin (); it != m_configurations.end (); ++it) { *it = 0; } @@ -91,7 +91,7 @@ void Radvd::StartApplication () m_socket->SetRecvCallback (MakeCallback (&Radvd::HandleRead, this)); } - for (RadvdInterfaceListCI it = m_configurations.begin () ; it != m_configurations.end () ; it++) + for (RadvdInterfaceListCI it = m_configurations.begin (); it != m_configurations.end (); it++) { m_eventIds[(*it)->GetInterface ()] = EventId (); ScheduleTransmit (Seconds (0.), (*it), m_eventIds[(*it)->GetInterface ()], Ipv6Address::GetAllNodesMulticast (), true); @@ -107,7 +107,7 @@ void Radvd::StopApplication () m_socket->SetRecvCallback (MakeNullCallback > ()); } - for (EventIdMapI it = m_eventIds.begin () ; it != m_eventIds.end () ; ++it) + for (EventIdMapI it = m_eventIds.begin (); it != m_eventIds.end (); ++it) { Simulator::Cancel ((*it).second); } @@ -168,7 +168,7 @@ void Radvd::Send (Ptr config, Ipv6Address dst, bool reschedule) } /* add list of prefixes */ - for (std::list >::const_iterator jt = prefixes.begin () ; jt != prefixes.end () ; jt++) + for (std::list >::const_iterator jt = prefixes.begin (); jt != prefixes.end (); jt++) { uint8_t flags = 0; prefixHdr = Icmpv6OptionPrefixInformation (); @@ -212,8 +212,8 @@ void Radvd::Send (Ptr config, Ipv6Address dst, bool reschedule) * The ttl value should be set as a socket option, but this is not yet implemented */ SocketIpTtlTag ttl; - ttl.SetTtl(255); - p->AddPacketTag(ttl); + ttl.SetTtl (255); + p->AddPacketTag (ttl); /* send RA */ NS_LOG_LOGIC ("Send RA"); @@ -257,7 +257,7 @@ void Radvd::HandleRead (Ptr socket) NS_LOG_INFO ("Received ICMPv6 Router Solicitation from " << hdr.GetSourceAddress () << " code = " << (uint32_t)rsHdr.GetCode ()); /* XXX advertise just prefix(es) for the interface not all */ - for (RadvdInterfaceListCI it = m_configurations.begin () ; it != m_configurations.end () ; it++) + for (RadvdInterfaceListCI it = m_configurations.begin (); it != m_configurations.end (); it++) { /* calculate minimum delay between RA */ delay = static_cast (rnd.GetValue (0, MAX_RA_DELAY_TIME) + 0.5); diff --git a/src/applications/model/udp-echo-client.cc b/src/applications/model/udp-echo-client.cc index 34f0e7d56..c5676aacc 100644 --- a/src/applications/model/udp-echo-client.cc +++ b/src/applications/model/udp-echo-client.cc @@ -111,14 +111,14 @@ UdpEchoClient::StartApplication (void) if (m_socket == 0) { TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); - m_socket = Socket::CreateSocket (GetNode(), tid); + m_socket = Socket::CreateSocket (GetNode (), tid); m_socket->Bind (); m_socket->Connect (InetSocketAddress (m_peerAddress, m_peerPort)); } - m_socket->SetRecvCallback(MakeCallback(&UdpEchoClient::HandleRead, this)); + m_socket->SetRecvCallback (MakeCallback (&UdpEchoClient::HandleRead, this)); - ScheduleTransmit (Seconds(0.)); + ScheduleTransmit (Seconds (0.)); } void @@ -129,11 +129,11 @@ UdpEchoClient::StopApplication () if (m_socket != 0) { m_socket->Close (); - m_socket->SetRecvCallback(MakeNullCallback > ()); + m_socket->SetRecvCallback (MakeNullCallback > ()); m_socket = 0; } - Simulator::Cancel(m_sendEvent); + Simulator::Cancel (m_sendEvent); } void @@ -228,7 +228,7 @@ UdpEchoClient::SetFill (uint8_t *fill, uint32_t fillSize, uint32_t dataSize) // // Last fill may be partial // - memcpy(&m_data[filled], fill, dataSize - filled); + memcpy (&m_data[filled], fill, dataSize - filled); // // Overwrite packet size attribute. @@ -240,7 +240,7 @@ void UdpEchoClient::ScheduleTransmit (Time dt) { NS_LOG_FUNCTION_NOARGS (); - m_sendEvent = Simulator::Schedule(dt, &UdpEchoClient::Send, this); + m_sendEvent = Simulator::Schedule (dt, &UdpEchoClient::Send, this); } void @@ -299,8 +299,8 @@ UdpEchoClient::HandleRead (Ptr socket) { if (InetSocketAddress::IsMatchingType (from)) { - NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " << - InetSocketAddress::ConvertFrom (from).GetIpv4()); + NS_LOG_INFO ("Received " << packet->GetSize () << " bytes from " << + InetSocketAddress::ConvertFrom (from).GetIpv4 ()); } } } diff --git a/src/applications/model/udp-echo-server.cc b/src/applications/model/udp-echo-server.cc index a55214bbf..a5715d3ac 100644 --- a/src/applications/model/udp-echo-server.cc +++ b/src/applications/model/udp-echo-server.cc @@ -75,7 +75,7 @@ UdpEchoServer::StartApplication (void) if (m_socket == 0) { TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); - m_socket = Socket::CreateSocket (GetNode(), tid); + m_socket = Socket::CreateSocket (GetNode (), tid); InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), m_port); m_socket->Bind (local); if (addressUtils::IsMulticast (m_local)) @@ -93,7 +93,7 @@ UdpEchoServer::StartApplication (void) } } - m_socket->SetRecvCallback(MakeCallback(&UdpEchoServer::HandleRead, this)); + m_socket->SetRecvCallback (MakeCallback (&UdpEchoServer::HandleRead, this)); } void @@ -104,7 +104,7 @@ UdpEchoServer::StopApplication () if (m_socket != 0) { m_socket->Close (); - m_socket->SetRecvCallback(MakeNullCallback > ()); + m_socket->SetRecvCallback (MakeNullCallback > ()); } } @@ -117,8 +117,8 @@ UdpEchoServer::HandleRead (Ptr socket) { if (InetSocketAddress::IsMatchingType (from)) { - NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " << - InetSocketAddress::ConvertFrom (from).GetIpv4()); + NS_LOG_INFO ("Received " << packet->GetSize () << " bytes from " << + InetSocketAddress::ConvertFrom (from).GetIpv4 ()); packet->RemoveAllPacketTags (); packet->RemoveAllByteTags (); diff --git a/src/applications/model/udp-server.cc b/src/applications/model/udp-server.cc index ae42cd8a4..264281c5c 100644 --- a/src/applications/model/udp-server.cc +++ b/src/applications/model/udp-server.cc @@ -148,12 +148,12 @@ UdpServer::HandleRead (Ptr socket) packet->RemoveHeader (seqTs); uint32_t currentSequenceNumber = seqTs.GetSeq (); NS_LOG_INFO ("TraceDelay: RX " << packet->GetSize () << - " bytes from "<< InetSocketAddress::ConvertFrom(from).GetIpv4 () << + " bytes from "<< InetSocketAddress::ConvertFrom (from).GetIpv4 () << " Sequence Number: " << currentSequenceNumber << " Uid: " << packet->GetUid () << " TXtime: " << seqTs.GetTs () << " RXtime: " << Simulator::Now () << - " Delay: " << Simulator::Now () - seqTs.GetTs ()) ; + " Delay: " << Simulator::Now () - seqTs.GetTs ()); m_lossCounter.NotifyReceived (currentSequenceNumber); m_received++; diff --git a/src/applications/model/udp-trace-client.h b/src/applications/model/udp-trace-client.h index 728a736f2..705953e65 100644 --- a/src/applications/model/udp-trace-client.h +++ b/src/applications/model/udp-trace-client.h @@ -93,12 +93,12 @@ public: /** * \return the maximum packet size */ - uint16_t GetMaxPacketSize(void); + uint16_t GetMaxPacketSize (void); /** * \param maxPacketSize The maximum packet size */ - void SetMaxPacketSize(uint16_t maxPacketSize); + void SetMaxPacketSize (uint16_t maxPacketSize); protected: virtual void DoDispose (void); diff --git a/src/applications/model/v4ping.cc b/src/applications/model/v4ping.cc index fbfc3700a..93c6fdad0 100644 --- a/src/applications/model/v4ping.cc +++ b/src/applications/model/v4ping.cc @@ -119,7 +119,7 @@ V4Ping::Receive (Ptr socket) { Icmpv4Echo echo; p->RemoveHeader (echo); - std::map::iterator i = m_sent.find(echo.GetSequenceNumber()); + std::map::iterator i = m_sent.find (echo.GetSequenceNumber ()); if (i != m_sent.end () && echo.GetIdentifier () == 0) { @@ -141,16 +141,16 @@ V4Ping::Receive (Ptr socket) Time delta = Simulator::Now () - sendTime; m_sent.erase (i); - m_avgRtt.Update (delta.GetMilliSeconds()); + m_avgRtt.Update (delta.GetMilliSeconds ()); m_recv++; m_traceRtt (delta); if (m_verbose) { - std::cout << recvSize << " bytes from " << realFrom.GetIpv4() << ":" + std::cout << recvSize << " bytes from " << realFrom.GetIpv4 () << ":" << " icmp_seq=" << echo.GetSequenceNumber () << " ttl=" << (unsigned)ipv4.GetTtl () - << " time=" << delta.GetMilliSeconds() << " ms\n"; + << " time=" << delta.GetMilliSeconds () << " ms\n"; } } } @@ -214,7 +214,7 @@ V4Ping::Send () header.EnableChecksum (); } p->AddHeader (header); - m_sent.insert (std::make_pair (m_seq - 1, Simulator::Now())); + m_sent.insert (std::make_pair (m_seq - 1, Simulator::Now ())); m_socket->Send (p, 0); m_next = Simulator::Schedule (m_interval, &V4Ping::Send, this); } @@ -251,7 +251,7 @@ void V4Ping::StopApplication (void) { NS_LOG_FUNCTION (this); - m_next.Cancel(); + m_next.Cancel (); m_socket->Close (); if (m_verbose) @@ -264,10 +264,10 @@ V4Ping::StopApplication (void) << "time " << (Simulator::Now () - m_started).GetMilliSeconds () << "ms\n"; if (m_avgRtt.Count () > 0) - os << "rtt min/avg/max/mdev = " << m_avgRtt.Min() << "/" << m_avgRtt.Avg() << "/" - << m_avgRtt.Max() << "/" << m_avgRtt.Stddev() + os << "rtt min/avg/max/mdev = " << m_avgRtt.Min () << "/" << m_avgRtt.Avg () << "/" + << m_avgRtt.Max () << "/" << m_avgRtt.Stddev () << " ms\n"; - std::cout << os.str(); + std::cout << os.str (); } } diff --git a/src/applications/test/udp-client-server-test.cc b/src/applications/test/udp-client-server-test.cc index 3123c8d45..0d58c1a4b 100644 --- a/src/applications/test/udp-client-server-test.cc +++ b/src/applications/test/udp-client-server-test.cc @@ -88,7 +88,7 @@ void UdpClientServerTestCase::DoRun (void) uint16_t port = 4000; UdpServerHelper server (port); - ApplicationContainer apps = server.Install (n.Get(1)); + ApplicationContainer apps = server.Install (n.Get (1)); apps.Start (Seconds (1.0)); apps.Stop (Seconds (10.0)); @@ -161,7 +161,7 @@ void UdpTraceClientServerTestCase::DoRun (void) uint16_t port = 4000; UdpServerHelper server (port); - ApplicationContainer apps = server.Install (n.Get(1)); + ApplicationContainer apps = server.Install (n.Get (1)); apps.Start (Seconds (1.0)); apps.Stop (Seconds (10.0)); @@ -206,53 +206,53 @@ PacketLossCounterTestCase::~PacketLossCounterTestCase () void PacketLossCounterTestCase::DoRun (void) { - PacketLossCounter lossCounter(32); - lossCounter.NotifyReceived(32); //out of order + PacketLossCounter lossCounter (32); + lossCounter.NotifyReceived (32); //out of order for (uint32_t i=0; i<64; i++) { - lossCounter.NotifyReceived(i); + lossCounter.NotifyReceived (i); } - NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost(), 0, "Check that 0 packets are lost"); + NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost (), 0, "Check that 0 packets are lost"); for (uint32_t i=65; i<128; i++) // drop (1) seqNum 64 { - lossCounter.NotifyReceived(i); + lossCounter.NotifyReceived (i); } - NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost(), 1, "Check that 1 packet is lost"); + NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost (), 1, "Check that 1 packet is lost"); for (uint32_t i=134; i<200; i++) // drop seqNum 128,129,130,131,132,133 { - lossCounter.NotifyReceived(i); + lossCounter.NotifyReceived (i); } - NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost(), 7, "Check that 7 (6+1) packets are lost"); + NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost (), 7, "Check that 7 (6+1) packets are lost"); // reordering without loss - lossCounter.NotifyReceived(205); - lossCounter.NotifyReceived(206); - lossCounter.NotifyReceived(207); - lossCounter.NotifyReceived(200); - lossCounter.NotifyReceived(201); - lossCounter.NotifyReceived(202); - lossCounter.NotifyReceived(203); - lossCounter.NotifyReceived(204); + lossCounter.NotifyReceived (205); + lossCounter.NotifyReceived (206); + lossCounter.NotifyReceived (207); + lossCounter.NotifyReceived (200); + lossCounter.NotifyReceived (201); + lossCounter.NotifyReceived (202); + lossCounter.NotifyReceived (203); + lossCounter.NotifyReceived (204); for (uint32_t i=205; i<250; i++) { - lossCounter.NotifyReceived(i); + lossCounter.NotifyReceived (i); } - NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost(), 7, "Check that 7 (6+1) packets are lost even when reordering happens"); + NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost (), 7, "Check that 7 (6+1) packets are lost even when reordering happens"); // reordering with loss - lossCounter.NotifyReceived(255); + lossCounter.NotifyReceived (255); // drop (2) seqNum 250, 251 - lossCounter.NotifyReceived(252); - lossCounter.NotifyReceived(253); - lossCounter.NotifyReceived(254); + lossCounter.NotifyReceived (252); + lossCounter.NotifyReceived (253); + lossCounter.NotifyReceived (254); for (uint32_t i=256; i<300; i++) { - lossCounter.NotifyReceived(i); + lossCounter.NotifyReceived (i); } - NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost(), 9, "Check that 9 (6+1+2) packet are lost"); + NS_TEST_ASSERT_MSG_EQ (lossCounter.GetLost (), 9, "Check that 9 (6+1+2) packet are lost"); } class UdpClientServerTestSuite : public TestSuite { diff --git a/src/bridge/model/bridge-net-device.cc b/src/bridge/model/bridge-net-device.cc index 715e20ee1..c5343f450 100644 --- a/src/bridge/model/bridge-net-device.cc +++ b/src/bridge/model/bridge-net-device.cc @@ -263,14 +263,14 @@ BridgeNetDevice::AddBridgePort (Ptr bridgePort) } void -BridgeNetDevice::SetIfIndex(const uint32_t index) +BridgeNetDevice::SetIfIndex (const uint32_t index) { NS_LOG_FUNCTION_NOARGS (); m_ifIndex = index; } uint32_t -BridgeNetDevice::GetIfIndex(void) const +BridgeNetDevice::GetIfIndex (void) const { NS_LOG_FUNCTION_NOARGS (); return m_ifIndex; diff --git a/src/bridge/model/bridge-net-device.h b/src/bridge/model/bridge-net-device.h index e880d1a88..1be99e41c 100644 --- a/src/bridge/model/bridge-net-device.h +++ b/src/bridge/model/bridge-net-device.h @@ -89,8 +89,8 @@ public: Ptr GetBridgePort (uint32_t n) const; // inherited from NetDevice base class. - virtual void SetIfIndex(const uint32_t index); - virtual uint32_t GetIfIndex(void) const; + virtual void SetIfIndex (const uint32_t index); + virtual uint32_t GetIfIndex (void) const; virtual Ptr GetChannel (void) const; virtual void SetAddress (Address address); virtual Address GetAddress (void) const; diff --git a/src/click/doc/click.h b/src/click/doc/click.h deleted file mode 100644 index 6448b83ec..000000000 --- a/src/click/doc/click.h +++ /dev/null @@ -1,105 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2010 Lalith Suresh - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Authors: Lalith Suresh - */ - -/** -* \defgroup click Click Routing -* -* \section model Model -* -* This model implements the interface to the Click Modular Router and -* provides the Ipv4ClickRouting class to allow a node to use Click -* for external routing. Unlike normal Ipv4RoutingProtocol sub types, -* Ipv4ClickRouting doesn't use a RouteInput() method, but instead, -* receives a packet on the appropriate interface and processes it -* accordingly. Note that you need to have a routing table type element -* in your Click graph to use Click for external routing. This is needed -* by the RouteOutput() function inherited from Ipv4RoutingProtocol. -* Furthermore, a Click based node uses a different kind of L3 in the -* form of Ipv4L3ClickProtocol, which is a trimmed down version of -* Ipv4L3Protocol. Ipv4L3ClickProtocol passes on packets passing through -* the stack to Ipv4ClickRouting for processing. -* -* \section build Build Instructions -* -* The first step is to build Click. At the top of your Click source directory: -* -* $: ./configure --enable-userlevel --disable-linuxmodule --enable-nsclick --enable-wifi -* $: make -* -* The --enable wifi flag can be skipped in case you don't intend on using -* Click with Wifi. -* *Note: You don't need to do a 'make install'. -* -* Once Click has been built successfully, we proceed to configure ns-3 with -* Click Integration support: -* -* $: ./waf configure --with-nsclick=/path/to/click/source -* -* If it says 'enabled' beside 'NS-3 Click Integration Support', then you're -* good to go. -* -* Next, try running one of the examples: -* -* $: ./waf --run nsclick-simple-lan -* -* You will find a lot of output being generated. This is because of the -* IPPrint and Print elements present in the nsclick-simple-lan.click -* configuration file that the example script uses. -* -* \section clickgraph Click Graph Instructions -* -* The following should be kept in mind when making your Click graph: -* - Only userlevel elements can be used. -* - You will need to replace FromDevice and ToDevice elements -* with FromSimDevice and ToSimDevice elements. -* - Packets to the kernel are sent up using ToSimDevice(tap0,IP). -* - For any node, the 0th device will be tap0. The remaining devices -* should be eth0, eth1 and so forth (even if you're using wifi). -* Please note that the device numbering should begin from 0. -* - A routing table element is a mandatory. The OUTports of the routing -* table element should correspond to the interface number of the device -* through which the packet will ultimately be sent out. Violating this -* rule will lead to really weird packet traces. This routing table element's -* name should then be passed to the Ipv4ClickRouting protocol object as -* a simulation parameter. See the Click examples for details. -* - When using Wifi with ns-3-click, do not use wifi specific elements like -* WifiEncap, ExtraEncap, MadWifiRate etc. for outgoing packets. Incoming -* packets should have their Wifi headers removed using WifiDecap + ExtraDecap -* or Strip elements. See the nsclick-raw-wlan.click file for an idea of the same. -* - The current implementation leaves Click with mainly L3 functionality, -* with ns-3 handling L2. We will soon begin working to support the use of -* MAC protocols on Click as well. -* -* \section usage Usage -* -* To have a node run Click, the easiest way would be to use the ClickInternetStackHelper -* class in your simulation script. For instance: -* -* ClickInternetStackHelper click; -* click.SetClickFile (myNodeContainer, "nsclick-simple-lan.click"); -* click.SetRoutingTableElement (myNodeContainer, "u/rt"); -* click.Install (myNodeContainer); -* -* The example scripts inside examples/click/ demonstrate the use of Click based -* nodes in different scenarios. -* -* -*/ - diff --git a/src/click/doc/click.rst b/src/click/doc/click.rst index 3c691507d..06367daca 100644 --- a/src/click/doc/click.rst +++ b/src/click/doc/click.rst @@ -5,8 +5,7 @@ Click is a software architecture for building configurable routers. By using different combinations of packet processing units called elements, a Click router can be made to perform a specific kind of functionality. This flexibility provides a good platform for testing and experimenting with -different protocols. This project aims to integrate ns-3 with the Click -Modular Router so as to enable rapid protocol development. +different protocols. Model Description ***************** @@ -22,14 +21,28 @@ ns-3's design is well suited for an integration with Click due to the following * This also means that any kind of ns-3 traffic generator and transport should work easily on top of Click. * By striving to implement click as an Ipv4RoutingProtocol instance, we can avoid significant changes to the LL and MAC layer of the ns-3 code. -The design goal would be to make the ns-3-click public API simple enough such that the user needs to merely add an Ipv4ClickRouting instance to the node, and inform each Click node of the Click configuration file (.click file) that it is to use. +The design goal was to make the ns-3-click public API simple enough such that the user needs to merely add an Ipv4ClickRouting instance to the node, and inform each Click node of the Click configuration file (.click file) that it is to use. -Developing a Simulator API which will allow ns-3 to talk with Click and vice versa -################################################################################## +This model implements the interface to the Click Modular Router and +provides the Ipv4ClickRouting class to allow a node to use Click +for external routing. Unlike normal Ipv4RoutingProtocol sub types, +Ipv4ClickRouting doesn't use a RouteInput() method, but instead, +receives a packet on the appropriate interface and processes it +accordingly. Note that you need to have a routing table type element +in your Click graph to use Click for external routing. This is needed +by the RouteOutput() function inherited from Ipv4RoutingProtocol. +Furthermore, a Click based node uses a different kind of L3 in the +form of Ipv4L3ClickProtocol, which is a trimmed down version of +Ipv4L3Protocol. Ipv4L3ClickProtocol passes on packets passing through +the stack to Ipv4ClickRouting for processing. + + +Developing a Simulator API to allow ns-3 to interact with Click +############################################################### Much of the API is already well defined, which allows Click to probe for information from the simulator (like a Node's ID, an Interface ID and so forth). By retaining most of the methods, it should be possible to write new implementations specific to ns-3 for the same functionality. -Hence, for the Click integration with ns-3, a class named Ipv4ClickRouting will handle the interaction with Click. The code for the same can be found in ``src/click/model/ipv4-click-routing.[cc,h]``. +Hence, for the Click integration with ns-3, a class named Ipv4ClickRouting will handle the interaction with Click. The code for the same can be found in ``src/click/model/ipv4-click-routing.{cc,h}``. Packet hand off between ns-3 and Click ###################################### @@ -54,7 +67,8 @@ References ========== * Eddie Kohler, Robert Morris, Benjie Chen, John Jannotti, and M. Frans Kaashoek. The click modular router. ACM Transactions on Computer Systems 18(3), August 2000, pages 263-297. -* Neufeld, Michael and Jain, Ashish and Grunwald, Dirk. Nsclick: bridging network simulation and deployment. MSWiM '02: Proceedings of the 5th ACM international workshop on Modeling analysis and simulation of wireless and mobile systems, 2002, Atlanta, Georgia, USA. http://doi.acm.org/10.1145/570758.570772 +* Lalith Suresh P., and Ruben Merz. Ns-3-click: click modular router integration for ns-3. In Proc. of 3rd International ICST Workshop on NS-3 (WNS3), Barcelona, Spain. March, 2011. +* Michael Neufeld, Ashish Jain, and Dirk Grunwald. Nsclick: bridging network simulation and deployment. MSWiM '02: Proceedings of the 5th ACM international workshop on Modeling analysis and simulation of wireless and mobile systems, 2002, Atlanta, Georgia, USA. http://doi.acm.org/10.1145/570758.570772 Usage ***** @@ -62,7 +76,7 @@ Usage Building Click ============== -The first step is to build Click. At the top of your Click source directory:: +The first step is to fetch (http://read.cs.ucla.edu/click/download) and build Click. At the top of your Click source directory:: $: ./configure --enable-userlevel --disable-linuxmodule --enable-nsclick --enable-wifi $: make @@ -119,7 +133,7 @@ class in your simulation script. For instance:: click.Install (myNodeContainer); The example scripts inside ``src/click/examples/`` demonstrate the use of Click based nodes -in different scenarios. The helper source can be found inside ``src/click/helper/click-internet-stack-helper.[h,cc]`` +in different scenarios. The helper source can be found inside ``src/click/helper/click-internet-stack-helper.{h,cc}`` Examples ======== diff --git a/src/click/examples/nsclick-ip-router.click b/src/click/examples/nsclick-ip-router.click index 9d4586fbb..450b5b18a 100644 --- a/src/click/examples/nsclick-ip-router.click +++ b/src/click/examples/nsclick-ip-router.click @@ -39,7 +39,7 @@ c0[3] -> Discard; c1 :: Classifier(12/0806 20/0001, 12/0806 20/0002, 12/0800, -); FromSimDevice(eth1, 4096) -> c1; out1 :: Queue(200) -> todevice1 :: ToSimDevice(eth1); -c1[0] -> ar1 :: ARPResponder(eth0) -> out1; +c1[0] -> ar1 :: ARPResponder(eth1) -> out1; arpq1 :: ARPQuerier(eth1) -> out1; c1[1] -> arpt; arpt[1] -> [1]arpq1; diff --git a/src/click/examples/nsclick-raw-wlan.cc b/src/click/examples/nsclick-raw-wlan.cc index c237cb830..f9d983a41 100644 --- a/src/click/examples/nsclick-raw-wlan.cc +++ b/src/click/examples/nsclick-raw-wlan.cc @@ -138,6 +138,8 @@ int main (int argc, char *argv[]) Simulator::Stop (Seconds (20.0)); Simulator::Run (); + + Simulator::Destroy (); return 0; #else NS_FATAL_ERROR ("Can't use ns-3-click without NSCLICK compiled in"); diff --git a/src/click/examples/nsclick-routing-node2.click b/src/click/examples/nsclick-routing-node2.click index 4fcfe0f6e..77adb57c3 100644 --- a/src/click/examples/nsclick-routing-node2.click +++ b/src/click/examples/nsclick-routing-node2.click @@ -82,7 +82,7 @@ elementclass TapSimHost { $dev | // It is mandatory to use an IPRouteTable element with ns-3-click - rt :: LinearIPLookup (172.16.2.0/24 0.0.0.0 1,172.16.1.0/24 172.16.1.2 1); + rt :: LinearIPLookup (172.16.2.0/24 0.0.0.0 1,172.16.1.0/24 172.16.2.1 1); // Packets go to "tap0" which sends them to the kernel input[0] diff --git a/src/click/examples/nsclick-routing.cc b/src/click/examples/nsclick-routing.cc index 0b1d9cace..ea72ca557 100644 --- a/src/click/examples/nsclick-routing.cc +++ b/src/click/examples/nsclick-routing.cc @@ -20,7 +20,7 @@ // // // 172.16.1.0/24 -// (1.1) (1.2) (1.3) (1.4) +// (1.1) (1.2) (2.1) (2.2) // // eth0 eth0 eth1 eth0 // n0 ========= n1 ========= n2 diff --git a/src/click/examples/nsclick-simple-lan.cc b/src/click/examples/nsclick-simple-lan.cc index b5dd6e5ce..61b58821e 100644 --- a/src/click/examples/nsclick-simple-lan.cc +++ b/src/click/examples/nsclick-simple-lan.cc @@ -92,6 +92,8 @@ int main (int argc, char *argv[]) Simulator::Stop (Seconds (20.0)); Simulator::Run (); + + Simulator::Destroy (); return 0; #else NS_FATAL_ERROR ("Can't use ns-3-click without NSCLICK compiled in"); diff --git a/src/click/model/ipv4-click-routing.h b/src/click/model/ipv4-click-routing.h index 6bc5faab2..c2ea3125a 100644 --- a/src/click/model/ipv4-click-routing.h +++ b/src/click/model/ipv4-click-routing.h @@ -39,6 +39,11 @@ namespace ns3 { +/** +* \defgroup click Click Routing +* This section documents the API of the ns-3 click module. For a generic functional description, please refer to the ns-3 manual. +*/ + /** * \ingroup click * \brief Class to allow a node to use Click for external routing diff --git a/src/click/model/ipv4-l3-click-protocol.h b/src/click/model/ipv4-l3-click-protocol.h index de02c2f31..ae5c43fbe 100644 --- a/src/click/model/ipv4-l3-click-protocol.h +++ b/src/click/model/ipv4-l3-click-protocol.h @@ -48,6 +48,7 @@ class Icmpv4L4Protocol; /** * \brief Implement the Ipv4 layer specifically for Click nodes * to allow a clean integration of Click. + * \ingroup click * * This is code is mostly repeated from the Ipv4L3Protocol implementation. * Changes include: diff --git a/src/click/test/examples-to-run.py b/src/click/test/examples-to-run.py index 8fd1bfb68..4acdd6c0c 100644 --- a/src/click/test/examples-to-run.py +++ b/src/click/test/examples-to-run.py @@ -8,7 +8,7 @@ # # See test.py for more information. cpp_examples = [ - ("nsclick-simple-lan", "ENABLE_CLICK == True", "True"), + ("nsclick-simple-lan", "ENABLE_CLICK == True", "False"), ] # A list of Python examples to run in order to ensure that they remain diff --git a/src/click/wscript b/src/click/wscript index ae5dbafc6..a600b78ee 100644 --- a/src/click/wscript +++ b/src/click/wscript @@ -24,6 +24,11 @@ def configure(conf): conf.check_message("click location", '', False) conf.report_optional_feature("nsclick", "NS-3 Click Integration", False, "nsclick not enabled (see option --with-nsclick)") + + # Add this module to the list of modules that won't be built + # if they are enabled. + conf.env['MODULES_NOT_BUILT'].append('click') + return test_code = ''' @@ -69,8 +74,15 @@ int main() if conf.env['NSCLICK']: conf.env.append_value('CXXDEFINES', 'NS3_CLICK') conf.env.append_value('CPPPATH', conf.env['CPPPATH_NSCLICK']) + else: + # Add this module to the list of modules that won't be built + # if they are enabled. + conf.env['MODULES_NOT_BUILT'].append('click') def build(bld): + # Don't do anything for this module if click should not be built. + if 'click' in bld.env['MODULES_NOT_BUILT']: + return module = bld.create_ns3_module('click', ['internet']) module.includes = '. CPPPATH_NSCLICK' diff --git a/src/config-store/model/raw-text-config.cc b/src/config-store/model/raw-text-config.cc index 5c0109699..f73659a60 100644 --- a/src/config-store/model/raw-text-config.cc +++ b/src/config-store/model/raw-text-config.cc @@ -118,7 +118,7 @@ RawTextConfigLoad::Default (void) m_is->seekg (0); std::string type, name, value; *m_is >> type >> name >> value; - while (m_is->good()) + while (m_is->good ()) { NS_LOG_DEBUG ("type=" << type << ", name=" << name << ", value=" << value); value = Strip (value); @@ -135,7 +135,7 @@ RawTextConfigLoad::Global (void) m_is->seekg (0); std::string type, name, value; *m_is >> type >> name >> value; - while (m_is->good()) + while (m_is->good ()) { NS_LOG_DEBUG ("type=" << type << ", name=" << name << ", value=" << value); value = Strip (value); @@ -152,7 +152,7 @@ RawTextConfigLoad::Attributes (void) m_is->seekg (0); std::string type, path, value; *m_is >> type >> path >> value; - while (m_is->good()) + while (m_is->good ()) { NS_LOG_DEBUG ("type=" << type << ", path=" << path << ", value=" << value); value = Strip (value); diff --git a/src/config-store/model/xml-config.cc b/src/config-store/model/xml-config.cc index 833fc0d86..098ccc49c 100644 --- a/src/config-store/model/xml-config.cc +++ b/src/config-store/model/xml-config.cc @@ -29,7 +29,7 @@ XmlConfigSave::SetFilename (std::string filename) int rc; /* Create a new XmlWriter for uri, with no compression. */ - m_writer = xmlNewTextWriterFilename(filename.c_str (), 0); + m_writer = xmlNewTextWriterFilename (filename.c_str (), 0); if (m_writer == NULL) { NS_FATAL_ERROR ("Error creating the xml writer"); @@ -42,7 +42,7 @@ XmlConfigSave::SetFilename (std::string filename) /* Start the document with the xml default for the version, * encoding utf-8 and the default for the standalone * declaration. */ - rc = xmlTextWriterStartDocument(m_writer, NULL, "utf-8", NULL); + rc = xmlTextWriterStartDocument (m_writer, NULL, "utf-8", NULL); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterStartDocument"); @@ -50,7 +50,7 @@ XmlConfigSave::SetFilename (std::string filename) /* Start an element named "ns3". Since thist is the first * element, this will be the root element of the document. */ - rc = xmlTextWriterStartElement(m_writer, BAD_CAST "ns3"); + rc = xmlTextWriterStartElement (m_writer, BAD_CAST "ns3"); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterStartElement\n"); @@ -68,13 +68,13 @@ XmlConfigSave::~XmlConfigSave () * function xmlTextWriterEndElement, but since we do not want to * write any other elements, we simply call xmlTextWriterEndDocument, * which will do all the work. */ - rc = xmlTextWriterEndDocument(m_writer); + rc = xmlTextWriterEndDocument (m_writer); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterEndDocument\n"); } - xmlFreeTextWriter(m_writer); + xmlFreeTextWriter (m_writer); m_writer = 0; } void @@ -92,25 +92,25 @@ private: } virtual void DoVisitAttribute (std::string name, std::string defaultValue) { int rc; - rc = xmlTextWriterStartElement(m_writer, BAD_CAST "default"); + rc = xmlTextWriterStartElement (m_writer, BAD_CAST "default"); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterStartElement"); } std::string fullname = m_typeid + "::" + name; - rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "name", - BAD_CAST fullname.c_str ()); + rc = xmlTextWriterWriteAttribute (m_writer, BAD_CAST "name", + BAD_CAST fullname.c_str ()); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); } - rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "value", - BAD_CAST defaultValue.c_str ()); + rc = xmlTextWriterWriteAttribute (m_writer, BAD_CAST "value", + BAD_CAST defaultValue.c_str ()); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); } - rc = xmlTextWriterEndElement(m_writer); + rc = xmlTextWriterEndElement (m_writer); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterEndElement"); @@ -136,24 +136,24 @@ private: StringValue str; object->GetAttribute (name, str); int rc; - rc = xmlTextWriterStartElement(m_writer, BAD_CAST "value"); + rc = xmlTextWriterStartElement (m_writer, BAD_CAST "value"); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterStartElement"); } - rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "path", - BAD_CAST GetCurrentPath ().c_str ()); + rc = xmlTextWriterWriteAttribute (m_writer, BAD_CAST "path", + BAD_CAST GetCurrentPath ().c_str ()); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); } - rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "value", - BAD_CAST str.Get ().c_str ()); + rc = xmlTextWriterWriteAttribute (m_writer, BAD_CAST "value", + BAD_CAST str.Get ().c_str ()); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); } - rc = xmlTextWriterEndElement(m_writer); + rc = xmlTextWriterEndElement (m_writer); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterEndElement"); @@ -175,24 +175,24 @@ XmlConfigSave::Global (void) StringValue value; (*i)->GetValue (value); - rc = xmlTextWriterStartElement(m_writer, BAD_CAST "global"); + rc = xmlTextWriterStartElement (m_writer, BAD_CAST "global"); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterStartElement"); } - rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "name", - BAD_CAST (*i)->GetName ().c_str ()); + rc = xmlTextWriterWriteAttribute (m_writer, BAD_CAST "name", + BAD_CAST (*i)->GetName ().c_str ()); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); } - rc = xmlTextWriterWriteAttribute(m_writer, BAD_CAST "value", - BAD_CAST value.Get ().c_str ()); + rc = xmlTextWriterWriteAttribute (m_writer, BAD_CAST "value", + BAD_CAST value.Get ().c_str ()); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterWriteAttribute"); } - rc = xmlTextWriterEndElement(m_writer); + rc = xmlTextWriterEndElement (m_writer); if (rc < 0) { NS_FATAL_ERROR ("Error at xmlTextWriterEndElement"); @@ -218,7 +218,7 @@ XmlConfigLoad::SetFilename (std::string filename) void XmlConfigLoad::Default (void) { - xmlTextReaderPtr reader = xmlNewTextReaderFilename(m_filename.c_str ()); + xmlTextReaderPtr reader = xmlNewTextReaderFilename (m_filename.c_str ()); if (reader == NULL) { NS_FATAL_ERROR ("Error at xmlReaderForFile"); @@ -227,7 +227,7 @@ XmlConfigLoad::Default (void) rc = xmlTextReaderRead (reader); while (rc > 0) { - const xmlChar *type = xmlTextReaderConstName(reader); + const xmlChar *type = xmlTextReaderConstName (reader); if (type == 0) { NS_FATAL_ERROR ("Invalid value"); @@ -256,7 +256,7 @@ XmlConfigLoad::Default (void) void XmlConfigLoad::Global (void) { - xmlTextReaderPtr reader = xmlNewTextReaderFilename(m_filename.c_str ()); + xmlTextReaderPtr reader = xmlNewTextReaderFilename (m_filename.c_str ()); if (reader == NULL) { NS_FATAL_ERROR ("Error at xmlReaderForFile"); @@ -265,7 +265,7 @@ XmlConfigLoad::Global (void) rc = xmlTextReaderRead (reader); while (rc > 0) { - const xmlChar *type = xmlTextReaderConstName(reader); + const xmlChar *type = xmlTextReaderConstName (reader); if (type == 0) { NS_FATAL_ERROR ("Invalid value"); @@ -294,7 +294,7 @@ XmlConfigLoad::Global (void) void XmlConfigLoad::Attributes (void) { - xmlTextReaderPtr reader = xmlNewTextReaderFilename(m_filename.c_str ()); + xmlTextReaderPtr reader = xmlNewTextReaderFilename (m_filename.c_str ()); if (reader == NULL) { NS_FATAL_ERROR ("Error at xmlReaderForFile"); @@ -303,7 +303,7 @@ XmlConfigLoad::Attributes (void) rc = xmlTextReaderRead (reader); while (rc > 0) { - const xmlChar *type = xmlTextReaderConstName(reader); + const xmlChar *type = xmlTextReaderConstName (reader); if (type == 0) { NS_FATAL_ERROR ("Invalid value"); diff --git a/src/core/bindings/module_helpers.cc b/src/core/bindings/module_helpers.cc index 17a389885..996bfece8 100644 --- a/src/core/bindings/module_helpers.cc +++ b/src/core/bindings/module_helpers.cc @@ -23,46 +23,46 @@ public: PythonEventImpl (PyObject *callback, PyObject *args) { m_callback = callback; - Py_INCREF(m_callback); + Py_INCREF (m_callback); m_args = args; - Py_INCREF(m_args); + Py_INCREF (m_args); } virtual ~PythonEventImpl () { PyGILState_STATE __py_gil_state; - __py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0); + __py_gil_state = (PyEval_ThreadsInitialized () ? PyGILState_Ensure () : (PyGILState_STATE) 0); - Py_DECREF(m_callback); - Py_DECREF(m_args); + Py_DECREF (m_callback); + Py_DECREF (m_args); - if (PyEval_ThreadsInitialized()) - PyGILState_Release(__py_gil_state); + if (PyEval_ThreadsInitialized ()) + PyGILState_Release (__py_gil_state); } virtual void Notify () { PyGILState_STATE __py_gil_state; - __py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0); + __py_gil_state = (PyEval_ThreadsInitialized () ? PyGILState_Ensure () : (PyGILState_STATE) 0); - PyObject *retval = PyObject_CallObject(m_callback, m_args); + PyObject *retval = PyObject_CallObject (m_callback, m_args); if (retval) { if (retval != Py_None) { - PyErr_SetString(PyExc_TypeError, "event callback should return None"); - PyErr_Print(); + PyErr_SetString (PyExc_TypeError, "event callback should return None"); + PyErr_Print (); } - Py_DECREF(retval); + Py_DECREF (retval); } else { - PyErr_Print(); + PyErr_Print (); } - if (PyEval_ThreadsInitialized()) - PyGILState_Release(__py_gil_state); + if (PyEval_ThreadsInitialized ()) + PyGILState_Release (__py_gil_state); } }; PyObject * -_wrap_Simulator_Schedule(PyNs3Simulator *PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs, - PyObject **return_exception) +_wrap_Simulator_Schedule (PyNs3Simulator *PYBINDGEN_UNUSED (dummy), PyObject *args, PyObject *kwargs, + PyObject **return_exception) { PyObject *exc_type, *traceback; PyObject *py_time; @@ -71,47 +71,47 @@ _wrap_Simulator_Schedule(PyNs3Simulator *PYBINDGEN_UNUSED(dummy), PyObject *args ns3::Ptr py_event_impl; PyNs3EventId *py_EventId; - if (kwargs && PyObject_Length(kwargs) > 0) { - PyErr_SetString(PyExc_TypeError, "keyword arguments not supported"); + if (kwargs && PyObject_Length (kwargs) > 0) { + PyErr_SetString (PyExc_TypeError, "keyword arguments not supported"); goto error; } - if (PyTuple_GET_SIZE(args) < 2) { - PyErr_SetString(PyExc_TypeError, "ns3.Simulator.Schedule needs at least 2 arguments"); + if (PyTuple_GET_SIZE (args) < 2) { + PyErr_SetString (PyExc_TypeError, "ns3.Simulator.Schedule needs at least 2 arguments"); goto error; } - py_time = PyTuple_GET_ITEM(args, 0); - py_callback = PyTuple_GET_ITEM(args, 1); + py_time = PyTuple_GET_ITEM (args, 0); + py_callback = PyTuple_GET_ITEM (args, 1); - if (!PyObject_IsInstance(py_time, (PyObject*) &PyNs3Time_Type)) { - PyErr_SetString(PyExc_TypeError, "Parameter 1 should be a ns3.Time instance"); + if (!PyObject_IsInstance (py_time, (PyObject*) &PyNs3Time_Type)) { + PyErr_SetString (PyExc_TypeError, "Parameter 1 should be a ns3.Time instance"); goto error; } - if (!PyCallable_Check(py_callback)) { - PyErr_SetString(PyExc_TypeError, "Parameter 2 should be callable"); + if (!PyCallable_Check (py_callback)) { + PyErr_SetString (PyExc_TypeError, "Parameter 2 should be callable"); goto error; } - user_args = PyTuple_GetSlice(args, 2, PyTuple_GET_SIZE(args)); + user_args = PyTuple_GetSlice (args, 2, PyTuple_GET_SIZE (args)); py_event_impl = ns3::Create(py_callback, user_args); - Py_DECREF(user_args); + Py_DECREF (user_args); - py_EventId = PyObject_New(PyNs3EventId, &PyNs3EventId_Type); - py_EventId->obj = new ns3::EventId( - ns3::Simulator::Schedule(*((PyNs3Time *) py_time)->obj, py_event_impl)); + py_EventId = PyObject_New (PyNs3EventId, &PyNs3EventId_Type); + py_EventId->obj = new ns3::EventId ( + ns3::Simulator::Schedule (*((PyNs3Time *) py_time)->obj, py_event_impl)); py_EventId->flags = PYBINDGEN_WRAPPER_FLAG_NONE; return (PyObject *) py_EventId; error: - PyErr_Fetch(&exc_type, return_exception, &traceback); - Py_XDECREF(exc_type); - Py_XDECREF(traceback); + PyErr_Fetch (&exc_type, return_exception, &traceback); + Py_XDECREF (exc_type); + Py_XDECREF (traceback); return NULL; } PyObject * -_wrap_Simulator_ScheduleNow(PyNs3Simulator *PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs, - PyObject **return_exception) +_wrap_Simulator_ScheduleNow (PyNs3Simulator *PYBINDGEN_UNUSED (dummy), PyObject *args, PyObject *kwargs, + PyObject **return_exception) { PyObject *exc_type, *traceback; PyObject *py_callback; @@ -119,41 +119,41 @@ _wrap_Simulator_ScheduleNow(PyNs3Simulator *PYBINDGEN_UNUSED(dummy), PyObject *a ns3::Ptr py_event_impl; PyNs3EventId *py_EventId; - if (kwargs && PyObject_Length(kwargs) > 0) { - PyErr_SetString(PyExc_TypeError, "keyword arguments not supported"); + if (kwargs && PyObject_Length (kwargs) > 0) { + PyErr_SetString (PyExc_TypeError, "keyword arguments not supported"); goto error; } - if (PyTuple_GET_SIZE(args) < 1) { - PyErr_SetString(PyExc_TypeError, "ns3.Simulator.Schedule needs at least 1 argument"); + if (PyTuple_GET_SIZE (args) < 1) { + PyErr_SetString (PyExc_TypeError, "ns3.Simulator.Schedule needs at least 1 argument"); goto error; } - py_callback = PyTuple_GET_ITEM(args, 0); + py_callback = PyTuple_GET_ITEM (args, 0); - if (!PyCallable_Check(py_callback)) { - PyErr_SetString(PyExc_TypeError, "Parameter 2 should be callable"); + if (!PyCallable_Check (py_callback)) { + PyErr_SetString (PyExc_TypeError, "Parameter 2 should be callable"); goto error; } - user_args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args)); + user_args = PyTuple_GetSlice (args, 1, PyTuple_GET_SIZE (args)); py_event_impl = ns3::Create(py_callback, user_args); - Py_DECREF(user_args); + Py_DECREF (user_args); - py_EventId = PyObject_New(PyNs3EventId, &PyNs3EventId_Type); - py_EventId->obj = new ns3::EventId(ns3::Simulator::ScheduleNow(py_event_impl)); + py_EventId = PyObject_New (PyNs3EventId, &PyNs3EventId_Type); + py_EventId->obj = new ns3::EventId (ns3::Simulator::ScheduleNow (py_event_impl)); py_EventId->flags = PYBINDGEN_WRAPPER_FLAG_NONE; return (PyObject *) py_EventId; error: - PyErr_Fetch(&exc_type, return_exception, &traceback); - Py_XDECREF(exc_type); - Py_XDECREF(traceback); + PyErr_Fetch (&exc_type, return_exception, &traceback); + Py_XDECREF (exc_type); + Py_XDECREF (traceback); return NULL; } PyObject * -_wrap_Simulator_ScheduleDestroy(PyNs3Simulator *PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs, - PyObject **return_exception) +_wrap_Simulator_ScheduleDestroy (PyNs3Simulator *PYBINDGEN_UNUSED (dummy), PyObject *args, PyObject *kwargs, + PyObject **return_exception) { PyObject *exc_type, *traceback; PyObject *py_callback; @@ -161,41 +161,41 @@ _wrap_Simulator_ScheduleDestroy(PyNs3Simulator *PYBINDGEN_UNUSED(dummy), PyObjec ns3::Ptr py_event_impl; PyNs3EventId *py_EventId; - if (kwargs && PyObject_Length(kwargs) > 0) { - PyErr_SetString(PyExc_TypeError, "keyword arguments not supported"); + if (kwargs && PyObject_Length (kwargs) > 0) { + PyErr_SetString (PyExc_TypeError, "keyword arguments not supported"); goto error; } - if (PyTuple_GET_SIZE(args) < 1) { - PyErr_SetString(PyExc_TypeError, "ns3.Simulator.Schedule needs at least 1 argument"); + if (PyTuple_GET_SIZE (args) < 1) { + PyErr_SetString (PyExc_TypeError, "ns3.Simulator.Schedule needs at least 1 argument"); goto error; } - py_callback = PyTuple_GET_ITEM(args, 0); + py_callback = PyTuple_GET_ITEM (args, 0); - if (!PyCallable_Check(py_callback)) { - PyErr_SetString(PyExc_TypeError, "Parameter 2 should be callable"); + if (!PyCallable_Check (py_callback)) { + PyErr_SetString (PyExc_TypeError, "Parameter 2 should be callable"); goto error; } - user_args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args)); + user_args = PyTuple_GetSlice (args, 1, PyTuple_GET_SIZE (args)); py_event_impl = ns3::Create(py_callback, user_args); - Py_DECREF(user_args); + Py_DECREF (user_args); - py_EventId = PyObject_New(PyNs3EventId, &PyNs3EventId_Type); - py_EventId->obj = new ns3::EventId(ns3::Simulator::ScheduleDestroy(py_event_impl)); + py_EventId = PyObject_New (PyNs3EventId, &PyNs3EventId_Type); + py_EventId->obj = new ns3::EventId (ns3::Simulator::ScheduleDestroy (py_event_impl)); py_EventId->flags = PYBINDGEN_WRAPPER_FLAG_NONE; return (PyObject *) py_EventId; error: - PyErr_Fetch(&exc_type, return_exception, &traceback); - Py_XDECREF(exc_type); - Py_XDECREF(traceback); + PyErr_Fetch (&exc_type, return_exception, &traceback); + Py_XDECREF (exc_type); + Py_XDECREF (traceback); return NULL; } PyObject * -_wrap_TypeId_LookupByNameFailSafe(PyNs3TypeId *PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs, - PyObject **return_exception) +_wrap_TypeId_LookupByNameFailSafe (PyNs3TypeId *PYBINDGEN_UNUSED (dummy), PyObject *args, PyObject *kwargs, + PyObject **return_exception) { bool ok; const char *name; @@ -204,21 +204,21 @@ _wrap_TypeId_LookupByNameFailSafe(PyNs3TypeId *PYBINDGEN_UNUSED(dummy), PyObject PyNs3TypeId *py_tid; const char *keywords[] = { "name", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "s#", (char **) keywords, &name, &name_len)) { + if (!PyArg_ParseTupleAndKeywords (args, kwargs, (char *) "s#", (char **) keywords, &name, &name_len)) { PyObject *exc_type, *traceback; - PyErr_Fetch(&exc_type, return_exception, &traceback); - Py_XDECREF(exc_type); - Py_XDECREF(traceback); + PyErr_Fetch (&exc_type, return_exception, &traceback); + Py_XDECREF (exc_type); + Py_XDECREF (traceback); return NULL; } - ok = ns3::TypeId::LookupByNameFailSafe(std::string(name, name_len), &tid); + ok = ns3::TypeId::LookupByNameFailSafe (std::string (name, name_len), &tid); if (!ok) { - PyErr_Format(PyExc_KeyError, "The ns3 type with name `%s' is not registered", name); + PyErr_Format (PyExc_KeyError, "The ns3 type with name `%s' is not registered", name); return NULL; } - py_tid = PyObject_New(PyNs3TypeId, &PyNs3TypeId_Type); + py_tid = PyObject_New (PyNs3TypeId, &PyNs3TypeId_Type); py_tid->obj = new ns3::TypeId (tid); PyNs3TypeId_wrapper_registry[(void *) py_tid->obj] = (PyObject *) py_tid; @@ -232,15 +232,15 @@ class CommandLinePythonValueSetter : public ns3::RefCountBase std::string m_variable; public: CommandLinePythonValueSetter (PyObject *ns, std::string const &variable) { - Py_INCREF(ns); + Py_INCREF (ns); m_namespace = ns; m_variable = variable; } bool Parse (std::string value) { - PyObject *pyvalue = PyString_FromStringAndSize (value.data(), value.size()); - PyObject_SetAttrString (m_namespace, (char *) m_variable.c_str(), pyvalue); - if (PyErr_Occurred()) { - PyErr_Print(); + PyObject *pyvalue = PyString_FromStringAndSize (value.data (), value.size ()); + PyObject_SetAttrString (m_namespace, (char *) m_variable.c_str (), pyvalue); + if (PyErr_Occurred ()) { + PyErr_Print (); return false; } return true; @@ -253,18 +253,18 @@ public: }; PyObject * -_wrap_CommandLine_AddValue(PyNs3CommandLine *self, PyObject *args, PyObject *kwargs, - PyObject **return_exception) +_wrap_CommandLine_AddValue (PyNs3CommandLine *self, PyObject *args, PyObject *kwargs, + PyObject **return_exception) { const char *name, *help, *variable = NULL; PyObject *py_namespace = NULL; const char *keywords[] = { "name", "help", "variable", "namespace", NULL}; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "ss|sO", (char **) keywords, &name, &help, &variable, &py_namespace)) { + if (!PyArg_ParseTupleAndKeywords (args, kwargs, (char *) "ss|sO", (char **) keywords, &name, &help, &variable, &py_namespace)) { PyObject *exc_type, *traceback; - PyErr_Fetch(&exc_type, return_exception, &traceback); - Py_XDECREF(exc_type); - Py_XDECREF(traceback); + PyErr_Fetch (&exc_type, return_exception, &traceback); + Py_XDECREF (exc_type); + Py_XDECREF (traceback); return NULL; } @@ -278,14 +278,14 @@ _wrap_CommandLine_AddValue(PyNs3CommandLine *self, PyObject *args, PyObject *kwa ns3::Ptr setter = ns3::Create (py_namespace, variable); self->obj->AddValue (name, help, ns3::MakeCallback (&CommandLinePythonValueSetter::Parse, setter)); - Py_INCREF(Py_None); + Py_INCREF (Py_None); return Py_None; } PyObject * -_wrap_Simulator_Run(PyNs3Simulator *PYBINDGEN_UNUSED(dummy), PyObject *args, PyObject *kwargs, - PyObject **return_exception) +_wrap_Simulator_Run (PyNs3Simulator *PYBINDGEN_UNUSED (dummy), PyObject *args, PyObject *kwargs, + PyObject **return_exception) { const char *keywords[] = { "signal_check_frequency", NULL}; int signal_check_frequency; @@ -298,11 +298,11 @@ _wrap_Simulator_Run(PyNs3Simulator *PYBINDGEN_UNUSED(dummy), PyObject *args, PyO signal_check_frequency = -1; } - if (!PyArg_ParseTupleAndKeywords(args, kwargs, (char *) "|i", (char **) keywords, &signal_check_frequency)) { + if (!PyArg_ParseTupleAndKeywords (args, kwargs, (char *) "|i", (char **) keywords, &signal_check_frequency)) { PyObject *exc_type, *traceback; - PyErr_Fetch(&exc_type, return_exception, &traceback); - Py_XDECREF(exc_type); - Py_XDECREF(traceback); + PyErr_Fetch (&exc_type, return_exception, &traceback); + Py_XDECREF (exc_type); + Py_XDECREF (traceback); return NULL; } @@ -311,29 +311,29 @@ _wrap_Simulator_Run(PyNs3Simulator *PYBINDGEN_UNUSED(dummy), PyObject *args, PyO if (signal_check_frequency == -1) { if (PyEval_ThreadsInitialized ()) - py_thread_state = PyEval_SaveThread(); - ns3::Simulator::Run(); + py_thread_state = PyEval_SaveThread (); + ns3::Simulator::Run (); if (py_thread_state) - PyEval_RestoreThread(py_thread_state); + PyEval_RestoreThread (py_thread_state); } else { - while (!ns3::Simulator::IsFinished()) + while (!ns3::Simulator::IsFinished ()) { - if (PyEval_ThreadsInitialized()) - py_thread_state = PyEval_SaveThread(); + if (PyEval_ThreadsInitialized ()) + py_thread_state = PyEval_SaveThread (); - for (int n = signal_check_frequency; n > 0 && !ns3::Simulator::IsFinished(); --n) + for (int n = signal_check_frequency; n > 0 && !ns3::Simulator::IsFinished (); --n) { - ns3::Simulator::RunOneEvent(); + ns3::Simulator::RunOneEvent (); } if (py_thread_state) - PyEval_RestoreThread(py_thread_state); - PyErr_CheckSignals(); - if (PyErr_Occurred()) + PyEval_RestoreThread (py_thread_state); + PyErr_CheckSignals (); + if (PyErr_Occurred ()) return NULL; } } - Py_INCREF(Py_None); + Py_INCREF (Py_None); return Py_None; } diff --git a/src/core/examples/main-random-variable.cc b/src/core/examples/main-random-variable.cc index de16cd6da..cca00e641 100644 --- a/src/core/examples/main-random-variable.cc +++ b/src/core/examples/main-random-variable.cc @@ -26,13 +26,13 @@ using namespace ns3; /// Round a double number to the given precision. e.g. dround(0.234, 0.1) = 0.2 /// and dround(0.257, 0.1) = 0.3 -double dround(double number, double precision) +double dround (double number, double precision) { number /= precision; if (number >= 0) - number = std::floor(number + 0.5); + number = std::floor (number + 0.5); else - number = std::ceil(number - 0.5); + number = std::ceil (number - 0.5); number *= precision; return number; } @@ -45,23 +45,23 @@ Histogramm (RandomVariable rndvar, unsigned int probes, double precision, const for(unsigned int i = 0; i < probes; ++i) { - double val = dround( rndvar.GetValue(), precision ); + double val = dround ( rndvar.GetValue (), precision ); ++histogramm[val]; } Gnuplot2dDataset data; - data.SetTitle(title); + data.SetTitle (title); if (notcontinous) { - data.SetStyle(Gnuplot2dDataset::IMPULSES); + data.SetStyle (Gnuplot2dDataset::IMPULSES); } - for(histogramm_maptype::const_iterator hi = histogramm.begin(); - hi != histogramm.end(); ++hi) + for(histogramm_maptype::const_iterator hi = histogramm.begin (); + hi != histogramm.end (); ++hi) { - data.Add(hi->first, (double)hi->second / (double)probes / precision); + data.Add (hi->first, (double)hi->second / (double)probes / precision); } return data; @@ -72,306 +72,306 @@ int main (int argc, char *argv[]) unsigned int probes = 1000000; double precision = 0.01; - GnuplotCollection gnuplots("main-random-variables.pdf"); - gnuplots.SetTerminal("pdf enhanced"); + GnuplotCollection gnuplots ("main-random-variables.pdf"); + gnuplots.SetTerminal ("pdf enhanced"); { Gnuplot plot; - plot.SetTitle("UniformVariable"); - plot.AppendExtra("set yrange [0:]"); + plot.SetTitle ("UniformVariable"); + plot.AppendExtra ("set yrange [0:]"); - plot.AddDataset( Histogramm(UniformVariable(0.0, 1.0), probes, precision, - "UniformVariable [0.0 .. 1.0)") ); + plot.AddDataset ( Histogramm (UniformVariable (0.0, 1.0), probes, precision, + "UniformVariable [0.0 .. 1.0)") ); - plot.AddDataset( Gnuplot2dFunction("0.1", - "0 <= x && x <= 1 ? 1.0 : 0") ); + plot.AddDataset ( Gnuplot2dFunction ("0.1", + "0 <= x && x <= 1 ? 1.0 : 0") ); - gnuplots.AddPlot(plot); + gnuplots.AddPlot (plot); } { Gnuplot plot; - plot.SetTitle("ExponentialVariable"); - plot.AppendExtra("set xrange [0:8]"); - plot.AppendExtra("ExpDist(x,l) = 1/l * exp(-1/l * x)"); + plot.SetTitle ("ExponentialVariable"); + plot.AppendExtra ("set xrange [0:8]"); + plot.AppendExtra ("ExpDist(x,l) = 1/l * exp(-1/l * x)"); - plot.AddDataset( Histogramm(ExponentialVariable(0.5), probes, precision, - "ExponentialVariable m=0.5") ); + plot.AddDataset ( Histogramm (ExponentialVariable (0.5), probes, precision, + "ExponentialVariable m=0.5") ); - plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 0.5", - "ExpDist(x, 0.5)") ); + plot.AddDataset ( Gnuplot2dFunction ("ExponentialDistribution mean 0.5", + "ExpDist(x, 0.5)") ); - plot.AddDataset( Histogramm(ExponentialVariable(1.0), probes, precision, - "ExponentialVariable m=1") ); + plot.AddDataset ( Histogramm (ExponentialVariable (1.0), probes, precision, + "ExponentialVariable m=1") ); - plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 1.0", - "ExpDist(x, 1.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("ExponentialDistribution mean 1.0", + "ExpDist(x, 1.0)") ); - plot.AddDataset( Histogramm(ExponentialVariable(1.5), probes, precision, - "ExponentialVariable m=1.5") ); + plot.AddDataset ( Histogramm (ExponentialVariable (1.5), probes, precision, + "ExponentialVariable m=1.5") ); - plot.AddDataset( Gnuplot2dFunction("ExponentialDistribution mean 1.5", - "ExpDist(x, 1.5)") ); + plot.AddDataset ( Gnuplot2dFunction ("ExponentialDistribution mean 1.5", + "ExpDist(x, 1.5)") ); - gnuplots.AddPlot(plot); + gnuplots.AddPlot (plot); } { Gnuplot plot; - plot.SetTitle("ParetoVariable"); - plot.AppendExtra("set xrange [0:2]"); + plot.SetTitle ("ParetoVariable"); + plot.AppendExtra ("set xrange [0:2]"); - plot.AddDataset( Histogramm(ParetoVariable(1.0, 1.5), probes, precision, - "ParetoVariable m=1.0 s=1.5") ); + plot.AddDataset ( Histogramm (ParetoVariable (1.0, 1.5), probes, precision, + "ParetoVariable m=1.0 s=1.5") ); - plot.AddDataset( Histogramm(ParetoVariable(1.0, 2.0), probes, precision, - "ParetoVariable m=1.0 s=2.0") ); + plot.AddDataset ( Histogramm (ParetoVariable (1.0, 2.0), probes, precision, + "ParetoVariable m=1.0 s=2.0") ); - plot.AddDataset( Histogramm(ParetoVariable(1.0, 2.5), probes, precision, - "ParetoVariable m=1.0 s=2.5") ); + plot.AddDataset ( Histogramm (ParetoVariable (1.0, 2.5), probes, precision, + "ParetoVariable m=1.0 s=2.5") ); - gnuplots.AddPlot(plot); + gnuplots.AddPlot (plot); } { Gnuplot plot; - plot.SetTitle("WeibullVariable"); - plot.AppendExtra("set xrange [0:3]"); + plot.SetTitle ("WeibullVariable"); + plot.AppendExtra ("set xrange [0:3]"); - plot.AddDataset( Histogramm(WeibullVariable(1.0, 1.0), probes, precision, - "WeibullVariable m=1.0 s=1.0") ); + plot.AddDataset ( Histogramm (WeibullVariable (1.0, 1.0), probes, precision, + "WeibullVariable m=1.0 s=1.0") ); - plot.AddDataset( Histogramm(WeibullVariable(1.0, 2.0), probes, precision, - "WeibullVariable m=1.0 s=2.0") ); + plot.AddDataset ( Histogramm (WeibullVariable (1.0, 2.0), probes, precision, + "WeibullVariable m=1.0 s=2.0") ); - plot.AddDataset( Histogramm(WeibullVariable(1.0, 3.0), probes, precision, - "WeibullVariable m=1.0 s=3.0") ); + plot.AddDataset ( Histogramm (WeibullVariable (1.0, 3.0), probes, precision, + "WeibullVariable m=1.0 s=3.0") ); - gnuplots.AddPlot(plot); + gnuplots.AddPlot (plot); } { Gnuplot plot; - plot.SetTitle("NormalVariable"); - plot.AppendExtra("set xrange [-3:3]"); - plot.AppendExtra("NormalDist(x,m,s) = 1 / (s * sqrt(2*pi)) * exp(-1.0 / 2.0 * ((x-m) / s)**2)"); + plot.SetTitle ("NormalVariable"); + plot.AppendExtra ("set xrange [-3:3]"); + plot.AppendExtra ("NormalDist(x,m,s) = 1 / (s * sqrt(2*pi)) * exp(-1.0 / 2.0 * ((x-m) / s)**2)"); - plot.AddDataset( Histogramm(NormalVariable(0.0, 1.0), probes, precision, - "NormalVariable m=0.0 v=1.0") ); + plot.AddDataset ( Histogramm (NormalVariable (0.0, 1.0), probes, precision, + "NormalVariable m=0.0 v=1.0") ); - plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=1.0", - "NormalDist(x,0.0,1.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("NormalDist {/Symbol m}=0.0 {/Symbol s}=1.0", + "NormalDist(x,0.0,1.0)") ); - plot.AddDataset( Histogramm(NormalVariable(0.0, 2.0), probes, precision, - "NormalVariable m=0.0 v=2.0") ); + plot.AddDataset ( Histogramm (NormalVariable (0.0, 2.0), probes, precision, + "NormalVariable m=0.0 v=2.0") ); - plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(2.0)", - "NormalDist(x,0.0,sqrt(2.0))") ); + plot.AddDataset ( Gnuplot2dFunction ("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(2.0)", + "NormalDist(x,0.0,sqrt(2.0))") ); - plot.AddDataset( Histogramm(NormalVariable(0.0, 3.0), probes, precision, - "NormalVariable m=0.0 v=3.0") ); + plot.AddDataset ( Histogramm (NormalVariable (0.0, 3.0), probes, precision, + "NormalVariable m=0.0 v=3.0") ); - plot.AddDataset( Gnuplot2dFunction("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(3.0)", - "NormalDist(x,0.0,sqrt(3.0))") ); + plot.AddDataset ( Gnuplot2dFunction ("NormalDist {/Symbol m}=0.0 {/Symbol s}=sqrt(3.0)", + "NormalDist(x,0.0,sqrt(3.0))") ); - gnuplots.AddPlot(plot); + gnuplots.AddPlot (plot); } { Gnuplot plot; - plot.SetTitle("EmpiricalVariable"); - plot.AppendExtra("set xrange [*:*]"); + plot.SetTitle ("EmpiricalVariable"); + plot.AppendExtra ("set xrange [*:*]"); EmpiricalVariable emp1; - emp1.CDF(0.0, 0.0 / 15.0); - emp1.CDF(0.2, 1.0 / 15.0); - emp1.CDF(0.4, 3.0 / 15.0); - emp1.CDF(0.6, 6.0 / 15.0); - emp1.CDF(0.8, 10.0 / 15.0); - emp1.CDF(1.0, 15.0 / 15.0); + emp1.CDF (0.0, 0.0 / 15.0); + emp1.CDF (0.2, 1.0 / 15.0); + emp1.CDF (0.4, 3.0 / 15.0); + emp1.CDF (0.6, 6.0 / 15.0); + emp1.CDF (0.8, 10.0 / 15.0); + emp1.CDF (1.0, 15.0 / 15.0); - plot.AddDataset( Histogramm(emp1, probes, precision, - "EmpiricalVariable (Stairs)") ); + plot.AddDataset ( Histogramm (emp1, probes, precision, + "EmpiricalVariable (Stairs)") ); - gnuplots.AddPlot(plot); + gnuplots.AddPlot (plot); } { Gnuplot plot; - plot.SetTitle("DeterministicVariable"); - plot.AppendExtra("set xrange [*:*]"); + plot.SetTitle ("DeterministicVariable"); + plot.AppendExtra ("set xrange [*:*]"); double values[] = { 0.0, 0.2, 0.2, 0.4, 0.2, 0.6, 0.8, 0.8, 1.0 }; DeterministicVariable det1 (values, sizeof(values) / sizeof(values[0])); - plot.AddDataset( Histogramm(det1, probes, precision, - "DeterministicVariable", true) ); + plot.AddDataset ( Histogramm (det1, probes, precision, + "DeterministicVariable", true) ); - gnuplots.AddPlot(plot); + gnuplots.AddPlot (plot); } { Gnuplot plot; - plot.SetTitle("LogNormalVariable"); - plot.AppendExtra("set xrange [0:3]"); + plot.SetTitle ("LogNormalVariable"); + plot.AppendExtra ("set xrange [0:3]"); - plot.AppendExtra("LogNormalDist(x,m,s) = 1.0/x * NormalDist(log(x), m, s)"); + plot.AppendExtra ("LogNormalDist(x,m,s) = 1.0/x * NormalDist(log(x), m, s)"); - plot.AddDataset( Histogramm(LogNormalVariable(0.0, 1.0), probes, precision, - "LogNormalVariable m=0.0 s=1.0") ); + plot.AddDataset ( Histogramm (LogNormalVariable (0.0, 1.0), probes, precision, + "LogNormalVariable m=0.0 s=1.0") ); - plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 1.0)", - "LogNormalDist(x, 0.0, 1.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("LogNormalDist(x, 0.0, 1.0)", + "LogNormalDist(x, 0.0, 1.0)") ); - plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.5), probes, precision, - "LogNormalVariable m=0.0 s=0.5") ); + plot.AddDataset ( Histogramm (LogNormalVariable (0.0, 0.5), probes, precision, + "LogNormalVariable m=0.0 s=0.5") ); - plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.25), probes, precision, - "LogNormalVariable m=0.0 s=0.25") ); + plot.AddDataset ( Histogramm (LogNormalVariable (0.0, 0.25), probes, precision, + "LogNormalVariable m=0.0 s=0.25") ); - plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 0.25)", - "LogNormalDist(x, 0.0, 0.25)") ); + plot.AddDataset ( Gnuplot2dFunction ("LogNormalDist(x, 0.0, 0.25)", + "LogNormalDist(x, 0.0, 0.25)") ); - plot.AddDataset( Histogramm(LogNormalVariable(0.0, 0.125), probes, precision, - "LogNormalVariable m=0.0 s=0.125") ); + plot.AddDataset ( Histogramm (LogNormalVariable (0.0, 0.125), probes, precision, + "LogNormalVariable m=0.0 s=0.125") ); - plot.AddDataset( Histogramm(LogNormalVariable(0.0, 2.0), probes, precision, - "LogNormalVariable m=0.0 s=2.0") ); + plot.AddDataset ( Histogramm (LogNormalVariable (0.0, 2.0), probes, precision, + "LogNormalVariable m=0.0 s=2.0") ); - plot.AddDataset( Gnuplot2dFunction("LogNormalDist(x, 0.0, 2.0)", - "LogNormalDist(x, 0.0, 2.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("LogNormalDist(x, 0.0, 2.0)", + "LogNormalDist(x, 0.0, 2.0)") ); - plot.AddDataset( Histogramm(LogNormalVariable(0.0, 2.5), probes, precision, - "LogNormalVariable m=0.0 s=2.5") ); + plot.AddDataset ( Histogramm (LogNormalVariable (0.0, 2.5), probes, precision, + "LogNormalVariable m=0.0 s=2.5") ); - gnuplots.AddPlot(plot); + gnuplots.AddPlot (plot); } { Gnuplot plot; - plot.SetTitle("TriangularVariable"); - plot.AppendExtra("set xrange [*:*]"); + plot.SetTitle ("TriangularVariable"); + plot.AppendExtra ("set xrange [*:*]"); - plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.5), probes, precision, - "TriangularVariable [0.0 .. 1.0) m=0.5") ); + plot.AddDataset ( Histogramm (TriangularVariable (0.0, 1.0, 0.5), probes, precision, + "TriangularVariable [0.0 .. 1.0) m=0.5") ); - plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.4), probes, precision, - "TriangularVariable [0.0 .. 1.0) m=0.4") ); + plot.AddDataset ( Histogramm (TriangularVariable (0.0, 1.0, 0.4), probes, precision, + "TriangularVariable [0.0 .. 1.0) m=0.4") ); - plot.AddDataset( Histogramm(TriangularVariable(0.0, 1.0, 0.65), probes, precision, - "TriangularVariable [0.0 .. 1.0) m=0.65") ); + plot.AddDataset ( Histogramm (TriangularVariable (0.0, 1.0, 0.65), probes, precision, + "TriangularVariable [0.0 .. 1.0) m=0.65") ); - gnuplots.AddPlot(plot); + gnuplots.AddPlot (plot); } { Gnuplot plot; - plot.SetTitle("GammaVariable"); - plot.AppendExtra("set xrange [0:10]"); - plot.AppendExtra("set yrange [0:1]"); - plot.AppendExtra("GammaDist(x,a,b) = x**(a-1) * 1/b**a * exp(-x/b) / gamma(a)"); + plot.SetTitle ("GammaVariable"); + plot.AppendExtra ("set xrange [0:10]"); + plot.AppendExtra ("set yrange [0:1]"); + plot.AppendExtra ("GammaDist(x,a,b) = x**(a-1) * 1/b**a * exp(-x/b) / gamma(a)"); - plot.AppendExtra("set label 1 '{/Symbol g}(x,{/Symbol a},{/Symbol b}) = x^{/Symbol a-1} e^{-x {/Symbol b}^{-1}} ( {/Symbol b}^{/Symbol a} {/Symbol G}({/Symbol a}) )^{-1}' at 0.7, 0.9"); + plot.AppendExtra ("set label 1 '{/Symbol g}(x,{/Symbol a},{/Symbol b}) = x^{/Symbol a-1} e^{-x {/Symbol b}^{-1}} ( {/Symbol b}^{/Symbol a} {/Symbol G}({/Symbol a}) )^{-1}' at 0.7, 0.9"); - plot.AddDataset( Histogramm(GammaVariable(1.0, 1.0), probes, precision, - "GammaVariable a=1.0 b=1.0") ); + plot.AddDataset ( Histogramm (GammaVariable (1.0, 1.0), probes, precision, + "GammaVariable a=1.0 b=1.0") ); - plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 1.0, 1.0)", - "GammaDist(x, 1.0, 1.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 1.0, 1.0)", + "GammaDist(x, 1.0, 1.0)") ); - plot.AddDataset( Histogramm(GammaVariable(1.5, 1.0), probes, precision, - "GammaVariable a=1.5 b=1.0") ); + plot.AddDataset ( Histogramm (GammaVariable (1.5, 1.0), probes, precision, + "GammaVariable a=1.5 b=1.0") ); - plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 1.5, 1.0)", - "GammaDist(x, 1.5, 1.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 1.5, 1.0)", + "GammaDist(x, 1.5, 1.0)") ); - plot.AddDataset( Histogramm(GammaVariable(2.0, 1.0), probes, precision, - "GammaVariable a=2.0 b=1.0") ); + plot.AddDataset ( Histogramm (GammaVariable (2.0, 1.0), probes, precision, + "GammaVariable a=2.0 b=1.0") ); - plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.0, 1.0)", - "GammaDist(x, 2.0, 1.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.0, 1.0)", + "GammaDist(x, 2.0, 1.0)") ); - plot.AddDataset( Histogramm(GammaVariable(4.0, 1.0), probes, precision, - "GammaVariable a=4.0 b=1.0") ); + plot.AddDataset ( Histogramm (GammaVariable (4.0, 1.0), probes, precision, + "GammaVariable a=4.0 b=1.0") ); - plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 4.0, 1.0)", - "GammaDist(x, 4.0, 1.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 4.0, 1.0)", + "GammaDist(x, 4.0, 1.0)") ); - plot.AddDataset( Histogramm(GammaVariable(2.0, 2.0), probes, precision, - "GammaVariable a=2.0 b=2.0") ); + plot.AddDataset ( Histogramm (GammaVariable (2.0, 2.0), probes, precision, + "GammaVariable a=2.0 b=2.0") ); - plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.0, 2.0)", - "GammaDist(x, 2.0, 2.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.0, 2.0)", + "GammaDist(x, 2.0, 2.0)") ); - plot.AddDataset( Histogramm(GammaVariable(2.5, 3.0), probes, precision, - "GammaVariable a=2.5 b=3.0") ); + plot.AddDataset ( Histogramm (GammaVariable (2.5, 3.0), probes, precision, + "GammaVariable a=2.5 b=3.0") ); - plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.5, 3.0)", - "GammaDist(x, 2.5, 3.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.5, 3.0)", + "GammaDist(x, 2.5, 3.0)") ); - plot.AddDataset( Histogramm(GammaVariable(2.5, 4.5), probes, precision, - "GammaVariable a=2.5 b=4.5") ); + plot.AddDataset ( Histogramm (GammaVariable (2.5, 4.5), probes, precision, + "GammaVariable a=2.5 b=4.5") ); - plot.AddDataset( Gnuplot2dFunction("{/Symbol g}(x, 2.5, 4.5)", - "GammaDist(x, 2.5, 4.5)") ); + plot.AddDataset ( Gnuplot2dFunction ("{/Symbol g}(x, 2.5, 4.5)", + "GammaDist(x, 2.5, 4.5)") ); - gnuplots.AddPlot(plot); + gnuplots.AddPlot (plot); } { Gnuplot plot; - plot.SetTitle("ErlangVariable"); - plot.AppendExtra("set xrange [0:10]"); - plot.AppendExtra("ErlangDist(x,k,l) = x**(k-1) * 1/l**k * exp(-x/l) / (k-1)!"); + plot.SetTitle ("ErlangVariable"); + plot.AppendExtra ("set xrange [0:10]"); + plot.AppendExtra ("ErlangDist(x,k,l) = x**(k-1) * 1/l**k * exp(-x/l) / (k-1)!"); - plot.AppendExtra("set label 1 'Erlang(x,k,{/Symbol l}) = x^{k-1} e^{-x {/Symbol l}^{-1}} ( {/Symbol l}^k (k-1)! )^{-1}' at 0.7, 0.9"); + plot.AppendExtra ("set label 1 'Erlang(x,k,{/Symbol l}) = x^{k-1} e^{-x {/Symbol l}^{-1}} ( {/Symbol l}^k (k-1)! )^{-1}' at 0.7, 0.9"); - plot.AddDataset( Histogramm(ErlangVariable(1, 1.0), probes, precision, - "ErlangVariable k=1 {/Symbol l}=1.0") ); + plot.AddDataset ( Histogramm (ErlangVariable (1, 1.0), probes, precision, + "ErlangVariable k=1 {/Symbol l}=1.0") ); - plot.AddDataset( Gnuplot2dFunction("Erlang(x, 1, 1.0)", - "ErlangDist(x, 1, 1.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 1, 1.0)", + "ErlangDist(x, 1, 1.0)") ); - plot.AddDataset( Histogramm(ErlangVariable(2, 1.0), probes, precision, - "ErlangVariable k=2 {/Symbol l}=1.0") ); + plot.AddDataset ( Histogramm (ErlangVariable (2, 1.0), probes, precision, + "ErlangVariable k=2 {/Symbol l}=1.0") ); - plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 1.0)", - "ErlangDist(x, 2, 1.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 1.0)", + "ErlangDist(x, 2, 1.0)") ); - plot.AddDataset( Histogramm(ErlangVariable(3, 1.0), probes, precision, - "ErlangVariable k=3 {/Symbol l}=1.0") ); + plot.AddDataset ( Histogramm (ErlangVariable (3, 1.0), probes, precision, + "ErlangVariable k=3 {/Symbol l}=1.0") ); - plot.AddDataset( Gnuplot2dFunction("Erlang(x, 3, 1.0)", - "ErlangDist(x, 3, 1.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 3, 1.0)", + "ErlangDist(x, 3, 1.0)") ); - plot.AddDataset( Histogramm(ErlangVariable(5, 1.0), probes, precision, - "ErlangVariable k=5 {/Symbol l}=1.0") ); + plot.AddDataset ( Histogramm (ErlangVariable (5, 1.0), probes, precision, + "ErlangVariable k=5 {/Symbol l}=1.0") ); - plot.AddDataset( Gnuplot2dFunction("Erlang(x, 5, 1.0)", - "ErlangDist(x, 5, 1.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 5, 1.0)", + "ErlangDist(x, 5, 1.0)") ); - plot.AddDataset( Histogramm(ErlangVariable(2, 2.0), probes, precision, - "ErlangVariable k=2 {/Symbol l}=2.0") ); + plot.AddDataset ( Histogramm (ErlangVariable (2, 2.0), probes, precision, + "ErlangVariable k=2 {/Symbol l}=2.0") ); - plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 2.0)", - "ErlangDist(x, 2, 2.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 2.0)", + "ErlangDist(x, 2, 2.0)") ); - plot.AddDataset( Histogramm(ErlangVariable(2, 3.0), probes, precision, - "ErlangVariable k=2 {/Symbol l}=3.0") ); + plot.AddDataset ( Histogramm (ErlangVariable (2, 3.0), probes, precision, + "ErlangVariable k=2 {/Symbol l}=3.0") ); - plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 3.0)", - "ErlangDist(x, 2, 3.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 3.0)", + "ErlangDist(x, 2, 3.0)") ); - plot.AddDataset( Histogramm(ErlangVariable(2, 5.0), probes, precision, - "ErlangVariable k=2 {/Symbol l}=5.0") ); + plot.AddDataset ( Histogramm (ErlangVariable (2, 5.0), probes, precision, + "ErlangVariable k=2 {/Symbol l}=5.0") ); - plot.AddDataset( Gnuplot2dFunction("Erlang(x, 2, 5.0)", - "ErlangDist(x, 2, 5.0)") ); + plot.AddDataset ( Gnuplot2dFunction ("Erlang(x, 2, 5.0)", + "ErlangDist(x, 2, 5.0)") ); - gnuplots.AddPlot(plot); + gnuplots.AddPlot (plot); } - gnuplots.GenerateOutput(std::cout); + gnuplots.GenerateOutput (std::cout); return 0; } diff --git a/src/core/examples/main-test-sync.cc b/src/core/examples/main-test-sync.cc index dac2c8418..e7b2aec6a 100644 --- a/src/core/examples/main-test-sync.cc +++ b/src/core/examples/main-test-sync.cc @@ -97,7 +97,7 @@ test (void) // // Make sure ScheduleNow works when the system isn't running // - DynamicCast (Simulator::GetImplementation ())->ScheduleRealtimeNow(MakeEvent (&first_function)); + DynamicCast (Simulator::GetImplementation ())->ScheduleRealtimeNow (MakeEvent (&first_function)); // // drive the progression of m_currentTs at a ten millisecond rate from the main thread diff --git a/src/core/model/abort.h b/src/core/model/abort.h index 7061ef971..6796aa17a 100644 --- a/src/core/model/abort.h +++ b/src/core/model/abort.h @@ -115,7 +115,7 @@ * \see NS_ABORT_IF */ #define NS_ABORT_UNLESS(cond) \ - NS_ABORT_IF(!(cond)) + NS_ABORT_IF (!(cond)) /** * \ingroup debugging @@ -129,6 +129,6 @@ * \see NS_ABORT_MSG_IF */ #define NS_ABORT_MSG_UNLESS(cond, msg) \ - NS_ABORT_MSG_IF(!(cond),msg) + NS_ABORT_MSG_IF (!(cond),msg) #endif /* NS3_ABORT_H */ diff --git a/src/core/model/assert.h b/src/core/model/assert.h index 12f7ec0f5..34e38c27c 100644 --- a/src/core/model/assert.h +++ b/src/core/model/assert.h @@ -68,7 +68,7 @@ { \ std::cerr << "assert failed. cond=\"" << \ # condition << "\", "; \ - NS_FATAL_ERROR_NO_MSG(); \ + NS_FATAL_ERROR_NO_MSG (); \ } \ } \ while (false) diff --git a/src/core/model/attribute-helper.h b/src/core/model/attribute-helper.h index 1309f43b6..a5b353275 100644 --- a/src/core/model/attribute-helper.h +++ b/src/core/model/attribute-helper.h @@ -180,13 +180,13 @@ private: \ return ns3::Create (*this); \ } \ std::string \ - name ## Value::SerializeToString (Ptr checker) const { \ + name ## Value::SerializeToString (Ptr checker) const { \ std::ostringstream oss; \ oss << m_value; \ return oss.str (); \ } \ bool \ - name ## Value::DeserializeFromString (std::string value, Ptr checker) { \ + name ## Value::DeserializeFromString (std::string value, Ptr checker) { \ std::istringstream iss; \ iss.str (value); \ iss >> m_value; \ @@ -203,7 +203,7 @@ private: \ * Typically invoked from xxx.cc. */ #define ATTRIBUTE_VALUE_IMPLEMENT(type) \ - ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(type,type) + ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (type,type) /** diff --git a/src/core/model/breakpoint.h b/src/core/model/breakpoint.h index 8354a9040..c3f3e656f 100644 --- a/src/core/model/breakpoint.h +++ b/src/core/model/breakpoint.h @@ -45,13 +45,13 @@ namespace ns3 { */ #if (defined (__i386__) || defined (__amd64__) || defined (__x86_64__)) && defined (__GNUC__) && __GNUC__ >= 2 # define NS_BREAKPOINT() \ - do { __asm__ __volatile__ ("int $03"); }while(false) + do { __asm__ __volatile__ ("int $03"); } while(false) #elif defined (_MSC_VER) && defined (_M_IX86) # define NS_BREAKPOINT() \ - do { __asm int 3h }while(false) + do { __asm int 3h } while(false) #elif defined (__alpha__) && !defined(__osf__) && defined (__GNUC__) && __GNUC__ >= 2 # define NS_BREAKPOINT() \ - do { __asm__ __volatile__ ("bpt"); }while(false) + do { __asm__ __volatile__ ("bpt"); } while(false) #else /* !__i386__ && !__alpha__ */ # define NS_BREAKPOINT() ns3::BreakpointFallback () #endif diff --git a/src/core/model/cairo-wideint-private.h b/src/core/model/cairo-wideint-private.h index ccb8e85de..27252c1fa 100644 --- a/src/core/model/cairo-wideint-private.h +++ b/src/core/model/cairo-wideint-private.h @@ -112,8 +112,8 @@ cairo_uint64_t I _cairo_uint64_not (cairo_uint64_t a); #define _cairo_uint64_to_int64(i) (i) #define _cairo_int64_to_uint64(i) (i) -cairo_int64_t I _cairo_int32_to_int64(int32_t i); -#define _cairo_int64_to_int32(a) ((int32_t) _cairo_uint64_to_uint32(a)) +cairo_int64_t I _cairo_int32_to_int64 (int32_t i); +#define _cairo_int64_to_int32(a) ((int32_t) _cairo_uint64_to_uint32 (a)) #define _cairo_int64_add(a,b) _cairo_uint64_add (a,b) #define _cairo_int64_sub(a,b) _cairo_uint64_sub (a,b) #define _cairo_int64_mul(a,b) _cairo_uint64_mul (a,b) @@ -123,9 +123,9 @@ int I _cairo_int64_lt (cairo_uint64_t a, cairo_uint64_t b); #define _cairo_int64_lsl(a,b) _cairo_uint64_lsl (a,b) #define _cairo_int64_rsl(a,b) _cairo_uint64_rsl (a,b) #define _cairo_int64_rsa(a,b) _cairo_uint64_rsa (a,b) -#define _cairo_int64_negate(a) _cairo_uint64_negate(a) +#define _cairo_int64_negate(a) _cairo_uint64_negate (a) #define _cairo_int64_negative(a) (((int32_t)((a).hi)) < 0) -#define _cairo_int64_not(a) _cairo_uint64_not(a) +#define _cairo_int64_not(a) _cairo_uint64_not (a) #else @@ -170,15 +170,15 @@ typedef int64_t cairo_int64_t; /* * 64-bit comparisions derived from lt or eq */ -#define _cairo_uint64_le(a,b) (!_cairo_uint64_gt(a,b)) -#define _cairo_uint64_ne(a,b) (!_cairo_uint64_eq(a,b)) -#define _cairo_uint64_ge(a,b) (!_cairo_uint64_lt(a,b)) -#define _cairo_uint64_gt(a,b) _cairo_uint64_lt(b,a) +#define _cairo_uint64_le(a,b) (!_cairo_uint64_gt (a,b)) +#define _cairo_uint64_ne(a,b) (!_cairo_uint64_eq (a,b)) +#define _cairo_uint64_ge(a,b) (!_cairo_uint64_lt (a,b)) +#define _cairo_uint64_gt(a,b) _cairo_uint64_lt (b,a) -#define _cairo_int64_le(a,b) (!_cairo_int64_gt(a,b)) -#define _cairo_int64_ne(a,b) (!_cairo_int64_eq(a,b)) -#define _cairo_int64_ge(a,b) (!_cairo_int64_lt(a,b)) -#define _cairo_int64_gt(a,b) _cairo_int64_lt(b,a) +#define _cairo_int64_le(a,b) (!_cairo_int64_gt (a,b)) +#define _cairo_int64_ne(a,b) (!_cairo_int64_eq (a,b)) +#define _cairo_int64_ge(a,b) (!_cairo_int64_lt (a,b)) +#define _cairo_int64_gt(a,b) _cairo_int64_lt (b,a) /* * As the C implementation always computes both, create @@ -216,7 +216,7 @@ typedef struct cairo_uint128 { cairo_uint128_t I _cairo_uint32_to_uint128 (uint32_t i); cairo_uint128_t I _cairo_uint64_to_uint128 (cairo_uint64_t i); #define _cairo_uint128_to_uint64(a) ((a).lo) -#define _cairo_uint128_to_uint32(a) _cairo_uint64_to_uint32(_cairo_uint128_to_uint64(a)) +#define _cairo_uint128_to_uint32(a) _cairo_uint64_to_uint32 (_cairo_uint128_to_uint64 (a)) cairo_uint128_t I _cairo_uint128_add (cairo_uint128_t a, cairo_uint128_t b); cairo_uint128_t I _cairo_uint128_sub (cairo_uint128_t a, cairo_uint128_t b); cairo_uint128_t I _cairo_uint128_mul (cairo_uint128_t a, cairo_uint128_t b); @@ -227,7 +227,7 @@ cairo_uint128_t I _cairo_uint128_rsa (cairo_uint128_t a, int shift); int I _cairo_uint128_lt (cairo_uint128_t a, cairo_uint128_t b); int I _cairo_uint128_eq (cairo_uint128_t a, cairo_uint128_t b); cairo_uint128_t I _cairo_uint128_negate (cairo_uint128_t a); -#define _cairo_uint128_negative(a) (_cairo_uint64_negative(a.hi)) +#define _cairo_uint128_negative(a) (_cairo_uint64_negative (a.hi)) cairo_uint128_t I _cairo_uint128_not (cairo_uint128_t a); #define _cairo_uint128_to_int128(i) (i) @@ -236,19 +236,19 @@ cairo_uint128_t I _cairo_uint128_not (cairo_uint128_t a); cairo_int128_t I _cairo_int32_to_int128 (int32_t i); cairo_int128_t I _cairo_int64_to_int128 (cairo_int64_t i); #define _cairo_int128_to_int64(a) ((cairo_int64_t)(a).lo) -#define _cairo_int128_to_int32(a) _cairo_int64_to_int32(_cairo_int128_to_int64(a)) -#define _cairo_int128_add(a,b) _cairo_uint128_add(a,b) -#define _cairo_int128_sub(a,b) _cairo_uint128_sub(a,b) -#define _cairo_int128_mul(a,b) _cairo_uint128_mul(a,b) +#define _cairo_int128_to_int32(a) _cairo_int64_to_int32 (_cairo_int128_to_int64 (a)) +#define _cairo_int128_add(a,b) _cairo_uint128_add (a,b) +#define _cairo_int128_sub(a,b) _cairo_uint128_sub (a,b) +#define _cairo_int128_mul(a,b) _cairo_uint128_mul (a,b) cairo_int128_t I _cairo_int64x64_128_mul (cairo_int64_t a, cairo_int64_t b); -#define _cairo_int128_lsl(a,b) _cairo_uint128_lsl(a,b) -#define _cairo_int128_rsl(a,b) _cairo_uint128_rsl(a,b) -#define _cairo_int128_rsa(a,b) _cairo_uint128_rsa(a,b) +#define _cairo_int128_lsl(a,b) _cairo_uint128_lsl (a,b) +#define _cairo_int128_rsl(a,b) _cairo_uint128_rsl (a,b) +#define _cairo_int128_rsa(a,b) _cairo_uint128_rsa (a,b) int I _cairo_int128_lt (cairo_int128_t a, cairo_int128_t b); #define _cairo_int128_eq(a,b) _cairo_uint128_eq (a,b) -#define _cairo_int128_negate(a) _cairo_uint128_negate(a) -#define _cairo_int128_negative(a) (_cairo_uint128_negative(a)) -#define _cairo_int128_not(a) _cairo_uint128_not(a) +#define _cairo_int128_negate(a) _cairo_uint128_negate (a) +#define _cairo_int128_negative(a) (_cairo_uint128_negative (a)) +#define _cairo_int128_not(a) _cairo_uint128_not (a) #else /* !HAVE_UINT128_T */ @@ -318,15 +318,15 @@ cairo_quorem64_t I _cairo_int_96by64_32x64_divrem (cairo_int128_t num, cairo_int64_t den); -#define _cairo_uint128_le(a,b) (!_cairo_uint128_gt(a,b)) -#define _cairo_uint128_ne(a,b) (!_cairo_uint128_eq(a,b)) -#define _cairo_uint128_ge(a,b) (!_cairo_uint128_lt(a,b)) -#define _cairo_uint128_gt(a,b) _cairo_uint128_lt(b,a) +#define _cairo_uint128_le(a,b) (!_cairo_uint128_gt (a,b)) +#define _cairo_uint128_ne(a,b) (!_cairo_uint128_eq (a,b)) +#define _cairo_uint128_ge(a,b) (!_cairo_uint128_lt (a,b)) +#define _cairo_uint128_gt(a,b) _cairo_uint128_lt (b,a) -#define _cairo_int128_le(a,b) (!_cairo_int128_gt(a,b)) -#define _cairo_int128_ne(a,b) (!_cairo_int128_eq(a,b)) -#define _cairo_int128_ge(a,b) (!_cairo_int128_lt(a,b)) -#define _cairo_int128_gt(a,b) _cairo_int128_lt(b,a) +#define _cairo_int128_le(a,b) (!_cairo_int128_gt (a,b)) +#define _cairo_int128_ne(a,b) (!_cairo_int128_eq (a,b)) +#define _cairo_int128_ge(a,b) (!_cairo_int128_lt (a,b)) +#define _cairo_int128_gt(a,b) _cairo_int128_lt (b,a) #undef I diff --git a/src/core/model/callback.cc b/src/core/model/callback.cc index 30ed261c3..0998ef076 100644 --- a/src/core/model/callback.cc +++ b/src/core/model/callback.cc @@ -49,36 +49,36 @@ ATTRIBUTE_CHECKER_IMPLEMENT (Callback); namespace ns3 { std::string -CallbackBase::Demangle(const std::string& mangled) +CallbackBase::Demangle (const std::string& mangled) { int status; - char* demangled = abi::__cxa_demangle(mangled.c_str(), - NULL, NULL, &status); + char* demangled = abi::__cxa_demangle (mangled.c_str (), + NULL, NULL, &status); std::string ret; if (status == 0) { - NS_ASSERT(demangled); + NS_ASSERT (demangled); ret = demangled; } else if (status == -1) { - NS_LOG_UNCOND("Callback demangling failed: Memory allocation failure occured."); + NS_LOG_UNCOND ("Callback demangling failed: Memory allocation failure occured."); ret = mangled; } else if (status == -2) { - NS_LOG_UNCOND("Callback demangling failed: Mangled name is not a valid under the C++ ABI mangling rules."); + NS_LOG_UNCOND ("Callback demangling failed: Mangled name is not a valid under the C++ ABI mangling rules."); ret = mangled; } else if (status == -3) { - NS_LOG_UNCOND("Callback demangling failed: One of the arguments is invalid."); + NS_LOG_UNCOND ("Callback demangling failed: One of the arguments is invalid."); ret = mangled; } else { - NS_LOG_UNCOND("Callback demangling failed: status " << status); + NS_LOG_UNCOND ("Callback demangling failed: status " << status); ret = mangled; } if (demangled) { - free(demangled); + free (demangled); } return ret; } @@ -88,7 +88,7 @@ CallbackBase::Demangle(const std::string& mangled) #else std::string -ns3::CallbackBase::Demangle(const std::string& mangled) +ns3::CallbackBase::Demangle (const std::string& mangled) { return mangled; } diff --git a/src/core/model/callback.h b/src/core/model/callback.h index 1c339374b..67546e3fd 100644 --- a/src/core/model/callback.h +++ b/src/core/model/callback.h @@ -194,7 +194,7 @@ public: } virtual bool IsEqual (Ptr other) const { FunctorCallbackImpl const *otherDerived = - dynamic_cast const *> (PeekPointer(other)); + dynamic_cast const *> (PeekPointer (other)); if (otherDerived == 0) { return false; @@ -323,12 +323,12 @@ private: class CallbackBase { public: CallbackBase () : m_impl () {} - Ptr GetImpl (void) const { return m_impl;} + Ptr GetImpl (void) const { return m_impl; } protected: CallbackBase (Ptr impl) : m_impl (impl) {} Ptr m_impl; - static std::string Demangle(const std::string& mangled); + static std::string Demangle (const std::string& mangled); }; /** @@ -894,7 +894,7 @@ Callback MakeNullCallback (void) { template Callback MakeBoundCallback (R (*fnPtr)(TX), ARG a) { Ptr > impl = - Create >(fnPtr, a); + Create >(fnPtr, a); return Callback (impl); } @@ -902,56 +902,56 @@ template Callback MakeBoundCallback (R (*fnPtr)(TX,T1), ARG a) { Ptr > impl = - Create > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } template Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2), ARG a) { Ptr > impl = - Create > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } template Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3), ARG a) { Ptr > impl = - Create > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } template Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4), ARG a) { Ptr > impl = - Create > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } template Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5), ARG a) { Ptr > impl = - Create > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } template Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6), ARG a) { Ptr > impl = - Create > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } template Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6,T7), ARG a) { Ptr > impl = - Create > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } template Callback MakeBoundCallback (R (*fnPtr)(TX,T1,T2,T3,T4,T5,T6,T7,T8), ARG a) { Ptr > impl = - Create > (fnPtr, a); + Create > (fnPtr, a); return Callback (impl); } } // namespace ns3 @@ -974,7 +974,7 @@ private: CallbackBase m_value; }; -ATTRIBUTE_ACCESSOR_DEFINE(Callback); +ATTRIBUTE_ACCESSOR_DEFINE (Callback); ATTRIBUTE_CHECKER_DEFINE (Callback); } // namespace ns3 diff --git a/src/core/model/default-simulator-impl.cc b/src/core/model/default-simulator-impl.cc index 3f0db0066..b3793da42 100644 --- a/src/core/model/default-simulator-impl.cc +++ b/src/core/model/default-simulator-impl.cc @@ -161,7 +161,7 @@ DefaultSimulatorImpl::Run (void) // If the simulator stopped naturally by lack of events, make a // consistency test to check that we didn't lose any events along the way. - NS_ASSERT(!m_events->IsEmpty () || m_unscheduledEvents == 0); + NS_ASSERT (!m_events->IsEmpty () || m_unscheduledEvents == 0); } void diff --git a/src/core/model/fatal-error.h b/src/core/model/fatal-error.h index 296e12b34..1f3fb6b84 100644 --- a/src/core/model/fatal-error.h +++ b/src/core/model/fatal-error.h @@ -73,7 +73,7 @@ do \ { \ std::cerr << "msg=\"" << msg << "\", "; \ - NS_FATAL_ERROR_NO_MSG(); \ + NS_FATAL_ERROR_NO_MSG (); \ } \ while (false) diff --git a/src/core/model/fatal-impl.cc b/src/core/model/fatal-impl.cc index 40ea58f01..1099e3e09 100644 --- a/src/core/model/fatal-impl.cc +++ b/src/core/model/fatal-impl.cc @@ -96,7 +96,7 @@ UnregisterStream (std::ostream* stream) namespace { /* Overrides normal SIGSEGV handler once the * HandleTerminate function is run. */ -void sigHandler(int sig) +void sigHandler (int sig) { FlushStreams (); std::abort (); diff --git a/src/core/model/int64x64-128.cc b/src/core/model/int64x64-128.cc index 75f33fca8..ea6b948c9 100644 --- a/src/core/model/int64x64-128.cc +++ b/src/core/model/int64x64-128.cc @@ -10,7 +10,7 @@ namespace ns3 { negB = sb < 0; \ ua = negA ? -sa : sa; \ ub = negB ? -sb : sb; \ - (negA && !negB) || (!negA && negB);}) + (negA && !negB) || (!negA && negB); }) #define MASK_LO ((((int128_t)1)<<64)-1) diff --git a/src/core/model/int64x64-cairo.cc b/src/core/model/int64x64-cairo.cc index e45365d99..4c05da45b 100644 --- a/src/core/model/int64x64-cairo.cc +++ b/src/core/model/int64x64-cairo.cc @@ -34,7 +34,7 @@ namespace ns3 { ub = _cairo_int128_to_uint128 (sb); \ ua = negA ? _cairo_uint128_negate (ua) : ua; \ ub = negB ? _cairo_uint128_negate (ub) : ub; \ - (negA && !negB) || (!negA && negB);}) + (negA && !negB) || (!negA && negB); }) void int64x64_t::Mul (int64x64_t const &o) @@ -114,10 +114,10 @@ void int64x64_t::MulByInvert (const int64x64_t &o) { bool negResult = _cairo_int128_negative (_v); - cairo_uint128_t a = negResult ? _cairo_int128_negate(_v) : _v; + cairo_uint128_t a = negResult ? _cairo_int128_negate (_v) : _v; cairo_uint128_t result = UmulByInvert (a, o._v); - _v = negResult ? _cairo_int128_negate(result) : result; + _v = negResult ? _cairo_int128_negate (result) : result; } cairo_uint128_t int64x64_t::UmulByInvert (cairo_uint128_t a, cairo_uint128_t b) diff --git a/src/core/model/int64x64-cairo.h b/src/core/model/int64x64-cairo.h index 4af474b2b..769a6fbca 100644 --- a/src/core/model/int64x64-cairo.h +++ b/src/core/model/int64x64-cairo.h @@ -25,7 +25,7 @@ public: { #define HPCAIRO_MAX_64 18446744073709551615.0 double fhi = floor (value); - int64_t hi = lround(fhi); + int64_t hi = lround (fhi); uint64_t lo = (uint64_t)((value - fhi) * HPCAIRO_MAX_64); _v.hi = hi; _v.lo = lo; diff --git a/src/core/model/int64x64.cc b/src/core/model/int64x64.cc index b90becbc1..99840e37b 100644 --- a/src/core/model/int64x64.cc +++ b/src/core/model/int64x64.cc @@ -92,11 +92,11 @@ std::istream &operator >> (std::istream &is, int64x64_t &value) cur = next; int64_t hi; uint64_t lo; - next = str.find(".", cur); + next = str.find (".", cur); if (next != std::string::npos) { hi = ReadDigits (str.substr (cur, next-cur)); - lo = ReadDigits (str.substr (next+1, str.size()-(next+1))); + lo = ReadDigits (str.substr (next+1, str.size ()-(next+1))); } else { diff --git a/src/core/model/int64x64.h b/src/core/model/int64x64.h index aecdfdcca..270cae9d8 100644 --- a/src/core/model/int64x64.h +++ b/src/core/model/int64x64.h @@ -19,13 +19,13 @@ namespace ns3 { inline int64x64_t operator op (const int64x64_t &lhs, const type rhs) \ { \ int64x64_t tmp = lhs; \ - tmp op ##= int64x64_t (rhs); \ + tmp op ## = int64x64_t (rhs); \ return tmp; \ } \ inline int64x64_t operator op (const type lhs, const int64x64_t &rhs) \ { \ int64x64_t tmp = int64x64_t (lhs); \ - tmp op ##= rhs; \ + tmp op ## = rhs; \ return tmp; \ } @@ -33,20 +33,20 @@ namespace ns3 { inline int64x64_t operator op (const int64x64_t &lhs, const int64x64_t &rhs) \ { \ int64x64_t tmp = lhs; \ - tmp op ##= rhs; \ + tmp op ## = rhs; \ return tmp; \ } \ - INT64X64_OP_ARITH_TYPE(op,double) \ - INT64X64_OP_ARITH_TYPE(op,signed char) \ - INT64X64_OP_ARITH_TYPE(op,signed short) \ - INT64X64_OP_ARITH_TYPE(op,signed int) \ - INT64X64_OP_ARITH_TYPE(op,signed long int) \ - INT64X64_OP_ARITH_TYPE(op,signed long long int) \ - INT64X64_OP_ARITH_TYPE(op,unsigned char) \ - INT64X64_OP_ARITH_TYPE(op,unsigned short) \ - INT64X64_OP_ARITH_TYPE(op,unsigned int) \ - INT64X64_OP_ARITH_TYPE(op,unsigned long int) \ - INT64X64_OP_ARITH_TYPE(op,unsigned long long int) + INT64X64_OP_ARITH_TYPE (op,double) \ + INT64X64_OP_ARITH_TYPE (op,signed char) \ + INT64X64_OP_ARITH_TYPE (op,signed short) \ + INT64X64_OP_ARITH_TYPE (op,signed int) \ + INT64X64_OP_ARITH_TYPE (op,signed long int) \ + INT64X64_OP_ARITH_TYPE (op,signed long long int) \ + INT64X64_OP_ARITH_TYPE (op,unsigned char) \ + INT64X64_OP_ARITH_TYPE (op,unsigned short) \ + INT64X64_OP_ARITH_TYPE (op,unsigned int) \ + INT64X64_OP_ARITH_TYPE (op,unsigned long int) \ + INT64X64_OP_ARITH_TYPE (op,unsigned long long int) #define INT64X64_OP_CMP_TYPE(op,type) \ inline bool operator op (const int64x64_t &lhs, const type &rhs) \ @@ -59,25 +59,25 @@ namespace ns3 { } #define INT64X64_OP_CMP(op) \ - INT64X64_OP_CMP_TYPE(op,double) \ - INT64X64_OP_CMP_TYPE(op,signed int) \ - INT64X64_OP_CMP_TYPE(op,signed long int) \ - INT64X64_OP_CMP_TYPE(op,signed long long int) \ - INT64X64_OP_CMP_TYPE(op,unsigned int) \ - INT64X64_OP_CMP_TYPE(op,unsigned long int) \ - INT64X64_OP_CMP_TYPE(op,unsigned long long int) + INT64X64_OP_CMP_TYPE (op,double) \ + INT64X64_OP_CMP_TYPE (op,signed int) \ + INT64X64_OP_CMP_TYPE (op,signed long int) \ + INT64X64_OP_CMP_TYPE (op,signed long long int) \ + INT64X64_OP_CMP_TYPE (op,unsigned int) \ + INT64X64_OP_CMP_TYPE (op,unsigned long int) \ + INT64X64_OP_CMP_TYPE (op,unsigned long long int) -INT64X64_OP_ARITH(+) -INT64X64_OP_ARITH(-) -INT64X64_OP_ARITH(*) -INT64X64_OP_ARITH(/) -INT64X64_OP_CMP(==) -INT64X64_OP_CMP(!=) -INT64X64_OP_CMP(<) -INT64X64_OP_CMP(<=) -INT64X64_OP_CMP(>) -INT64X64_OP_CMP(>=) +INT64X64_OP_ARITH (+) +INT64X64_OP_ARITH (-) +INT64X64_OP_ARITH (*) +INT64X64_OP_ARITH (/) +INT64X64_OP_CMP (==) +INT64X64_OP_CMP (!=) +INT64X64_OP_CMP (<) +INT64X64_OP_CMP (<=) +INT64X64_OP_CMP (>) +INT64X64_OP_CMP (>=) std::ostream &operator << (std::ostream &os, const int64x64_t &val); std::istream &operator >> (std::istream &is, int64x64_t &val); diff --git a/src/core/model/integer.h b/src/core/model/integer.h index 2bb8125a9..98ddb63ec 100644 --- a/src/core/model/integer.h +++ b/src/core/model/integer.h @@ -42,8 +42,8 @@ namespace ns3 { * int, etc. */ -ATTRIBUTE_VALUE_DEFINE_WITH_NAME(int64_t, Integer); -ATTRIBUTE_ACCESSOR_DEFINE(Integer); +ATTRIBUTE_VALUE_DEFINE_WITH_NAME (int64_t, Integer); +ATTRIBUTE_ACCESSOR_DEFINE (Integer); template Ptr MakeIntegerChecker (void); diff --git a/src/core/model/log.cc b/src/core/model/log.cc index 828318396..5dffa822a 100644 --- a/src/core/model/log.cc +++ b/src/core/model/log.cc @@ -56,7 +56,7 @@ ComponentList *GetComponentList (void) PrintList::PrintList () { #ifdef HAVE_GETENV - char *envVar = getenv("NS_LOG"); + char *envVar = getenv ("NS_LOG"); if (envVar == 0) { return; @@ -102,7 +102,7 @@ void LogComponent::EnvVarCheck (char const * name) { #ifdef HAVE_GETENV - char *envVar = getenv("NS_LOG"); + char *envVar = getenv ("NS_LOG"); if (envVar == 0) { return; @@ -358,7 +358,7 @@ void LogSetTimePrinter (LogTimePrinter printer) { g_logTimePrinter = printer; } -LogTimePrinter LogGetTimePrinter(void) +LogTimePrinter LogGetTimePrinter (void) { return g_logTimePrinter; } @@ -367,7 +367,7 @@ void LogSetNodePrinter (LogNodePrinter printer) { g_logNodePrinter = printer; } -LogNodePrinter LogGetNodePrinter(void) +LogNodePrinter LogGetNodePrinter (void) { return g_logNodePrinter; } diff --git a/src/core/model/log.h b/src/core/model/log.h index fa381a49c..944f76fec 100644 --- a/src/core/model/log.h +++ b/src/core/model/log.h @@ -219,7 +219,7 @@ void LogComponentDisableAll (enum LogLevel level); * Use \ref NS_LOG to output a message of level LOG_ERROR. */ #define NS_LOG_ERROR(msg) \ - NS_LOG(ns3::LOG_ERROR, msg) + NS_LOG (ns3::LOG_ERROR, msg) /** * \ingroup logging @@ -228,7 +228,7 @@ void LogComponentDisableAll (enum LogLevel level); * Use \ref NS_LOG to output a message of level LOG_WARN. */ #define NS_LOG_WARN(msg) \ - NS_LOG(ns3::LOG_WARN, msg) + NS_LOG (ns3::LOG_WARN, msg) /** * \ingroup logging @@ -237,7 +237,7 @@ void LogComponentDisableAll (enum LogLevel level); * Use \ref NS_LOG to output a message of level LOG_DEBUG. */ #define NS_LOG_DEBUG(msg) \ - NS_LOG(ns3::LOG_DEBUG, msg) + NS_LOG (ns3::LOG_DEBUG, msg) /** * \ingroup logging @@ -246,7 +246,7 @@ void LogComponentDisableAll (enum LogLevel level); * Use \ref NS_LOG to output a message of level LOG_INFO. */ #define NS_LOG_INFO(msg) \ - NS_LOG(ns3::LOG_INFO, msg) + NS_LOG (ns3::LOG_INFO, msg) /** * \ingroup logging @@ -294,7 +294,7 @@ void LogComponentDisableAll (enum LogLevel level); NS_LOG_APPEND_CONTEXT; \ std::clog << g_log.Name () << ":" \ << __FUNCTION__ << "("; \ - ns3::ParameterLogger (std::clog) << parameters; \ + ns3::ParameterLogger (std::clog) << parameters; \ std::clog << ")" << std::endl; \ } \ } \ @@ -308,7 +308,7 @@ void LogComponentDisableAll (enum LogLevel level); * Use \ref NS_LOG to output a message of level LOG_LOGIC */ #define NS_LOG_LOGIC(msg) \ - NS_LOG(ns3::LOG_LOGIC, msg) + NS_LOG (ns3::LOG_LOGIC, msg) /** * \ingroup logging @@ -353,10 +353,10 @@ typedef void (*LogTimePrinter)(std::ostream &os); typedef void (*LogNodePrinter)(std::ostream &os); void LogSetTimePrinter (LogTimePrinter); -LogTimePrinter LogGetTimePrinter(void); +LogTimePrinter LogGetTimePrinter (void); void LogSetNodePrinter (LogNodePrinter); -LogNodePrinter LogGetNodePrinter(void); +LogNodePrinter LogGetNodePrinter (void); class LogComponent { diff --git a/src/core/model/names.cc b/src/core/model/names.cc index ed901464c..8fc59627a 100644 --- a/src/core/model/names.cc +++ b/src/core/model/names.cc @@ -254,7 +254,7 @@ NamesPriv::Add (Ptr context, std::string name, Ptr object) return false; } - NameNode *newNode = new NameNode(node, name, object); + NameNode *newNode = new NameNode (node, name, object); node->m_nameMap[name] = newNode; m_objectMap[object] = newNode; @@ -498,7 +498,7 @@ NamesPriv::Find (std::string path) // specified name. We need to "recurse" when we find this segment. // offset = remaining.find ("/"); - std::string segment = remaining.substr(0, offset); + std::string segment = remaining.substr (0, offset); std::map::iterator i = node->m_nameMap.find (segment); if (i == node->m_nameMap.end ()) diff --git a/src/core/model/ns2-calendar-scheduler.cc b/src/core/model/ns2-calendar-scheduler.cc index d0f3a8ef5..92c7519fb 100644 --- a/src/core/model/ns2-calendar-scheduler.cc +++ b/src/core/model/ns2-calendar-scheduler.cc @@ -318,19 +318,19 @@ Ns2CalendarScheduler::head (void) do { \ head_search_++; \ if ((e = buckets_[i].list_) != NULL) { \ - diff = e->event.key.m_ts - cal_clock_.m_ts; \ - if (diff < diff ## x ## _) { \ - l = i; \ - goto found_l; \ - } \ - if (min_e == NULL || min_e->event.key > e->event.key) { \ - min_e = e; \ - l = i; \ - } \ - } \ - if (++i == nbuckets_) { i = 0; } \ - } \ - while (0) + diff = e->event.key.m_ts - cal_clock_.m_ts; \ + if (diff < diff ## x ## _) { \ + l = i; \ + goto found_l; \ + } \ + if (min_e == NULL || min_e->event.key > e->event.key) { \ + min_e = e; \ + l = i; \ + } \ + } \ + if (++i == nbuckets_) { i = 0; } \ + } \ + while (0) // CAL_DEQUEUE applied successively will find the event to // dequeue (within one year) and keep track of the @@ -341,22 +341,22 @@ Ns2CalendarScheduler::head (void) CAL_DEQUEUE (0); CAL_DEQUEUE (1); for (; i != lastbucket_dec; ) - { - CAL_DEQUEUE (2); - } + { + CAL_DEQUEUE (2); + } // one last bucket is left unchecked - take the minimum // [could have done CAL_DEQUEUE(3) with diff3_ = bwidth*(nbuck*3/2-1)] e = buckets_[i].list_; if (min_e != NULL && (e == NULL || min_e->event.key < e->event.key)) - { - e = min_e; - } + { + e = min_e; + } else - { - // assert(e); - l = i; - } + { + // assert(e); + l = i; + } found_l: // assert(buckets_[l].count_ >= 0); // assert(buckets_[l].list_ == e); @@ -401,49 +401,49 @@ Ns2CalendarScheduler::resize (int newsize, Scheduler::EventKey start) { uint64_t bwidth; if (newsize == nbuckets_) - { - /* we resize for bwidth*/ - if (head_search_) { - bwidth = head_search_; - } - else - { - bwidth = 1; - } - if (insert_search_) - { - bwidth = bwidth / insert_search_; - } - bwidth = static_cast (sqrt (bwidth) * width_); - if (bwidth < min_bin_width_) - { - if (time_to_newwidth_ > 0) - { - time_to_newwidth_--; - head_search_ = 0; - insert_search_ = 0; - round_num_ = 0; - return; // failed to adjust bwidth - } + /* we resize for bwidth*/ + if (head_search_) + { + bwidth = head_search_; + } else - { - // We have many (adjust_new_width_interval_) times failure in adjusting bwidth. - // should do a reshuffle with newwidth - bwidth = newwidth (newsize); - } + { + bwidth = 1; + } + if (insert_search_) + { + bwidth = bwidth / insert_search_; + } + bwidth = static_cast (sqrt (bwidth) * width_); + if (bwidth < min_bin_width_) + { + if (time_to_newwidth_ > 0) + { + time_to_newwidth_--; + head_search_ = 0; + insert_search_ = 0; + round_num_ = 0; + return; // failed to adjust bwidth + } + else + { + // We have many (adjust_new_width_interval_) times failure in adjusting bwidth. + // should do a reshuffle with newwidth + bwidth = newwidth (newsize); + } + } + // snoopy queue calculation } - // snoopy queue calculation - } else - { - /* we resize for size */ - bwidth = newwidth (newsize); - if (newsize < 4) { - newsize = 4; + /* we resize for size */ + bwidth = newwidth (newsize); + if (newsize < 4) + { + newsize = 4; + } } - } Bucket *oldb = buckets_; int oldn = nbuckets_; @@ -454,24 +454,24 @@ Ns2CalendarScheduler::resize (int newsize, Scheduler::EventKey start) int i; for (i = 0; i < oldn; ++i) - { - // we can do inserts faster, if we use insert2, but to - // preserve FIFO, we have to start from the end of - // each bucket and use insert2 - if (oldb[i].list_) { - BucketItem *tail = oldb[i].list_->prev_; - BucketItem *e = tail; - do - { - BucketItem* ep = e->prev_; - e->next_ = e->prev_ = 0; - insert2 (e); - e = ep; - } - while (e != tail); + // we can do inserts faster, if we use insert2, but to + // preserve FIFO, we have to start from the end of + // each bucket and use insert2 + if (oldb[i].list_) + { + BucketItem *tail = oldb[i].list_->prev_; + BucketItem *e = tail; + do + { + BucketItem* ep = e->prev_; + e->next_ = e->prev_ = 0; + insert2 (e); + e = ep; + } + while (e != tail); + } } - } head_search_ = 0; insert_search_ = 0; round_num_ = 0; @@ -489,46 +489,46 @@ Ns2CalendarScheduler::insert2 (Ns2CalendarScheduler::BucketItem* e) BucketItem *head = buckets_[i].list_; BucketItem *before = 0; if (!head) - { - buckets_[i].list_ = e; - e->next_ = e->prev_ = e; - ++stat_qsize_; - ++buckets_[i].count_; - } - else - { - bool newhead; - if (e->event.key > head->prev_->event.key) // strict LIFO, so > and not >= - { // insert at the tail - before = head; - newhead = false; - } - else - { - // insert event in time sorted order, LIFO for sim-time events - for (before = head; e->event.key > before->event.key; before = before->next_) - { - } - newhead = (before == head); - } - - e->next_ = before; - e->prev_ = before->prev_; - before->prev_ = e; - e->prev_->next_ = e; - if (newhead) { buckets_[i].list_ = e; - // assert(e->time_ <= e->next_->time_); - } - - if (e != e->next_ && e->next_->event.key != e->event.key) - { - // unique timing + e->next_ = e->prev_ = e; ++stat_qsize_; ++buckets_[i].count_; } - } + else + { + bool newhead; + if (e->event.key > head->prev_->event.key) // strict LIFO, so > and not >= + { // insert at the tail + before = head; + newhead = false; + } + else + { + // insert event in time sorted order, LIFO for sim-time events + for (before = head; e->event.key > before->event.key; before = before->next_) + { + } + newhead = (before == head); + } + + e->next_ = before; + e->prev_ = before->prev_; + before->prev_ = e; + e->prev_->next_ = e; + if (newhead) + { + buckets_[i].list_ = e; + // assert(e->time_ <= e->next_->time_); + } + + if (e != e->next_ && e->next_->event.key != e->event.key) + { + // unique timing + ++stat_qsize_; + ++buckets_[i].count_; + } + } // assert(e == buckets_[i].list_ || e->prev_->time_ <= e->time_); // assert(e == buckets_[i].list_->prev_ || e->next_->time_ >= e->time_); @@ -540,28 +540,28 @@ uint64_t Ns2CalendarScheduler::newwidth (int newsize) { if (adjust_new_width_interval_) - { - time_to_newwidth_ = adjust_new_width_interval_; - if (avg_gap_ > 0) { - return avg_gap_ * 4; + time_to_newwidth_ = adjust_new_width_interval_; + if (avg_gap_ > 0) + { + return avg_gap_ * 4; + } } - } int i; int max_bucket = 0; // index of the fullest bucket for (i = 1; i < nbuckets_; ++i) - { - if (buckets_[i].count_ > buckets_[max_bucket].count_) { - max_bucket = i; + if (buckets_[i].count_ > buckets_[max_bucket].count_) + { + max_bucket = i; + } } - } int nsamples = buckets_[max_bucket].count_; if (nsamples <= 4) - { - return width_; - } + { + return width_; + } uint64_t nw = (buckets_[max_bucket].list_->prev_->event.key.m_ts - buckets_[max_bucket].list_->event.key.m_ts) * 4; diff --git a/src/core/model/nstime.h b/src/core/model/nstime.h index 61125d6d1..7979226a6 100644 --- a/src/core/model/nstime.h +++ b/src/core/model/nstime.h @@ -175,7 +175,7 @@ public: : m_data (o.m_data) {} explicit inline Time (double v) - : m_data (lround(v)) + : m_data (lround (v)) {} explicit inline Time (int v) : m_data (v) diff --git a/src/core/model/object-base.h b/src/core/model/object-base.h index 811c9510c..3b910e0b5 100644 --- a/src/core/model/object-base.h +++ b/src/core/model/object-base.h @@ -29,7 +29,7 @@ * defines a new GetTypeId method. */ #define NS_OBJECT_ENSURE_REGISTERED(type) \ - static struct X## type ## RegistrationClass \ + static struct X ## type ## RegistrationClass \ { \ X ## type ## RegistrationClass () { \ ns3::TypeId tid = type::GetTypeId (); \ diff --git a/src/core/model/object.h b/src/core/model/object.h index f168872ed..f6b38abae 100644 --- a/src/core/model/object.h +++ b/src/core/model/object.h @@ -440,7 +440,7 @@ template Ptr CompleteConstruct (T *p) { p->SetTypeId (T::GetTypeId ()); - p->Object::Construct (AttributeList()); + p->Object::Construct (AttributeList ()); return Ptr (p, false); } template diff --git a/src/core/model/ptr.h b/src/core/model/ptr.h index 8486629cd..0dbbef776 100644 --- a/src/core/model/ptr.h +++ b/src/core/model/ptr.h @@ -100,7 +100,7 @@ public: // allow conversions from T to T const. template Ptr (Ptr const &o); - ~Ptr () ; + ~Ptr (); Ptr &operator = (Ptr const& o); T *operator -> () const; @@ -453,7 +453,7 @@ Ptr::~Ptr () { if (m_ptr != 0) { - m_ptr->Unref(); + m_ptr->Unref (); } } @@ -467,7 +467,7 @@ Ptr::operator = (Ptr const& o) } if (m_ptr != 0) { - m_ptr->Unref(); + m_ptr->Unref (); } m_ptr = o.m_ptr; Acquire (); diff --git a/src/core/model/random-variable.h b/src/core/model/random-variable.h index f4f3b9869..3241c05ed 100644 --- a/src/core/model/random-variable.h +++ b/src/core/model/random-variable.h @@ -603,10 +603,10 @@ public: * where \f$ mean = e^{\mu+\frac{\sigma^2}{2}} \f$ and * \f$ variance = (e^{\sigma^2}-1)e^{2\mu+\sigma^2}\f$ * - * The \f$ \mu \f$ and \f$ \sigma \f$ parameters can be calculated from the mean - * and standard deviation with the following equations: - * \f$ \mu = ln(mean) - \frac{1}{2}ln\left(1+\frac{stddev}{mean^2}\right)\f$, and, - * \f$ \sigma = \sqrt{ln\left(1+\frac{stddev}{mean^2}\right)}\f$ + * The \f$ \mu \f$ and \f$ \sigma \f$ parameters can be calculated if instead + * the mean and variance are known with the following equations: + * \f$ \mu = ln(mean) - \frac{1}{2}ln\left(1+\frac{variance}{mean^2}\right)\f$, and, + * \f$ \sigma = \sqrt{ln\left(1+\frac{variance}{mean^2}\right)}\f$ */ class LogNormalVariable : public RandomVariable { diff --git a/src/core/model/rng-stream.cc b/src/core/model/rng-stream.cc index 1ef525878..96f7287bb 100644 --- a/src/core/model/rng-stream.cc +++ b/src/core/model/rng-stream.cc @@ -110,7 +110,7 @@ double MultModM (double a, double s, double c, double m) a1 = static_cast (v / m); /* in case v < 0)*/ - if ((v -= a1 * m) < 0.0) return v += m;else return v; + if ((v -= a1 * m) < 0.0) return v += m; else return v; } @@ -250,13 +250,13 @@ double RngStream::U01 () double RngStream::U01d () { double u; - u = U01(); + u = U01 (); if (anti) { // Don't forget that U01() returns 1 - u in the antithetic case - u += (U01() - 1.0) * fact; + u += (U01 () - 1.0) * fact; return (u < 0.0) ? u + 1.0 : u; } else { - u += U01() * fact; + u += U01 () * fact; return (u < 1.0) ? u : (u - 1.0); } } @@ -361,7 +361,7 @@ RngStream::RngStream(const RngStream& r) } -void RngStream::InitializeStream() +void RngStream::InitializeStream () { // Moved from the RngStream constructor above to allow seeding // AFTER the global package seed has been set in the Random // object constructor. @@ -405,8 +405,8 @@ void RngStream::ResetStartSubstream () // void RngStream::ResetNextSubstream () { - MatVecModM(A1p76, Bg, Bg, m1); - MatVecModM(A2p76, &Bg[3], &Bg[3], m2); + MatVecModM (A1p76, Bg, Bg, m1); + MatVecModM (A2p76, &Bg[3], &Bg[3], m2); for (int i = 0; i < 6; ++i) Cg[i] = Bg[i]; } @@ -418,8 +418,8 @@ void RngStream::ResetNthSubstream (uint32_t N) { if(N==0) return; for(uint32_t i=0; i (limit) + (tol) || (actual) < (limit) - (tol)) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream msgStream; \ msgStream << msg; \ std::ostringstream actualStream; \ @@ -301,7 +301,7 @@ extern bool gBreakOnFailure; do { \ if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream msgStream; \ msgStream << msg; \ std::ostringstream actualStream; \ @@ -383,7 +383,7 @@ extern bool gBreakOnFailure; do { \ if ((actual) > (limit) + (tol) || (actual) < (limit) - (tol)) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream msgStream; \ msgStream << msg; \ std::ostringstream actualStream; \ @@ -459,7 +459,7 @@ extern bool gBreakOnFailure; do { \ if (!((actual) != (limit))) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream msgStream; \ msgStream << msg; \ std::ostringstream actualStream; \ @@ -510,7 +510,7 @@ extern bool gBreakOnFailure; do { \ if (!((actual) != (limit))) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream msgStream; \ msgStream << msg; \ std::ostringstream actualStream; \ @@ -567,7 +567,7 @@ extern bool gBreakOnFailure; do { \ if (!((actual) != (limit))) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream msgStream; \ msgStream << msg; \ std::ostringstream actualStream; \ @@ -618,7 +618,7 @@ extern bool gBreakOnFailure; do { \ if (!((actual) < (limit))) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream msgStream; \ msgStream << msg; \ std::ostringstream actualStream; \ @@ -662,7 +662,7 @@ extern bool gBreakOnFailure; do { \ if (!((actual) < (limit))) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream msgStream; \ msgStream << msg; \ std::ostringstream actualStream; \ @@ -702,7 +702,7 @@ extern bool gBreakOnFailure; do { \ if (!((actual) > (limit))) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream msgStream; \ msgStream << msg; \ std::ostringstream actualStream; \ @@ -746,7 +746,7 @@ extern bool gBreakOnFailure; do { \ if (!((actual) > (limit))) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream msgStream; \ msgStream << msg; \ std::ostringstream actualStream; \ diff --git a/src/core/model/traced-value.h b/src/core/model/traced-value.h index 05ea39cf3..aa3b487a6 100644 --- a/src/core/model/traced-value.h +++ b/src/core/model/traced-value.h @@ -135,7 +135,7 @@ private: template std::ostream& operator << (std::ostream& os, const TracedValue& rhs) { - return os< diff --git a/src/core/model/type-id.h b/src/core/model/type-id.h index bdd0a2aab..f79514a1e 100644 --- a/src/core/model/type-id.h +++ b/src/core/model/type-id.h @@ -51,7 +51,7 @@ public: ATTR_GET = 1<<0, /**< The attribute can be read */ ATTR_SET = 1<<1, /**< The attribute can be written */ ATTR_CONSTRUCT = 1<<2, /**< The attribute can be written at construction-time */ - ATTR_SGC = ATTR_GET | ATTR_SET | ATTR_CONSTRUCT, /** The attribute can be read, and written at any time */ + ATTR_SGC = ATTR_GET | ATTR_SET | ATTR_CONSTRUCT, /**< The attribute can be read, and written at any time */ }; /** diff --git a/src/core/model/type-traits.h b/src/core/model/type-traits.h index d3d00dc96..456283d20 100644 --- a/src/core/model/type-traits.h +++ b/src/core/model/type-traits.h @@ -39,14 +39,14 @@ private: enum { IsFunctionPointer = 0}; }; template - struct FunctionPtrTraits + struct FunctionPtrTraits { enum { IsFunctionPointer = 1}; enum { nArgs = 0}; typedef U ReturnType; }; template - struct FunctionPtrTraits + struct FunctionPtrTraits { enum { IsFunctionPointer = 1}; enum { nArgs = 1}; @@ -54,7 +54,7 @@ private: typedef V1 Arg1Type; }; template - struct FunctionPtrTraits + struct FunctionPtrTraits { enum { IsFunctionPointer = 1}; enum { nArgs = 2}; @@ -64,7 +64,7 @@ private: }; template - struct FunctionPtrTraits + struct FunctionPtrTraits { enum { IsFunctionPointer = 1}; enum { nArgs = 3}; @@ -75,7 +75,7 @@ private: }; template - struct FunctionPtrTraits + struct FunctionPtrTraits { enum { IsFunctionPointer = 1}; enum { nArgs = 4}; @@ -88,7 +88,7 @@ private: template - struct FunctionPtrTraits + struct FunctionPtrTraits { enum { IsFunctionPointer = 1}; enum { nArgs = 5}; @@ -102,7 +102,7 @@ private: template - struct FunctionPtrTraits + struct FunctionPtrTraits { enum { IsFunctionPointer = 1}; enum { nArgs = 6}; @@ -119,21 +119,21 @@ private: enum { IsPointerToMember = 0}; }; template - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 0}; typedef U ReturnType; }; template - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 0}; typedef U ReturnType; }; template - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 1}; @@ -141,7 +141,7 @@ private: typedef W1 Arg1Type; }; template - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 1}; @@ -149,7 +149,7 @@ private: typedef W1 Arg1Type; }; template - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 2}; @@ -158,7 +158,7 @@ private: typedef W2 Arg2Type; }; template - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 2}; @@ -169,7 +169,7 @@ private: template - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 3}; @@ -181,7 +181,7 @@ private: template - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 3}; @@ -193,7 +193,7 @@ private: template - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 4}; @@ -206,7 +206,7 @@ private: template - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 4}; @@ -220,7 +220,7 @@ private: typename W1, typename W2, typename W3, typename W4, typename W5> - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 5}; @@ -235,7 +235,7 @@ private: typename W1, typename W2, typename W3, typename W4, typename W5> - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 5}; @@ -250,7 +250,7 @@ private: typename W1, typename W2, typename W3, typename W4, typename W5, typename W6> - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 6}; @@ -266,7 +266,7 @@ private: typename W1, typename W2, typename W3, typename W4, typename W5, typename W6> - struct PtrToMemberTraits + struct PtrToMemberTraits { enum { IsPointerToMember = 1}; enum { nArgs = 6}; diff --git a/src/core/model/uinteger.cc b/src/core/model/uinteger.cc index 86eba69a4..7d4548a61 100644 --- a/src/core/model/uinteger.cc +++ b/src/core/model/uinteger.cc @@ -23,7 +23,7 @@ namespace ns3 { -ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME(uint64_t,Uinteger); +ATTRIBUTE_VALUE_IMPLEMENT_WITH_NAME (uint64_t,Uinteger); namespace internal { diff --git a/src/core/model/unix-fd-reader.cc b/src/core/model/unix-fd-reader.cc index f992b2ebc..e5a6ae413 100644 --- a/src/core/model/unix-fd-reader.cc +++ b/src/core/model/unix-fd-reader.cc @@ -63,12 +63,12 @@ void FdReader::Start (int fd, Callback readCallback) } // make the read end non-blocking - tmp = fcntl(m_evpipe[0], F_GETFL); + tmp = fcntl (m_evpipe[0], F_GETFL); if (tmp == -1) { NS_FATAL_ERROR ("fcntl() failed: " << strerror (errno)); } - if (fcntl(m_evpipe[0], F_SETFL, tmp | O_NONBLOCK) == -1) + if (fcntl (m_evpipe[0], F_SETFL, tmp | O_NONBLOCK) == -1) { NS_FATAL_ERROR ("fcntl() failed: " << strerror (errno)); } diff --git a/src/core/model/unix-system-condition.cc b/src/core/model/unix-system-condition.cc index 70ace4583..3f5c40791 100644 --- a/src/core/model/unix-system-condition.cc +++ b/src/core/model/unix-system-condition.cc @@ -137,7 +137,7 @@ SystemConditionPrivate::TimedWait (uint64_t ns) ts.tv_nsec = ns % NS_PER_SEC; struct timeval tv; - gettimeofday(&tv, NULL); + gettimeofday (&tv, NULL); ts.tv_sec += tv.tv_sec; ts.tv_nsec += tv.tv_usec * 1000; diff --git a/src/core/model/unix-system-mutex.cc b/src/core/model/unix-system-mutex.cc index e088b4a47..d99187101 100644 --- a/src/core/model/unix-system-mutex.cc +++ b/src/core/model/unix-system-mutex.cc @@ -79,7 +79,7 @@ SystemMutexPrivate::Lock (void) { NS_FATAL_ERROR ("SystemMutexPrivate::Lock()" "pthread_mutex_lock failed: " << rc << " = \"" << - strerror(rc) << "\""); + strerror (rc) << "\""); } } @@ -93,7 +93,7 @@ SystemMutexPrivate::Unlock (void) { NS_FATAL_ERROR ("SystemMutexPrivate::Unlock()" "pthread_mutex_unlock failed: " << rc << " = \"" << - strerror(rc) << "\""); + strerror (rc) << "\""); } } @@ -110,21 +110,21 @@ SystemMutex::~SystemMutex() } void -SystemMutex::Lock() +SystemMutex::Lock () { NS_LOG_FUNCTION_NOARGS (); m_priv->Lock (); } void -SystemMutex::Unlock() +SystemMutex::Unlock () { NS_LOG_FUNCTION_NOARGS (); m_priv->Unlock (); } CriticalSection::CriticalSection (SystemMutex &mutex) - : m_mutex(mutex) + : m_mutex (mutex) { NS_LOG_FUNCTION_NOARGS (); m_mutex.Lock (); diff --git a/src/core/model/unix-system-thread.cc b/src/core/model/unix-system-thread.cc index e792125f5..0c7a8ffdf 100644 --- a/src/core/model/unix-system-thread.cc +++ b/src/core/model/unix-system-thread.cc @@ -85,7 +85,7 @@ SystemThreadImpl::Start (void) if (rc) { NS_FATAL_ERROR ("pthread_create failed: " << rc << "=\"" << - strerror(rc) << "\"."); + strerror (rc) << "\"."); } } @@ -99,7 +99,7 @@ SystemThreadImpl::Join (void) if (rc) { NS_FATAL_ERROR ("pthread_join failed: " << rc << "=\"" << - strerror(rc) << "\"."); + strerror (rc) << "\"."); } } diff --git a/src/core/model/vector.h b/src/core/model/vector.h index 434765e9e..1d5851dc9 100644 --- a/src/core/model/vector.h +++ b/src/core/model/vector.h @@ -118,7 +118,7 @@ std::istream &operator >> (std::istream &is, Vector2D &vector); typedef Vector3D Vector; typedef Vector3DValue VectorValue; typedef Vector3DChecker VectorChecker; -ATTRIBUTE_ACCESSOR_DEFINE(Vector); +ATTRIBUTE_ACCESSOR_DEFINE (Vector); Ptr MakeVectorChecker (void); } // namespace ns3 diff --git a/src/core/test/attribute-test-suite.cc b/src/core/test/attribute-test-suite.cc index 600888d5a..fb12c378e 100644 --- a/src/core/test/attribute-test-suite.cc +++ b/src/core/test/attribute-test-suite.cc @@ -175,9 +175,9 @@ public: return tid; } - void AddToVector1 (void) { m_vector1.push_back (CreateObject ());} - void AddToVector2 (void) { m_vector2.push_back (CreateObject ());} - void InvokeCb (double a, int b, float c) { m_cb (a,b,c);} + void AddToVector1 (void) { m_vector1.push_back (CreateObject ()); } + void AddToVector2 (void) { m_vector2.push_back (CreateObject ()); } + void InvokeCb (double a, int b, float c) { m_cb (a,b,c); } void InvokeCbValue (int8_t a) { @@ -187,14 +187,14 @@ public: } private: - void DoSetTestB (bool v) { m_boolTestA = v;} - bool DoGetTestB (void) const { return m_boolTestA;} - int16_t DoGetInt16 (void) const { return m_int16SetGet;} - void DoSetInt16 (int16_t v) { m_int16SetGet = v;} - uint32_t DoGetVectorN (void) const { return m_vector2.size ();} - Ptr DoGetVector (uint32_t i) const { return m_vector2[i];} - bool DoSetIntSrc (int8_t v) { m_intSrc2 = v; return true;} - int8_t DoGetIntSrc (void) const { return m_intSrc2;} + void DoSetTestB (bool v) { m_boolTestA = v; } + bool DoGetTestB (void) const { return m_boolTestA; } + int16_t DoGetInt16 (void) const { return m_int16SetGet; } + void DoSetInt16 (int16_t v) { m_int16SetGet = v; } + uint32_t DoGetVectorN (void) const { return m_vector2.size (); } + Ptr DoGetVector (uint32_t i) const { return m_vector2[i]; } + bool DoSetIntSrc (int8_t v) { m_intSrc2 = v; return true; } + int8_t DoGetIntSrc (void) const { return m_intSrc2; } bool m_boolTestA; bool m_boolTest; @@ -326,7 +326,7 @@ AttributeTestCase::DoRun (void) // // Set the BooleanValue Attribute to true via SetAttributeFailSafe path. // - ok = p->SetAttributeFailSafe("TestBoolName", StringValue ("true")); + ok = p->SetAttributeFailSafe ("TestBoolName", StringValue ("true")); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() \"TestBoolName\" to true"); ok = CheckGetCodePaths (p, "TestBoolName", "true", BooleanValue (true)); @@ -335,7 +335,7 @@ AttributeTestCase::DoRun (void) // // Set the BooleanValue to false via SetAttributeFailSafe path. // - ok = p->SetAttributeFailSafe("TestBoolName", StringValue ("false")); + ok = p->SetAttributeFailSafe ("TestBoolName", StringValue ("false")); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() \"TestBoolName\" to false"); ok = CheckGetCodePaths (p, "TestBoolName", "false", BooleanValue (false)); @@ -365,7 +365,7 @@ AttributeTestCase::DoRun (void) // attribute is declared differently in the object. First make sure we can set // to true. // - ok = p->SetAttributeFailSafe("TestBoolA", StringValue ("true")); + ok = p->SetAttributeFailSafe ("TestBoolA", StringValue ("true")); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() a boolean value to true"); ok = CheckGetCodePaths (p, "TestBoolA", "true", BooleanValue (true)); @@ -374,7 +374,7 @@ AttributeTestCase::DoRun (void) // // Now Set the BooleanValue to false via the setter. // - ok = p->SetAttributeFailSafe("TestBoolA", StringValue ("false")); + ok = p->SetAttributeFailSafe ("TestBoolA", StringValue ("false")); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() a boolean value to false"); ok = CheckGetCodePaths (p, "TestBoolA", "false", BooleanValue (false)); @@ -400,7 +400,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute to a negative value through a StringValue. // - ok = p->SetAttributeFailSafe("TestInt16", StringValue ("-5")); + ok = p->SetAttributeFailSafe ("TestInt16", StringValue ("-5")); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via StringValue to -5"); ok = CheckGetCodePaths (p, "TestInt16", "-5", IntegerValue (-5)); @@ -409,7 +409,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute to a positive value through a StringValue. // - ok = p->SetAttributeFailSafe("TestInt16", StringValue ("+2")); + ok = p->SetAttributeFailSafe ("TestInt16", StringValue ("+2")); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via StringValue to +2"); ok = CheckGetCodePaths (p, "TestInt16", "2", IntegerValue (2)); @@ -418,7 +418,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute to the most negative value of the signed 16-bit range. // - ok = p->SetAttributeFailSafe("TestInt16", StringValue ("-32768")); + ok = p->SetAttributeFailSafe ("TestInt16", StringValue ("-32768")); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via StringValue to -32768"); ok = CheckGetCodePaths (p, "TestInt16", "-32768", IntegerValue (-32768)); @@ -428,7 +428,7 @@ AttributeTestCase::DoRun (void) // Try to set the Attribute past the most negative value of the signed 16-bit // range and make sure the underlying attribute is unchanged. // - ok = p->SetAttributeFailSafe("TestInt16", StringValue ("-32769")); + ok = p->SetAttributeFailSafe ("TestInt16", StringValue ("-32769")); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via StringValue to -32769"); ok = CheckGetCodePaths (p, "TestInt16", "-32768", IntegerValue (-32768)); @@ -437,7 +437,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute to the most positive value of the signed 16-bit range. // - ok = p->SetAttributeFailSafe("TestInt16", StringValue ("32767")); + ok = p->SetAttributeFailSafe ("TestInt16", StringValue ("32767")); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via StringValue to 32767"); ok = CheckGetCodePaths (p, "TestInt16", "32767", IntegerValue (32767)); @@ -447,7 +447,7 @@ AttributeTestCase::DoRun (void) // Try to set the Attribute past the most positive value of the signed 16-bit // range and make sure the underlying attribute is unchanged. // - ok = p->SetAttributeFailSafe("TestInt16", StringValue ("32768")); + ok = p->SetAttributeFailSafe ("TestInt16", StringValue ("32768")); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via StringValue to 32768"); ok = CheckGetCodePaths (p, "TestInt16", "32767", IntegerValue (32767)); @@ -457,7 +457,7 @@ AttributeTestCase::DoRun (void) // Attributes can have limits other than the intrinsic limits of the // underlying data types. These limits are specified in the Object. // - ok = p->SetAttributeFailSafe("TestInt16WithBounds", IntegerValue (10)); + ok = p->SetAttributeFailSafe ("TestInt16WithBounds", IntegerValue (10)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via IntegerValue to 10"); ok = CheckGetCodePaths (p, "TestInt16WithBounds", "10", IntegerValue (10)); @@ -466,7 +466,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute past the positive limit. // - ok = p->SetAttributeFailSafe("TestInt16WithBounds", IntegerValue (11)); + ok = p->SetAttributeFailSafe ("TestInt16WithBounds", IntegerValue (11)); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 11"); ok = CheckGetCodePaths (p, "TestInt16WithBounds", "10", IntegerValue (10)); @@ -475,7 +475,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute at the negative limit. // - ok = p->SetAttributeFailSafe("TestInt16WithBounds", IntegerValue (-5)); + ok = p->SetAttributeFailSafe ("TestInt16WithBounds", IntegerValue (-5)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via IntegerValue to -5"); ok = CheckGetCodePaths (p, "TestInt16WithBounds", "-5", IntegerValue (-5)); @@ -484,7 +484,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute past the negative limit. // - ok = p->SetAttributeFailSafe("TestInt16WithBounds", IntegerValue (-6)); + ok = p->SetAttributeFailSafe ("TestInt16WithBounds", IntegerValue (-6)); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -6"); ok = CheckGetCodePaths (p, "TestInt16WithBounds", "-5", IntegerValue (-5)); @@ -510,7 +510,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute to zero. // - ok = p->SetAttributeFailSafe("TestUint8", UintegerValue (0)); + ok = p->SetAttributeFailSafe ("TestUint8", UintegerValue (0)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() to 0"); ok = CheckGetCodePaths (p, "TestUint8", "0", UintegerValue (0)); @@ -519,7 +519,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute to the most positive value of the unsigned 8-bit range. // - ok = p->SetAttributeFailSafe("TestUint8", UintegerValue (255)); + ok = p->SetAttributeFailSafe ("TestUint8", UintegerValue (255)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() to 255"); ok = CheckGetCodePaths (p, "TestUint8", "255", UintegerValue (255)); @@ -529,7 +529,7 @@ AttributeTestCase::DoRun (void) // Try and set the Attribute past the most positive value of the unsigned // 8-bit range. // - ok = p->SetAttributeFailSafe("TestUint8", UintegerValue (256)); + ok = p->SetAttributeFailSafe ("TestUint8", UintegerValue (256)); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() to 256"); ok = CheckGetCodePaths (p, "TestUint8", "255", UintegerValue (255)); @@ -539,7 +539,7 @@ AttributeTestCase::DoRun (void) // Set the Attribute to the most positive value of the unsigned 8-bit range // through a StringValue. // - ok = p->SetAttributeFailSafe("TestUint8", StringValue ("255")); + ok = p->SetAttributeFailSafe ("TestUint8", StringValue ("255")); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via StringValue to 255"); ok = CheckGetCodePaths (p, "TestUint8", "255", UintegerValue (255)); @@ -549,7 +549,7 @@ AttributeTestCase::DoRun (void) // Try and set the Attribute past the most positive value of the unsigned // 8-bit range through a StringValue. // - ok = p->SetAttributeFailSafe("TestUint8", StringValue ("256")); + ok = p->SetAttributeFailSafe ("TestUint8", StringValue ("256")); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via StringValue to 256"); ok = CheckGetCodePaths (p, "TestUint8", "255", UintegerValue (255)); @@ -558,7 +558,7 @@ AttributeTestCase::DoRun (void) // // Try to set the Attribute to a negative StringValue. // - ok = p->SetAttributeFailSafe("TestUint8", StringValue ("-1")); + ok = p->SetAttributeFailSafe ("TestUint8", StringValue ("-1")); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via StringValue to -1"); } @@ -581,7 +581,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute. // - ok = p->SetAttributeFailSafe("TestFloat", DoubleValue ((float)2.3)); + ok = p->SetAttributeFailSafe ("TestFloat", DoubleValue ((float)2.3)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() to 2.3"); ok = CheckGetCodePaths (p, "TestFloat", "2.3", DoubleValue ((float)2.3)); @@ -607,7 +607,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute using the EnumValue type. // - ok = p->SetAttributeFailSafe("TestEnum", EnumValue (AttributeObjectTest::TEST_C)); + ok = p->SetAttributeFailSafe ("TestEnum", EnumValue (AttributeObjectTest::TEST_C)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() to TEST_C"); ok = CheckGetCodePaths (p, "TestEnum", "TestC", EnumValue (AttributeObjectTest::TEST_C)); @@ -616,7 +616,7 @@ AttributeTestCase::DoRun (void) // // Set the Attribute using the StringValue type. // - ok = p->SetAttributeFailSafe("TestEnum", StringValue ("TestB")); + ok = p->SetAttributeFailSafe ("TestEnum", StringValue ("TestB")); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() to TEST_B"); ok = CheckGetCodePaths (p, "TestEnum", "TestB", EnumValue (AttributeObjectTest::TEST_B)); @@ -626,7 +626,7 @@ AttributeTestCase::DoRun (void) // Try to set the Attribute to a bogus enum using the StringValue type and // make sure the underlying value doesn't change. // - ok = p->SetAttributeFailSafe("TestEnum", StringValue ("TestD")); + ok = p->SetAttributeFailSafe ("TestEnum", StringValue ("TestD")); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() to TEST_D"); // ok = CheckGetCodePaths (p, "TestEnum", "TestB", EnumValue (AttributeObjectTest::TEST_B)); @@ -636,7 +636,7 @@ AttributeTestCase::DoRun (void) // Try to set the Attribute to a bogus enum using an integer implicit conversion // and make sure the underlying value doesn't change. // - ok = p->SetAttributeFailSafe("TestEnum", EnumValue (5)); + ok = p->SetAttributeFailSafe ("TestEnum", EnumValue (5)); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() to 5"); ok = CheckGetCodePaths (p, "TestEnum", "TestB", EnumValue (AttributeObjectTest::TEST_B)); @@ -655,13 +655,13 @@ AttributeTestCase::DoRun (void) // // Try to set a UniformVariable // - ok = p->SetAttributeFailSafe("TestRandom", RandomVariableValue (UniformVariable (0., 1.))); + ok = p->SetAttributeFailSafe ("TestRandom", RandomVariableValue (UniformVariable (0., 1.))); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() a UniformVariable"); // // Try to set a ConstantVariable // - ok = p->SetAttributeFailSafe("TestRandom", RandomVariableValue (ConstantVariable (10.))); + ok = p->SetAttributeFailSafe ("TestRandom", RandomVariableValue (ConstantVariable (10.))); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() a UniformVariable"); } @@ -770,7 +770,7 @@ IntegerTraceSourceAttributeTestCase::DoRun (void) // // Set the Attribute to a positive value through an IntegerValue. // - ok = p->SetAttributeFailSafe("IntegerTraceSource1", IntegerValue (5)); + ok = p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (5)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via IntegerValue to 5"); p->GetAttribute ("IntegerTraceSource1", iv); @@ -779,16 +779,16 @@ IntegerTraceSourceAttributeTestCase::DoRun (void) // // Limits should work. // - ok = p->SetAttributeFailSafe("IntegerTraceSource1", IntegerValue (127)); + ok = p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (127)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via IntegerValue to 127"); - ok = p->SetAttributeFailSafe("IntegerTraceSource1", IntegerValue (128)); + ok = p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (128)); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128"); - ok = p->SetAttributeFailSafe("IntegerTraceSource1", IntegerValue (-128)); + ok = p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (-128)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via IntegerValue to -128"); - ok = p->SetAttributeFailSafe("IntegerTraceSource1", IntegerValue (-129)); + ok = p->SetAttributeFailSafe ("IntegerTraceSource1", IntegerValue (-129)); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129"); // @@ -801,7 +801,7 @@ IntegerTraceSourceAttributeTestCase::DoRun (void) // // Set the Attribute to a positive value through an IntegerValue. // - ok = p->SetAttributeFailSafe("IntegerTraceSource2", IntegerValue (5)); + ok = p->SetAttributeFailSafe ("IntegerTraceSource2", IntegerValue (5)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via IntegerValue to 5"); p->GetAttribute ("IntegerTraceSource2", iv); @@ -810,16 +810,16 @@ IntegerTraceSourceAttributeTestCase::DoRun (void) // // Limits should work. // - ok = p->SetAttributeFailSafe("IntegerTraceSource2", IntegerValue (127)); + ok = p->SetAttributeFailSafe ("IntegerTraceSource2", IntegerValue (127)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via IntegerValue to 127"); - ok = p->SetAttributeFailSafe("IntegerTraceSource2", IntegerValue (128)); + ok = p->SetAttributeFailSafe ("IntegerTraceSource2", IntegerValue (128)); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via IntegerValue to 128"); - ok = p->SetAttributeFailSafe("IntegerTraceSource2", IntegerValue (-128)); + ok = p->SetAttributeFailSafe ("IntegerTraceSource2", IntegerValue (-128)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() via IntegerValue to -128"); - ok = p->SetAttributeFailSafe("IntegerTraceSource2", IntegerValue (-129)); + ok = p->SetAttributeFailSafe ("IntegerTraceSource2", IntegerValue (-129)); NS_TEST_ASSERT_MSG_EQ (ok, false, "Unexpectedly could SetAttributeFailSafe() via IntegerValue to -129"); } @@ -836,7 +836,7 @@ public: private: virtual void DoRun (void); - void NotifySource1 (int8_t old, int8_t n) { m_got1 = n;} + void NotifySource1 (int8_t old, int8_t n) { m_got1 = n; } int64_t m_got1; }; @@ -908,7 +908,7 @@ public: private: virtual void DoRun (void); - void NotifySource2 (double a, int b, float c) { m_got2 = a;} + void NotifySource2 (double a, int b, float c) { m_got2 = a; } double m_got2; }; @@ -982,7 +982,7 @@ public: private: virtual void DoRun (void); - void NotifySource2 (double a, int b, float c) { m_got2 = a;} + void NotifySource2 (double a, int b, float c) { m_got2 = a; } double m_got2; }; @@ -1016,7 +1016,7 @@ PointerAttributeTestCase::DoRun (void) // to that object. We can then set the PointerValue Attribute to that Ptr. // derived = Create (); - ok = p->SetAttributeFailSafe("Pointer", PointerValue (derived)); + ok = p->SetAttributeFailSafe ("Pointer", PointerValue (derived)); NS_TEST_ASSERT_MSG_EQ (ok, true, "Could not SetAttributeFailSafe() a PointerValue of the correct type"); // @@ -1078,7 +1078,7 @@ private: Callback m_cbValue; - void NotifyCallbackValue (int8_t a) { m_gotCbValue = a;} + void NotifyCallbackValue (int8_t a) { m_gotCbValue = a; } int16_t m_gotCbValue; }; diff --git a/src/core/test/callback-test-suite.cc b/src/core/test/callback-test-suite.cc index ad82cbe91..7af8cf722 100644 --- a/src/core/test/callback-test-suite.cc +++ b/src/core/test/callback-test-suite.cc @@ -31,10 +31,10 @@ public: BasicCallbackTestCase (); virtual ~BasicCallbackTestCase () {} - void Target1 (void) { m_test1 = true;} - int Target2 (void) { m_test2 = true; return 2;} - void Target3 (double a) { m_test3 = true;} - int Target4 (double a, int b) { m_test4 = true; return 4;} + void Target1 (void) { m_test1 = true; } + int Target2 (void) { m_test2 = true; return 2; } + void Target3 (double a) { m_test3 = true; } + int Target4 (double a, int b) { m_test4 = true; return 4; } private: virtual void DoRun (void); @@ -161,10 +161,10 @@ public: MakeCallbackTestCase (); virtual ~MakeCallbackTestCase () {} - void Target1 (void) { m_test1 = true;} - int Target2 (void) { m_test2 = true; return 2;} - void Target3 (double a) { m_test3 = true;} - int Target4 (double a, int b) { m_test4 = true; return 4;} + void Target1 (void) { m_test1 = true; } + int Target2 (void) { m_test2 = true; return 2; } + void Target3 (double a) { m_test3 = true; } + int Target4 (double a, int b) { m_test4 = true; return 4; } private: virtual void DoRun (void); @@ -387,7 +387,7 @@ public: NullifyCallbackTestCase (); virtual ~NullifyCallbackTestCase () {} - void Target1 (void) { m_test1 = true;} + void Target1 (void) { m_test1 = true; } private: virtual void DoRun (void); @@ -435,7 +435,7 @@ public: MakeCallbackTemplatesTestCase (); virtual ~MakeCallbackTemplatesTestCase () {} - void Target1 (void) { m_test1 = true;} + void Target1 (void) { m_test1 = true; } private: virtual void DoRun (void); diff --git a/src/core/test/config-test-suite.cc b/src/core/test/config-test-suite.cc index 625343c1b..f06a58395 100644 --- a/src/core/test/config-test-suite.cc +++ b/src/core/test/config-test-suite.cc @@ -457,8 +457,8 @@ public: ObjectVectorTraceConfigTestCase (); virtual ~ObjectVectorTraceConfigTestCase () {} - void Trace (int16_t oldValue, int16_t newValue) { m_newValue = newValue;} - void TraceWithPath (std::string path, int16_t old, int16_t newValue) { m_newValue = newValue; m_path = path;} + void Trace (int16_t oldValue, int16_t newValue) { m_newValue = newValue; } + void TraceWithPath (std::string path, int16_t old, int16_t newValue) { m_newValue = newValue; m_path = path; } private: virtual void DoRun (void); diff --git a/src/core/test/int64x64-test-suite.cc b/src/core/test/int64x64-test-suite.cc index 8bfacb4ca..a724f7748 100644 --- a/src/core/test/int64x64-test-suite.cc +++ b/src/core/test/int64x64-test-suite.cc @@ -132,43 +132,43 @@ Int64x64ArithmeticTestCase::DoRun (void) { int64x64_t a, b; - CHECK_EXPECTED (V(1) - V(1), 0); - CHECK_EXPECTED (V(1) - V(2), -1); - CHECK_EXPECTED (V(1) - V(3), -2); - CHECK_EXPECTED (V(1) - V(-1), 2); - CHECK_EXPECTED (V(1) - V(-2), 3); - CHECK_EXPECTED (V(-3) - V(-4), 1); - CHECK_EXPECTED (V(-2) - V(3), -5); - CHECK_EXPECTED (V(1) + V(2), 3); - CHECK_EXPECTED (V(1) + V(-3), -2); - CHECK_EXPECTED (V(0) + V(0), 0); - CHECK_EXPECTED (V(0) * V(0), 0); - CHECK_EXPECTED (V(0) * V(1), 0); - CHECK_EXPECTED (V(0) * V(-1), 0); - CHECK_EXPECTED (V(1) * V(0), 0); - CHECK_EXPECTED (V(1) * V(1), 1); - CHECK_EXPECTED (V(1) * V(-1), -1); - CHECK_EXPECTED (V(-1) * V(-1), 1); - CHECK_EXPECTED (V(0) * V(1), 0); - CHECK_EXPECTED (V(0) * V(-1), 0); - CHECK_EXPECTED (V(-1) * V(1), -1); + CHECK_EXPECTED (V (1) - V (1), 0); + CHECK_EXPECTED (V (1) - V (2), -1); + CHECK_EXPECTED (V (1) - V (3), -2); + CHECK_EXPECTED (V (1) - V (-1), 2); + CHECK_EXPECTED (V (1) - V (-2), 3); + CHECK_EXPECTED (V (-3) - V (-4), 1); + CHECK_EXPECTED (V (-2) - V (3), -5); + CHECK_EXPECTED (V (1) + V (2), 3); + CHECK_EXPECTED (V (1) + V (-3), -2); + CHECK_EXPECTED (V (0) + V (0), 0); + CHECK_EXPECTED (V (0) * V (0), 0); + CHECK_EXPECTED (V (0) * V (1), 0); + CHECK_EXPECTED (V (0) * V (-1), 0); + CHECK_EXPECTED (V (1) * V (0), 0); + CHECK_EXPECTED (V (1) * V (1), 1); + CHECK_EXPECTED (V (1) * V (-1), -1); + CHECK_EXPECTED (V (-1) * V (-1), 1); + CHECK_EXPECTED (V (0) * V (1), 0); + CHECK_EXPECTED (V (0) * V (-1), 0); + CHECK_EXPECTED (V (-1) * V (1), -1); - CHECK_EXPECTED (V (2) * V(3) / V(3), 2); + CHECK_EXPECTED (V (2) * V (3) / V (3), 2); // Below, the division loses precision because 2/3 is not // representable exactly in 64.64 integers. So, we got // something super close but the final rounding kills us. - a = V(2); - b = V(3); + a = V (2); + b = V (3); a /= b; a *= b; - CHECK_EXPECTED (V(2) / V(3) * V(3), 1); + CHECK_EXPECTED (V (2) / V (3) * V (3), 1); // The example below shows that we really do not lose // much precision internally: it is almost always the // final conversion which loses precision. - CHECK_EXPECTED (V (2000000000) / V(3) * V(3), 1999999999); + CHECK_EXPECTED (V (2000000000) / V (3) * V (3), 1999999999); } class Int64x64Bug455TestCase : public TestCase @@ -248,12 +248,12 @@ void Int64x64CompareTestCase::DoRun (void) { - NS_TEST_ASSERT_MSG_EQ ((V(-1) < V(1)), true, "a is smaller than b"); - NS_TEST_ASSERT_MSG_EQ ((V(-1) > V(-2)), true, "a is bigger than b"); - NS_TEST_ASSERT_MSG_EQ ((V(-1) == V(-1)), true, "a is equal to b"); + NS_TEST_ASSERT_MSG_EQ ((V (-1) < V (1)), true, "a is smaller than b"); + NS_TEST_ASSERT_MSG_EQ ((V (-1) > V (-2)), true, "a is bigger than b"); + NS_TEST_ASSERT_MSG_EQ ((V (-1) == V (-1)), true, "a is equal to b"); - NS_TEST_ASSERT_MSG_EQ ((V(1) > V(-1)), true, "a is bigger than b"); - NS_TEST_ASSERT_MSG_EQ ((V(1) < V(2)), true, "a is smaller than b"); + NS_TEST_ASSERT_MSG_EQ ((V (1) > V (-1)), true, "a is bigger than b"); + NS_TEST_ASSERT_MSG_EQ ((V (1) < V (2)), true, "a is smaller than b"); } class Int64x64InvertTestCase : public TestCase @@ -284,7 +284,7 @@ Int64x64InvertTestCase::DoRun (void) NS_TEST_ASSERT_MSG_EQ (c.GetHigh (), 0, \ "1 * 1/x should be 0 for x=" << factor); \ int64x64_t d = V (1); \ - d /= (V(factor)); \ + d /= (V (factor)); \ NS_TEST_ASSERT_MSG_EQ (d.GetDouble (), c.GetDouble (), \ "1 * 1/x should be equal to 1/x for x=" << factor); \ int64x64_t e = V (-factor); \ @@ -293,28 +293,28 @@ Int64x64InvertTestCase::DoRun (void) "-x * 1/x should be -1 for x=" << factor); \ } \ while(false) - TEST(2); - TEST(3); - TEST(4); - TEST(5); - TEST(6); - TEST(10); - TEST(99); - TEST(100); - TEST(1000); - TEST(10000); - TEST(100000); - TEST(100000); - TEST(1000000); - TEST(10000000); - TEST(100000000); - TEST(1000000000); - TEST(10000000000LL); - TEST(100000000000LL); - TEST(1000000000000LL); - TEST(10000000000000LL); - TEST(100000000000000LL); - TEST(1000000000000000LL); + TEST (2); + TEST (3); + TEST (4); + TEST (5); + TEST (6); + TEST (10); + TEST (99); + TEST (100); + TEST (1000); + TEST (10000); + TEST (100000); + TEST (100000); + TEST (1000000); + TEST (10000000); + TEST (100000000); + TEST (1000000000); + TEST (10000000000LL); + TEST (100000000000LL); + TEST (1000000000000LL); + TEST (10000000000000LL); + TEST (100000000000000LL); + TEST (1000000000000000LL); #undef TEST } diff --git a/src/core/test/simulator-test-suite.cc b/src/core/test/simulator-test-suite.cc index 0206c6477..ae4da46ff 100644 --- a/src/core/test/simulator-test-suite.cc +++ b/src/core/test/simulator-test-suite.cc @@ -38,7 +38,7 @@ public: void D (int d); void foo0 (void); uint64_t NowUs (void); - void destroy(void); + void destroy (void); bool m_b; bool m_a; bool m_c; @@ -103,7 +103,7 @@ SimulatorEventsTestCase::D (int d) } void -SimulatorEventsTestCase::foo0(void) +SimulatorEventsTestCase::foo0 (void) {} void diff --git a/src/core/test/type-traits-test-suite.cc b/src/core/test/type-traits-test-suite.cc index f2b220ee4..66e02225f 100644 --- a/src/core/test/type-traits-test-suite.cc +++ b/src/core/test/type-traits-test-suite.cc @@ -39,12 +39,12 @@ TypeTraitsTestCase::TypeTraitsTestCase (void) void TypeTraitsTestCase::DoRun (void) { - NS_TEST_ASSERT_MSG_EQ (TypeTraits::IsPointerToMember, 1, "Check"); - NS_TEST_ASSERT_MSG_EQ (TypeTraits::IsPointerToMember, 1, "Check"); - NS_TEST_ASSERT_MSG_EQ (TypeTraits::IsPointerToMember, 1, "Check"); - NS_TEST_ASSERT_MSG_EQ (TypeTraits::IsPointerToMember, 1, "Check"); - NS_TEST_ASSERT_MSG_EQ (TypeTraits::PointerToMemberTraits::nArgs, 0, "Check"); - NS_TEST_ASSERT_MSG_EQ (TypeTraits::PointerToMemberTraits::nArgs, 1, "Check"); + NS_TEST_ASSERT_MSG_EQ (TypeTraits::IsPointerToMember, 1, "Check"); + NS_TEST_ASSERT_MSG_EQ (TypeTraits::IsPointerToMember, 1, "Check"); + NS_TEST_ASSERT_MSG_EQ (TypeTraits::IsPointerToMember, 1, "Check"); + NS_TEST_ASSERT_MSG_EQ (TypeTraits::IsPointerToMember, 1, "Check"); + NS_TEST_ASSERT_MSG_EQ (TypeTraits::PointerToMemberTraits::nArgs, 0, "Check"); + NS_TEST_ASSERT_MSG_EQ (TypeTraits::PointerToMemberTraits::nArgs, 1, "Check"); } class TypeTraitsTestSuite : public TestSuite diff --git a/src/csma-layout/examples/csma-star.cc b/src/csma-layout/examples/csma-star.cc index 1b0e6a280..b92271589 100644 --- a/src/csma-layout/examples/csma-star.cc +++ b/src/csma-layout/examples/csma-star.cc @@ -63,7 +63,7 @@ main (int argc, char *argv[]) uint32_t nSpokes = 7; CommandLine cmd; - cmd.AddValue("nSpokes", "Number of spoke nodes to place in the star", nSpokes); + cmd.AddValue ("nSpokes", "Number of spoke nodes to place in the star", nSpokes); cmd.Parse (argc, argv); NS_LOG_INFO ("Build star topology."); diff --git a/src/csma-layout/model/csma-star-helper.cc b/src/csma-layout/model/csma-star-helper.cc index b4089f3a1..dff12299a 100644 --- a/src/csma-layout/model/csma-star-helper.cc +++ b/src/csma-layout/model/csma-star-helper.cc @@ -24,7 +24,7 @@ #include "ns3/point-to-point-net-device.h" #include "ns3/vector.h" -NS_LOG_COMPONENT_DEFINE("CsmaStarHelper"); +NS_LOG_COMPONENT_DEFINE ("CsmaStarHelper"); namespace ns3 { diff --git a/src/csma-layout/wscript b/src/csma-layout/wscript index edf316e9d..79f0062e9 100644 --- a/src/csma-layout/wscript +++ b/src/csma-layout/wscript @@ -1,7 +1,7 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- def build(bld): - obj = bld.create_ns3_module('csma-layout', ['csma', 'network', 'applications']) + obj = bld.create_ns3_module('csma-layout', ['csma', 'network', 'applications', 'netanim', 'point-to-point']) obj.source = [ 'model/csma-star-helper.cc', ] diff --git a/src/csma/doc/csma.h b/src/csma/doc/csma.h deleted file mode 100644 index cf07a78c5..000000000 --- a/src/csma/doc/csma.h +++ /dev/null @@ -1,330 +0,0 @@ -/** - * \defgroup CsmaModel CSMA Device - * - * \section CsmaModelOverview CSMA Model Overview - * - * The ns-3 CSMA device models a simple bus network in the spirit of Ethernet. - * Although it does not model any real physical network you could ever build - * or buy, it does provide some very useful functionality. - * - * Typically when one thinks of a bus network Ethernet or IEEE 802.3 comes to - * mind. Ethernet uses CSMA/CD (Carrier Sense Multiple Access with Collision - * Detection with exponentially increasing backoff to contend for the shared - * transmission medium. The ns-3 CSMA device models only a portion of this - * process, using the nature of the globally available channel to provide - * instantaneous (faster than light) carrier sense and priority-based - * collision "avoidance." Collisions in the sense of Ethernet never happen and - * so the ns-3 CSMA device does not model collision detection, nor will any - * transmission in progress be "jammed." - * - * \section CsmaLayerModel CSMA Layer Model - * - * There are a number of conventions in use for describing layered - * communications architectures in the literature and in textbooks. The most - * common layering model is the ISO seven layer reference model. In this view - * the ns3::CsmaNetDevice and ns3::CsmaChannel pair occupies the lowest two - * layers -- at the physical (layer one), and data link (layer two) positions. - * Another important reference model is that specified by RFC 1122, - * "Requirements for Internet Hosts -- Communication Layers." In this view the - * CsmaNetDevice and CsmaChannel pair occupies the lowest layer -- - * the link layer. There is also a seemingly endless litany of alternative - * descriptions found in textbooks and in the literature. We adopt the naming - * conventions used in the IEEE 802 standards which speak of LLC, MAC, MII - * and PHY layering. These acronyms are defined as: - * - * - LLC: Logical Link Control; - * - MAC: Media Access Control; - * - MII: Media Independent Interface; - * - PHY: Physical Layer. - * - * In this case the LLC and MAC are sublayers of the OSI data link layer and the - * MII and PHY are sublayers of the OSI physical layer. - * - * The "top" of the CSMA device defines the transition from the network layer - * to the data link layer. This transition is performed by higher layers by - * calling either ns3::CsmaNetDevice::Send or ns3::CsmaNetDevice::SendFrom. - * - * In contrast to the IEEE 802.3 standards, there is no precisely specified - * PHY in the CSMA model in the sense of wire types, signals or pinouts. The - * "bottom" interface of the CsmaNetDevice can be thought of as as a kind - * of Media Independent Interface (MII) as seen in the "Fast Ethernet" - * (IEEE 802.3u) specifications. This MII interface fits into a corresponding - * media independent interface on the CsmaChannel. You will not find the - * equivalent of a 10BASE-T or a 1000BASE-LX PHY. - * - * The CsmaNetDevice calls the CsmaChannel through a media independent - * interface. There is a method defined to tell the channel when to start - * "wiggling the wires" using the method ns3::CsmaChannel::TransmitStart, and - * a method to tell the channel when the transmission process is done and - * the channel should begin propagating the last bit across the "wire": - * ns3::CsmaChannel::TransmitEnd. - * - * When the TransmitEnd method is executed, the channel will model a single - * uniform signal propagation delay in the medium and deliver copes of the packet - * to each of the devices attached to the packet via the - * ns3::CsmaNetDevice::Receive method. - * - * There is a "pin" in the device media independent interface corresponding to - * "COL" (collision). The state of the channel may be sensed by calling - * ns3::CsmaChannel::GetState. Each device will look at this "pin" before - * starting a send and will perform appropriate backoff operations if required. - * - * Properly received packets are forwarded up to higher levels from the - * CsmaNetDevice via a callback mechanism. The callback function is - * initialized by the higher layer (when the net device is attached) using - * ns3::CsmaNetDevice::SetReceiveCallback and is invoked upon "proper" - * reception of a packet by the net device in order to forward the packet up - * the protocol stack. - * - * \section CsmaChannelModel CSMA Channel Model - * - * The class CsmaChannel models the actual transmission medium. - * There is no fixed limit for the number of devices connected to the channel. - * The CsmaChannel models a data rate and a speed-of-light delay which can - * be accessed via the attributes "DataRate" and "Delay" respectively. - * The data rate provided to the channel is used to set the data rates - * used by the transmitter sections of the CSMA devices connected to the - * channel. There is no way to independently set data rates in the - * devices. Since the data rate is only used to calculate a delay time, there - * is no limitation (other than by the data type holding the value) on the - * speed at which CSMA channels and devices can operate; and no restriction - * based on any kind of PHY characteristics. - * - * The CsmaChannel has three states, IDLE, TRANSMITTING and PROPAGATING. - * These three states are "seen" instantaneously by all devices on the channel. - * By this we mean that if one device begins or ends a simulated transmission, - * all devices on the channel are immediately aware of the change in state. - * There is no time during which one device may see an IDLE channel while - * another device physically further away in the collision domain may have - * begun transmitting with the associated signals not propagated. Thus there - * is no need for collision detection in the CsmaChannel model and it is - * not implemented in any way. - * - * We do, as the name indicates, have a Carrier Sense aspect to the model. - * Since the simulator is single threaded, access to the common channel will - * be serialized by the simulator. This provides a deterministic mechanism - * for contending for the channel. The channel is allocated (transitioned from - * state IDLE to state TRANSMITTING) on a first-come first-served basis. The - * channel always goes through a three state process: - * - * IDLE -> TRANSMITTING -> PROPAGATING -> IDLE - * - * The TRANSMITTING state models the time during which the source net device - * is actually wiggling the signals on the wire. The PROPAGATING state models - * the time after the last bit was sent, when the signal is propagating down - * the wire to the "far end." - * - * The transition to the TRANSMITTING state is driven by a call to - * ns3::CsmaChannel::TransmitStart which is called by the net device that - * transmits the packet. It is the responsibility of that device to end the - * transmission with a call to ns3::CsmaChannel::TransmitEnd at the appropriate - * simulation time that reflects the time elapsed to put all of the packet bits - * on the wire. When TransmitEnd is called, the channel schedules an event - * corresponding to a single speed-of-light delay. This delay applies to all - * net devices on the channel identically. You can think of a symmetrical hub - * in which the packet bits propagate to a central location and then back out - * equal length cables to the other devices on the channel. - * - * The CsmaChannel models a broadcast medium so the packet is delivered - * to all of the devices on the channel (including the source) at the end of - * the propagation time. It is the responsibility of the sending device to - * determine whether or not it receives a packet broadcast over the channel. - * - * The CsmaChannel provides following Attributes: - * - * - DataRate: The bitrate for packet transmission on connected devices; - * - Delay: The speed of light transmission delay for the channel. - * - * \section CsmaNetDeviceModel CSMA Net Device Model - * - * The CSMA network device appears somewhat like an Ethernet device, but it - * is important to understand that it does not model an Ethernet device. As - * mentioned above, it does not model collisions. The CSMA model also provides - * users with the ability to configure the device into other states that are - * not compatible with strictly Ethernet or IEEE 802.3 devices. - * - * The CsmaNetDevice provides following Attributes: - * - * - Address: The Mac48Address of the device; - * - SendEnable: Enable packet transmission if true; - * - ReceiveEnable: Enable packet reception if true; - * - EncapsulationMode: Type of link layer encapsulation to use; - * - RxErrorModel: The receive error model; - * - TxQueue: The transmit queue used by the device; - * - InterframeGap: The optional time to wait between "frames"; - * - Rx: A trace source for received packets; - * - Drop: A trace source for dropped packets. - * - * We recommend thinking carefully about changing these Attributes, since - * it can result in behavior that surprises users. We allow this because - * we believe flexibility is important. As an example of a possibly - * surprising effect of changing Attributes, consider the following: - * - * The Mtu Attribute indicates the Maximum Transmission Unit to the device. - * This is the size of the largest Protocol Data Unit (PDU) that the - * device can send. This Attribute defaults to 1500 bytes and corresponds - * to a number found in RFC 894, "A Standard for the Transmission of IP - * Datagrams over Ethernet Networks." The number is actually derived - * from the maximum packet size for 10Base5 (full-spec Ethernet) networks -- - * 1518 bytes. If you subtract DIX encapsulation overhead for Ethernet - * packets (18 bytes) you will end up with a maximum possible data size (MTU) - * of 1500 bytes. One can also find that the MTU for IEEE 802.3 networks - * is 1492 bytes. This is because LLC/SNAP encapsulation adds an extra eight - * bytes of overhead to the packet. In both cases, the underlying network - * hardware is limited to 1518 bytes, but the MTU is different because the - * encapsulation is different. - * - * If one leaves the Mtu Attribute at 1500 bytes and changes the encapsulation - * mode Attribute to Llc, the result will be a network that encapsulates 1500 - * byte PDUs with LLC/SNAP framing resulting in packets of 1526 bytes. This - * would be illegal in many networks, but we allow you do do this. This - * results in a simulation that quite subtly does not reflect what you might - * be expecting since a real device would balk at sending a 1526 byte packet. - * - * There also exist jumbo frames (1500 < MTU <= 9000 bytes) and super-jumbo - * (MTU > 9000 bytes) frames that are not officially sanctioned by IEEE but - * are available in some high-speed (Gigabit) networks and NICs. In the - * CSMA model, one could leave the encapsulation mode set to Dix, and set the - * Mtu to 64000 bytes -- even though an associated CsmaChannel DataRate was - * left at 10 megabits per second (certainly not Gigabit Ethernet). This - * would essentially model an Ethernet switch made out of vampire-tapped - * 1980s-style 10Base5 networks that support super-jumbo datagrams, which is - * certainly not something that was ever made, nor is likely to ever be made; - * however it is quite easy for you to configure. - * - * Be careful about assumptions regarding what CSMA is actually modelling and - * how configuration (Attributes) may allow you to swerve considerably away - * from reality. - * - * The CsmaNetDevice supports the assignment of a "receive error model." - * This is an ErrorModel object that is used to simulate data corruption - * on the link. - * - * Packets sent over the CsmaNetDevice are always routed through the - * transmit queue to provide a trace hook for packets sent out over the - * network. This transmit queue can be set (via attribute) to model different - * queueing strategies. - * - * Also configurable by attribute is the encapsulation method used by the - * device. By default, or by setting the "EncapsulationMode" attribute to - * "Dix", the encapsulation is according to the DEC, Intel, Xerox standard. - * This is sometimes called EthernetII framing and is the familiar destination - * MAC, source MAC, EtherType, Data, CRC format. - * - * If the "EncapsulationMode" attribute is set to "Llc", the encapsulation is by - * LLC SNAP. In this case, a SNAP header is added that contains the EtherType - * (IP or ARP). - * - * The other implemented encapsulation modes are IP_ARP (set "EncapsulationMode" - * to "IpArp") in which the length type of the Ethernet header receives the - * protocol number of the packet; or ETHERNET_V1 (set "EncapsulationMode" to - * "EthernetV1") in which the length type of the Ethernet header receives the - * length of the packet. A "Raw" encapsulation mode is defined but not - * implemented -- use of the RAW mode results in an assertion. - * - * The CsmaNetDevice implements a random exponential backoff algorithm - * that is executed if the channel is determined to be busy (TRANSMITTING or - * PROPAGATING) when the device wants to start propagating. This results in a - * random delay of up to pow (2, retries) - 1 microseconds before a retry is - * attempted. The default maximum number of retries is 1000. - * - * \section CsmaTracingModel CSMA Tracing Model - * - * Like all ns-3 devices, the CSMA Model provides a number of trace sources. - * These trace sources can be hooked using your own custom trace code, or you - * can use our helper functions to arrange for tracing to be enabled on devices - * you specify. - * - * \subsection CsmaTracingModelUpperHooks Upper-Level (MAC) Hooks - * - * From the point of view of tracing in the net device, there are several - * interesting points to insert trace hooks. A convention inherited from other - * simulators is that packets destined for transmission onto attached networks - * pass through a single "transmit queue" in the net device. We provide trace - * hooks at this point in packet flow, which corresponds (abstractly) only to a - * transition from the network to data link layer, and call them collectively - * the device MAC hooks. - * - * When a packet is sent to the CSMA net device for transmission it always - * passes through the transmit queue. The transmit queue in the - * CsmaNetDevice inherits from Queue, and therefore inherits three - * trace sources: - * - * - An Enqueue operation source (see Queue::m_traceEnqueue); - * - A Dequeue operation source (see Queue::m_traceDequeue); - * - A Drop operation source (see Queue::m_traceDrop). - * - * The upper-level (MAC) trace hooks for the CsmaNetDevice are, in fact, - * exactly these three trace sources on the single transmit queue of the device. - * - * The m_traceEnqueue event is triggered when a packet is placed on the transmit - * queue. This happens at the time that ns3::CsmaNetDevice::Send or - * ns3::CsmaNetDevice::SendFrom is called by a higher layer to queue a packet for - * transmission. - * - * The m_traceDequeue event is triggered when a packet is removed from the - * transmit queue. Dequeues from the transmit queue can happen in three - * situations: 1) If the underlying channel is idle when the - * CsmaNetDevice::Send or CsmaNetDevice::SendFrom is called, a packet - * is dequeued from the transmit queue and immediately transmitted; 2) If the - * underlying channel is idle, a packet may be dequeued and immediately - * transmitted in an internal TransmitCompleteEvent that functions much - * like a transmit complete interrupt service routine; or 3) from - * the random exponential backoff handler if a timeout is detected. - * - * Case (3) implies that a packet is dequeued from the transmit queue if it is - * unable to be transmitted according to the backoff rules. It is important - * to understand that this will appear as a Dequeued packet and it is easy to - * incorrectly assume that the packet was transmitted since it passed through - * the transmit queue. In fact, a packet is actually dropped by the net device - * in this case. The reason for this behavior is due to the definition of the - * Queue Drop event. The m_traceDrop event is, by defintion, fired when a - * packet cannot be enqueued on the transmit queue because it is full. This - * event only fires if the queue is full and we do not overload this event - * to indicate that the CsmaChannel is "full." - * - * \subsection CsmaTracingModelUpperHooks Lower-Level (PHY) Hooks - * - * Similar to the upper level trace hooks, there are trace hooks available at - * the lower levels of the net device. We call these the PHY hooks. These - * events fire from the device methods that talk directly to the CsmaChannel. - * - * The trace source m_dropTrace is called to indicate a packet that is dropped - * by the device. This happens in two cases: First, if the receive side of - * the net device is not enabled (see ns3::CsmaNetDevice::m_receiveEnable and the - * associated attribute "ReceiveEnable"). - * - * The m_dropTrace is also used to indicate that a packet was discarded as - * corrupt if a receive error model is used (see - * ns3::CsmaNetDevice::m_receiveErrorModel and the associated attribute - * "ReceiveErrorModel"). - * - * The other low-level trace source fires on reception of an accepted packet - * (see ns3::CsmaNetDevice::m_rxTrace). A packet is accepted if it is destined - * for the broadcast address, a multicast address, or to the MAC address - * assigned to the net device. - * - * \section CsmaModelSummary CSMA Model Summary - * - * The ns3 CSMA model is a simplistic model of an Ethernet-like network. It - * supports a Carrier-Sense function and allows for Multiple Access to a - * shared medium. It is not physical in the sense that the state of the - * medium is instantaneously shared among all devices. This means that there - * is no collision detection required in this model and none is implemented. - * There will never be a "jam" of a packet already on the medium. Access to - * the shared channel is on a first-come first-served basis as determined by - * the simulator scheduler. If the channel is determined to be busy by looking - * at the global state, a random exponential backoff is performed and a retry - * is attempted. - * - * Ns-3 Attributes provide a mechanism for setting various parameters in the - * device and channel such as addresses, encapsulation modes and error model - * selection. Trace hooks are provided in the usual manner with a set of - * upper level hooks corresponding to a transmit queue and used in ASCII - * tracing; and also a set of lower level hooks used in pcap tracing. - * - * Although the ns-3 CsmaChannel and CsmaNetDevice does not model any kind of - * network you could build or buy, it does provide us with some useful - * functionality. You should, however, understand that it is explicitly not - * Ethernet or any flavor of IEEE 802.3 but an interesting subset. - */ diff --git a/src/csma/doc/csma.rst b/src/csma/doc/csma.rst index 639ed6f28..d4b21a3ec 100644 --- a/src/csma/doc/csma.rst +++ b/src/csma/doc/csma.rst @@ -228,6 +228,47 @@ allow you to use them in the future. This all takes just one line of code.:: NetDeviceContainer csmaDevices = csma.Install (csmaNodes); +We recommend thinking carefully about changing these Attributes, since +it can result in behavior that surprises users. We allow this because +we believe flexibility is important. As an example of a possibly +surprising effect of changing Attributes, consider the following: + +The Mtu Attribute indicates the Maximum Transmission Unit to the device. +This is the size of the largest Protocol Data Unit (PDU) that the +device can send. This Attribute defaults to 1500 bytes and corresponds +to a number found in RFC 894, "A Standard for the Transmission of IP +Datagrams over Ethernet Networks." The number is actually derived +from the maximum packet size for 10Base5 (full-spec Ethernet) networks -- +1518 bytes. If you subtract DIX encapsulation overhead for Ethernet +packets (18 bytes) you will end up with a maximum possible data size (MTU) +of 1500 bytes. One can also find that the MTU for IEEE 802.3 networks +is 1492 bytes. This is because LLC/SNAP encapsulation adds an extra eight +bytes of overhead to the packet. In both cases, the underlying network +hardware is limited to 1518 bytes, but the MTU is different because the +encapsulation is different. + +If one leaves the Mtu Attribute at 1500 bytes and changes the encapsulation +mode Attribute to Llc, the result will be a network that encapsulates 1500 +byte PDUs with LLC/SNAP framing resulting in packets of 1526 bytes. This +would be illegal in many networks, but we allow you do do this. This +results in a simulation that quite subtly does not reflect what you might +be expecting since a real device would balk at sending a 1526 byte packet. + +There also exist jumbo frames (1500 < MTU <= 9000 bytes) and super-jumbo +(MTU > 9000 bytes) frames that are not officially sanctioned by IEEE but +are available in some high-speed (Gigabit) networks and NICs. In the +CSMA model, one could leave the encapsulation mode set to Dix, and set the +Mtu to 64000 bytes -- even though an associated CsmaChannel DataRate was +left at 10 megabits per second (certainly not Gigabit Ethernet). This +would essentially model an Ethernet switch made out of vampire-tapped +1980s-style 10Base5 networks that support super-jumbo datagrams, which is +certainly not something that was ever made, nor is likely to ever be made; +however it is quite easy for you to configure. + +Be careful about assumptions regarding what CSMA is actually modelling and +how configuration (Attributes) may allow you to swerve considerably away +from reality. + CSMA Tracing ************ @@ -303,3 +344,29 @@ The other low-level trace source fires on reception of an accepted packet (see CsmaNetDevice::m_rxTrace). A packet is accepted if it is destined for the broadcast address, a multicast address, or to the MAC address assigned to the net device. + +Summary +******* + +The ns3 CSMA model is a simplistic model of an Ethernet-like network. It +supports a Carrier-Sense function and allows for Multiple Access to a +shared medium. It is not physical in the sense that the state of the +medium is instantaneously shared among all devices. This means that there +is no collision detection required in this model and none is implemented. +There will never be a "jam" of a packet already on the medium. Access to +the shared channel is on a first-come first-served basis as determined by +the simulator scheduler. If the channel is determined to be busy by looking +at the global state, a random exponential backoff is performed and a retry +is attempted. + +Ns-3 Attributes provide a mechanism for setting various parameters in the +device and channel such as addresses, encapsulation modes and error model +selection. Trace hooks are provided in the usual manner with a set of +upper level hooks corresponding to a transmit queue and used in ASCII +tracing; and also a set of lower level hooks used in pcap tracing. + +Although the ns-3 CsmaChannel and CsmaNetDevice does not model any kind of +network you could build or buy, it does provide us with some useful +functionality. You should, however, understand that it is explicitly not +Ethernet or any flavor of IEEE 802.3 but an interesting subset. + diff --git a/src/csma/examples/csma-broadcast.cc b/src/csma/examples/csma-broadcast.cc index 42aef40a2..8ca3bfd96 100644 --- a/src/csma/examples/csma-broadcast.cc +++ b/src/csma/examples/csma-broadcast.cc @@ -65,8 +65,8 @@ main (int argc, char *argv[]) NS_LOG_INFO ("Build Topology."); CsmaHelper csma; - csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate(5000000))); - csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds(2))); + csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); + csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); NetDeviceContainer n0 = csma.Install (c0); NetDeviceContainer n1 = csma.Install (c1); diff --git a/src/csma/examples/csma-multicast.cc b/src/csma/examples/csma-multicast.cc index 9f11636fb..e2ef4f3ec 100644 --- a/src/csma/examples/csma-multicast.cc +++ b/src/csma/examples/csma-multicast.cc @@ -119,7 +119,7 @@ main (int argc, char *argv[]) // 2) Set up a default multicast route on the sender n0 Ptr sender = c.Get (0); - Ptr senderIf = nd0.Get(0); + Ptr senderIf = nd0.Get (0); multicast.SetDefaultMulticastRoute (sender, senderIf); // @@ -144,12 +144,12 @@ main (int argc, char *argv[]) // // Tell the application when to start and stop. // - srcC.Start(Seconds(1.)); - srcC.Stop (Seconds(10.)); + srcC.Start (Seconds (1.)); + srcC.Stop (Seconds (10.)); // Create an optional packet sink to receive these packets PacketSinkHelper sink ("ns3::UdpSocketFactory", - InetSocketAddress (Ipv4Address::GetAny(), multicastPort)); + InetSocketAddress (Ipv4Address::GetAny (), multicastPort)); ApplicationContainer sinkC = sink.Install (c1.Get (2)); // Node n4 // Start the sink diff --git a/src/csma/examples/csma-one-subnet.cc b/src/csma/examples/csma-one-subnet.cc index 55efcc6f5..511e450e2 100644 --- a/src/csma/examples/csma-one-subnet.cc +++ b/src/csma/examples/csma-one-subnet.cc @@ -109,7 +109,7 @@ main (int argc, char *argv[]) onoff.SetAttribute ("Remote", AddressValue (InetSocketAddress (interfaces.GetAddress (0), port))); app = onoff.Install (nodes.Get (3)); - app.Start(Seconds (1.1)); + app.Start (Seconds (1.1)); app.Stop (Seconds (10.0)); app = sink.Install (nodes.Get (0)); diff --git a/src/csma/examples/csma-packet-socket.cc b/src/csma/examples/csma-packet-socket.cc index 2e8b4ba76..de2ba371a 100644 --- a/src/csma/examples/csma-packet-socket.cc +++ b/src/csma/examples/csma-packet-socket.cc @@ -72,8 +72,8 @@ main (int argc, char *argv[]) // create the shared medium used by all csma devices. NS_LOG_INFO ("Create channels."); Ptr channel = CreateObjectWithAttributes ( - "DataRate", DataRateValue (DataRate(5000000)), - "Delay", TimeValue (MilliSeconds(2))); + "DataRate", DataRateValue (DataRate (5000000)), + "Delay", TimeValue (MilliSeconds (2))); // use a helper function to connect our nodes to the shared channel. NS_LOG_INFO ("Build Topology."); @@ -84,7 +84,7 @@ main (int argc, char *argv[]) NS_LOG_INFO ("Create Applications."); // Create the OnOff application to send raw datagrams PacketSocketAddress socket; - socket.SetSingleDevice(devs.Get (0)->GetIfIndex ()); + socket.SetSingleDevice (devs.Get (0)->GetIfIndex ()); socket.SetPhysicalAddress (devs.Get (1)->GetAddress ()); socket.SetProtocol (2); OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket)); diff --git a/src/csma/model/backoff.cc b/src/csma/model/backoff.cc index 00939bf48..a6f8d4331 100644 --- a/src/csma/model/backoff.cc +++ b/src/csma/model/backoff.cc @@ -24,13 +24,13 @@ namespace ns3 { Backoff::Backoff () { - m_slotTime = MicroSeconds(1); + m_slotTime = MicroSeconds (1); m_minSlots = 1; m_maxSlots = 1000; m_ceiling = 10; m_maxRetries = 1000; - ResetBackoffTime(); + ResetBackoffTime (); } Backoff::Backoff(Time slotTime, uint32_t minSlots, uint32_t maxSlots, uint32_t ceiling, uint32_t maxRetries) @@ -64,7 +64,7 @@ Backoff::GetBackoffTime (void) maxSlot = m_maxSlots; } - uint32_t backoffSlots = (uint32_t)m_rng.GetValue(minSlot, maxSlot); + uint32_t backoffSlots = (uint32_t)m_rng.GetValue (minSlot, maxSlot); Time backoff = Time (backoffSlots * m_slotTime); return backoff; diff --git a/src/csma/model/backoff.h b/src/csma/model/backoff.h index 88528142a..8639b910a 100644 --- a/src/csma/model/backoff.h +++ b/src/csma/model/backoff.h @@ -68,7 +68,7 @@ public: * \return The amount of time that the net device should wait before * trying to retransmit the packet */ - Time GetBackoffTime(); + Time GetBackoffTime (); /** * Indicates to the backoff object that the last packet was diff --git a/src/csma/model/csma-channel.cc b/src/csma/model/csma-channel.cc index b59359036..8291f2360 100644 --- a/src/csma/model/csma-channel.cc +++ b/src/csma/model/csma-channel.cc @@ -55,7 +55,7 @@ CsmaChannel::CsmaChannel () { NS_LOG_FUNCTION_NOARGS (); m_state = IDLE; - m_deviceList.clear(); + m_deviceList.clear (); } int32_t @@ -77,7 +77,7 @@ CsmaChannel::Reattach (Ptr device) NS_ASSERT (device != 0); std::vector::iterator it; - for (it = m_deviceList.begin (); it < m_deviceList.end( ); it++) + for (it = m_deviceList.begin (); it < m_deviceList.end ( ); it++) { if (it->devicePtr == device) { @@ -174,7 +174,7 @@ CsmaChannel::TransmitStart (Ptr p, uint32_t srcId) return false; } - if (!IsActive(srcId)) + if (!IsActive (srcId)) { NS_LOG_ERROR ("CsmaChannel::TransmitStart(): Seclected source is not currently attached to network"); return false; @@ -188,13 +188,13 @@ CsmaChannel::TransmitStart (Ptr p, uint32_t srcId) } bool -CsmaChannel::IsActive(uint32_t deviceId) +CsmaChannel::IsActive (uint32_t deviceId) { return (m_deviceList[deviceId].active); } bool -CsmaChannel::TransmitEnd() +CsmaChannel::TransmitEnd () { NS_LOG_FUNCTION (this << m_currentPkt << m_currentSrc); NS_LOG_INFO ("UID is " << m_currentPkt->GetUid () << ")"); @@ -217,7 +217,7 @@ CsmaChannel::TransmitEnd() std::vector::iterator it; uint32_t devId = 0; - for (it = m_deviceList.begin (); it < m_deviceList.end(); it++) + for (it = m_deviceList.begin (); it < m_deviceList.end (); it++) { if (it->IsActive ()) { @@ -237,7 +237,7 @@ CsmaChannel::TransmitEnd() } void -CsmaChannel::PropagationCompleteEvent() +CsmaChannel::PropagationCompleteEvent () { NS_LOG_FUNCTION (this << m_currentPkt); NS_LOG_INFO ("UID is " << m_currentPkt->GetUid () << ")"); diff --git a/src/csma/model/csma-channel.h b/src/csma/model/csma-channel.h index 2c5131063..7e0f2c9bf 100644 --- a/src/csma/model/csma-channel.h +++ b/src/csma/model/csma-channel.h @@ -50,7 +50,7 @@ public: * \return If the net device pointed to by the devicePtr is active * and ready to RX/TX. */ - bool IsActive(); + bool IsActive (); }; /** @@ -130,7 +130,7 @@ public: * channel, false if the device is currently connected to the * channel or can't be found. */ - bool Reattach(uint32_t deviceId); + bool Reattach (uint32_t deviceId); /** * \brief Reattach a previously detached net device to the channel @@ -144,7 +144,7 @@ public: * channel, false if the device is currently connected to the * channel or can't be found. */ - bool Reattach(Ptr device); + bool Reattach (Ptr device); /** * \brief Start transmitting a packet over the channel diff --git a/src/csma/model/csma-net-device.cc b/src/csma/model/csma-net-device.cc index 3c26414aa..3d935f385 100644 --- a/src/csma/model/csma-net-device.cc +++ b/src/csma/model/csma-net-device.cc @@ -938,7 +938,7 @@ CsmaNetDevice::SendFrom (Ptr packet, const Address& src, const Address& // Place the packet to be sent on the send queue. Note that the // queue may fire a drop trace, but we will too. // - if (m_queue->Enqueue(packet) == false) + if (m_queue->Enqueue (packet) == false) { m_macTxDropTrace (packet); return false; @@ -996,7 +996,7 @@ Address CsmaNetDevice::GetMulticast (Ipv6Address addr) const { Mac48Address ad = Mac48Address::GetMulticast (addr); - NS_LOG_LOGIC("MAC IPv6 multicast address is " << ad); + NS_LOG_LOGIC ("MAC IPv6 multicast address is " << ad); return ad; } diff --git a/src/csma/model/csma-net-device.h b/src/csma/model/csma-net-device.h index a2ccdf5ab..cd63fa41b 100644 --- a/src/csma/model/csma-net-device.h +++ b/src/csma/model/csma-net-device.h @@ -41,7 +41,14 @@ class Queue; class CsmaChannel; class ErrorModel; +/** + * \defgroup csma CsmaNetDevice + * + * This section documents the API of the ns-3 csma module. For a generic functional description, please refer to the ns-3 manual. + */ + /** + * \ingroup csma * \class CsmaNetDevice * \brief A Device for a Csma Network Link. * diff --git a/src/dsdv/doc/dsdv.h b/src/dsdv/doc/dsdv.h index f5dd5d848..d90f1bc22 100644 --- a/src/dsdv/doc/dsdv.h +++ b/src/dsdv/doc/dsdv.h @@ -35,43 +35,9 @@ /** * \defgroup dsdv DSDV Routing * - * \brief Destination-Sequenced Distance Vector (DSDV) routing protocol is a pro-active, table-driven routing protocol - * for MANETs developed by Charles E. Perkins and Pravin Bhagwat in 1994. It uses the hop count as metric in route - * selection. - * - * DSDV Routing Table: Every node will maintain a table listing all the other nodes it has known either directly - * or through some neighbors. Every node has a single entry in the routing table. The entry will have information - * about the node's IP address, last known sequence number and the hop count to reach that node. Along with these - * details the table also keeps track of the nexthop neighbor to reach the destination node, the timestamp of the last - * update received for that node. - * - * The DSDV update message consists of three fields, Destination Address, Sequence Number and Hop Count. - * - * Each node uses 2 mechanisms to send out the DSDV updates. They are, - * 1. Periodic Updates - * Periodic updates are sent out after every m_periodicUpdateInterval(default:15s). In this update the node broadcasts - * out its entire routing table. - * 2. Trigger Updates - * Trigger Updates are small updates in-between the periodic updates. These updates are sent out whenever a node - * receives a DSDV packet that caused a change in its routing table. The original paper did not clearly mention - * when for what change in the table should a DSDV update be sent out. The current implemntation sends out an update - * irrespective of the change in the routing table. - * - * The updates are accepted based on the metric for a particular node. The first factor determinig the acceptance of - * an update is the sequence number. It has to accept the update if the sequence number of the update message is higher - * irrespective of the metric. If the update with same sequence number is received, then the update with least metric - * (hopCount) is given precedence. - * - * In highly mobile scenarios, there is a high chance of route fluctuations, thus we have the concept of weighted - * settling time where an update with change in metric will not be advertised to neighbors. The node waits for - * the settling time to make sure that it did not receive the update from its old neighbor before sending out - * that update. - * - * The current implementation covers all the above features of DSDV. The current implementation also has a request queue - * to buffer packets that have no routes to destination. The default is set to buffer up to 5 packets per destination. - * - * Link to the Paper: http://portal.acm.org/citation.cfm?doid=190314.190336 - * + * This section documents the API of the ns-3 DSDV module. For a + * generic functional description, please refer to the ns-3 model + * library document. */ #endif /* DSDV_H_ */ diff --git a/src/dsdv/doc/dsdv.rst b/src/dsdv/doc/dsdv.rst new file mode 100644 index 000000000..1722f9d4f --- /dev/null +++ b/src/dsdv/doc/dsdv.rst @@ -0,0 +1,49 @@ +.. include:: replace.txt + +DSDV Routing +------------ + +Destination-Sequenced Distance Vector (DSDV) routing protocol is a pro-active, table-driven routing protocol +for MANETs developed by Charles E. Perkins and Pravin Bhagwat in 1994. It uses the hop count as metric in route +selection. + + +DSDV Routing Overview +********************* + +DSDV Routing Table: Every node will maintain a table listing all the other nodes it has known either directly +or through some neighbors. Every node has a single entry in the routing table. The entry will have information +about the node's IP address, last known sequence number and the hop count to reach that node. Along with these +details the table also keeps track of the nexthop neighbor to reach the destination node, the timestamp of the last +update received for that node. + +The DSDV update message consists of three fields, Destination Address, Sequence Number and Hop Count. + +Each node uses 2 mechanisms to send out the DSDV updates. They are, + +1. Periodic Updates + Periodic updates are sent out after every m_periodicUpdateInterval(default:15s). In this update the node broadcasts + out its entire routing table. +2. Trigger Updates + Trigger Updates are small updates in-between the periodic updates. These updates are sent out whenever a node + receives a DSDV packet that caused a change in its routing table. The original paper did not clearly mention + when for what change in the table should a DSDV update be sent out. The current implemntation sends out an update + irrespective of the change in the routing table. + +The updates are accepted based on the metric for a particular node. The first factor determinig the acceptance of +an update is the sequence number. It has to accept the update if the sequence number of the update message is higher +irrespective of the metric. If the update with same sequence number is received, then the update with least metric +(hopCount) is given precedence. + +In highly mobile scenarios, there is a high chance of route fluctuations, thus we have the concept of weighted +settling time where an update with change in metric will not be advertised to neighbors. The node waits for +the settling time to make sure that it did not receive the update from its old neighbor before sending out +that update. + +The current implementation covers all the above features of DSDV. The current implementation also has a request queue +to buffer packets that have no routes to destination. The default is set to buffer up to 5 packets per destination. + +References +********** + +Link to the Paper: http://portal.acm.org/citation.cfm?doid=190314.190336 diff --git a/src/dsdv/model/dsdv-routing-protocol.cc b/src/dsdv/model/dsdv-routing-protocol.cc index aa5d424b5..99cbf593f 100644 --- a/src/dsdv/model/dsdv-routing-protocol.cc +++ b/src/dsdv/model/dsdv-routing-protocol.cc @@ -1138,8 +1138,8 @@ RoutingProtocol::GetSettlingTime (Ipv4Address address) { NS_LOG_DEBUG ("Route SettlingTime: " << mainrt.GetSettlingTime ().GetSeconds () << " and LifeTime:" << mainrt.GetLifeTime ().GetSeconds ()); - weightedTime = Time (m_weightedFactor * mainrt.GetSettlingTime ().GetSeconds() + (1.0 - m_weightedFactor) - * mainrt.GetLifeTime ().GetSeconds()); + weightedTime = Time (m_weightedFactor * mainrt.GetSettlingTime ().GetSeconds () + (1.0 - m_weightedFactor) + * mainrt.GetLifeTime ().GetSeconds ()); NS_LOG_DEBUG ("Calculated weightedTime:" << weightedTime.GetSeconds ()); return weightedTime; } diff --git a/src/emu/doc/emu.h b/src/emu/doc/emu.h deleted file mode 100644 index d25ef078b..000000000 --- a/src/emu/doc/emu.h +++ /dev/null @@ -1,113 +0,0 @@ -/** - * \defgroup EmuModel Emulated Device - * - * \section EmuModelOverview Emulated Net Device Model Overview - * - * The emulated net device allows a simulation node to send and receive packets - * a real network. - * - * The emulated net device relies on a specified interface being in promiscuous - * mode. It opens a raw socket and binds to that interface. We perform MAC - * spoofing to separate simulation network traffic from other network traffic - * that may be flowing to and from the host. - * - * Normally, the use case for emulated net devices is in collections of - * small simulations that connect to the outside world through specific - * interfaces. For example, one could construct a number of virtual - * machines and connect them via a host-only network. To use the emulated - * net device, you would need to set all of the host-only interfaces in - * promiscuous mode and provide an appropriate device name, "eth1" for example. - * - * One could also use the emulated net device in a testbed situation - * where the host on which the simulation is running has a specific interface - * of interest which drives the testbed hardware. You would also need to set - * this specific interface into promiscuous mode and provide an appropriate - * device name to the ns-3 emulated net device. - * - * The emulated net device only works if the underlying interface is up in - * promiscuous mode. We could just turn it on, but the situation is that we - * expect the other considerations listed above to have been dealt with. - * To verify that these issues are dealt with, we just make sure that the end - * result of that process has taken place and that the specified interface is - * in promiscuous mode. - * - * Packets will be sent out over the device, but we use MAC spoofing. The - * MAC addresses will be generated using the Organizationally Unique Identifier - * (OUI) 00:00:00 as a base. This vendor code is not assigned to any - * organization and so should not conflict with any real hardware. - * - * It is always up to you to determine that using these MAC addresses is - * okay on your network and won't conflict with anything else (including another - * simulation using emu devices) on your network. If you are using the - * emulated net device in separate simulations you must consider global MAC - * address assignment issues and ensure that MAC addresses are unique across - * all simulations. The emulated net device respects the MAC address provided - * in the SetAddress method so you can do this manually. For larger simulations, - * you may want to set the OUI in the MAC address allocation function. - * - * IP addresses corresponding to the emulated net devices are the addresses - * generated in the simulation, which are generated in the usual way via helper - * functions. - * - * The emulated net device comes with a helper function as all ns-3 devices do. - * One unique aspect is that there is no channel associated with the underlying - * medium. We really have no idea what this medium is, and so have not made an - * effort to model it abstractly. The primary thing to be aware of is the - * implication this has for static global routing. The global router module - * attempts to walk the channels looking for adjacent networks. Since there - * is no channel, the global router will be unable to do this. - * - * \section EmuTracingModel Emulated Net Device Tracing Model - * - * Like all ns-3 devices, the Emu Model provides a number of trace sources. - * These trace sources can be hooked using your own custom trace code, or you - * can use our helper functions to arrange for tracing to be enabled on devices - * you specify. - * - * \subsection EmuTracingModelUpperHooks Upper-Level (MAC) Hooks - * - * From the point of view of tracing in the net device, there are several - * interesting points to insert trace hooks. A convention inherited from other - * simulators is that packets destined for transmission onto attached networks - * pass through a single "transmit queue" in the net device. We provide trace - * hooks at this point in packet flow, which corresponds (abstractly) only to a - * transition from the network to data link layer, and call them collectively - * the device MAC hooks. - * - * When a packet is sent to the Emu net device for transmission it always - * passes through the transmit queue. The transmit queue in the EmuNetDevice - * inherits from Queue, and therefore inherits three trace sources: - * - * - An Enqueue operation source (see Queue::m_traceEnqueue); - * - A Dequeue operation source (see Queue::m_traceDequeue); - * - A Drop operation source (see Queue::m_traceDrop). - * - * The upper-level (MAC) trace hooks for the EmuNetDevice are, in fact, - * exactly these three trace sources on the single transmit queue of the device. - * - * The m_traceEnqueue event is triggered when a packet is placed on the transmit - * queue. This happens at the time that ns3::EmuNetDevice::Send or - * ns3::EmuNetDevice::SendFrom is called by a higher layer to queue a packet for - * transmission. - * - * The m_traceDequeue event is triggered when a packet is removed from the - * transmit queue. Dequeues from the transmit queue happen immediately after - * the packet was enqueued and only indicate that the packet is about to be - * sent to an underlying raw socket. The actual time at which the packet is - * sent out on the wire is not available. - * - * \subsection EmuTracingModelLowerHooks Lower-Level (PHY) Hooks - * - * Similar to the upper level trace hooks, there are trace hooks available at - * the lower levels of the net device. We call these the PHY hooks. These - * events fire from the device methods that talk directly to the underlying - * raw socket. - * - * The trace source m_dropTrace is not used in the Emu net device since that - * is really the business of the underlying "real" device driver. - * - * The other low-level trace source fires on reception of an accepted packet - * (see ns3::EmuNetDevice::m_rxTrace). A packet is accepted if it is destined - * for the broadcast address, a multicast address, or to the MAC address - * assigned to the Emu net device. - */ diff --git a/src/emu/doc/emu.rst b/src/emu/doc/emu.rst index 48285bea8..4df813eb5 100644 --- a/src/emu/doc/emu.rst +++ b/src/emu/doc/emu.rst @@ -266,3 +266,47 @@ from the net device queue to hit the trace hooks.:: Finally, we simply send the packet to the raw socket which puts it out on the real network. + +From the point of view of tracing in the net device, there are several +interesting points to insert trace hooks. A convention inherited from other +simulators is that packets destined for transmission onto attached networks +pass through a single "transmit queue" in the net device. We provide trace +hooks at this point in packet flow, which corresponds (abstractly) only to a +transition from the network to data link layer, and call them collectively +the device MAC hooks. + +When a packet is sent to the Emu net device for transmission it always +passes through the transmit queue. The transmit queue in the EmuNetDevice +inherits from Queue, and therefore inherits three trace sources: + +* An Enqueue operation source (see Queue::m_traceEnqueue); +* A Dequeue operation source (see Queue::m_traceDequeue); +* A Drop operation source (see Queue::m_traceDrop). + +The upper-level (MAC) trace hooks for the EmuNetDevice are, in fact, +exactly these three trace sources on the single transmit queue of the device. + +The m_traceEnqueue event is triggered when a packet is placed on the transmit +queue. This happens at the time that ns3::EmuNetDevice::Send or +``ns3::EmuNetDevice::SendFrom`` is called by a higher layer to queue a +packet for transmission. + +The m_traceDequeue event is triggered when a packet is removed from the +transmit queue. Dequeues from the transmit queue happen immediately after +the packet was enqueued and only indicate that the packet is about to be +sent to an underlying raw socket. The actual time at which the packet is +sent out on the wire is not available. + +Similar to the upper level trace hooks, there are trace hooks available at +the lower levels of the net device. We call these the PHY hooks. These +events fire from the device methods that talk directly to the underlying +raw socket. + +The trace source m_dropTrace is not used in the Emu net device since that +is really the business of the underlying "real" device driver. + +The other low-level trace source fires on reception of an accepted packet +(see ``ns3::EmuNetDevice::m_rxTrace``). A packet is accepted if it is destined +for the broadcast address, a multicast address, or to the MAC address +assigned to the Emu net device. + diff --git a/src/emu/examples/emu-ping.cc b/src/emu/examples/emu-ping.cc index 66b7552f5..0dc54d699 100644 --- a/src/emu/examples/emu-ping.cc +++ b/src/emu/examples/emu-ping.cc @@ -83,8 +83,8 @@ main (int argc, char *argv[]) // command-line arguments // CommandLine cmd; - cmd.AddValue("deviceName", "Device name", deviceName); - cmd.AddValue("remote", "Remote IP address (dotted decimal only please)", remote); + cmd.AddValue ("deviceName", "Device name", deviceName); + cmd.AddValue ("remote", "Remote IP address (dotted decimal only please)", remote); cmd.Parse (argc, argv); Ipv4Address remoteIp (remote.c_str ()); diff --git a/src/emu/examples/emu-udp-echo.cc b/src/emu/examples/emu-udp-echo.cc index 71cfce218..b5fb08eec 100644 --- a/src/emu/examples/emu-udp-echo.cc +++ b/src/emu/examples/emu-udp-echo.cc @@ -83,9 +83,9 @@ main (int argc, char *argv[]) // arguments // CommandLine cmd; - cmd.AddValue("deviceName", "device name", deviceName); - cmd.AddValue("encapsulationMode", "encapsulation mode of emu device (\"Dix\" [default] or \"Llc\")", encapMode); - cmd.AddValue("nNodes", "number of nodes to create (>= 2)", nNodes); + cmd.AddValue ("deviceName", "device name", deviceName); + cmd.AddValue ("encapsulationMode", "encapsulation mode of emu device (\"Dix\" [default] or \"Llc\")", encapMode); + cmd.AddValue ("nNodes", "number of nodes to create (>= 2)", nNodes); cmd.Parse (argc, argv); @@ -130,7 +130,7 @@ main (int argc, char *argv[]) // NS_LOG_INFO ("Create Applications."); UdpEchoServerHelper server (9); - ApplicationContainer apps = server.Install (n.Get(1)); + ApplicationContainer apps = server.Install (n.Get (1)); apps.Start (Seconds (1.0)); apps.Stop (Seconds (10.0)); diff --git a/src/emu/model/emu-encode-decode.cc b/src/emu/model/emu-encode-decode.cc index d558f88d6..e79faac16 100644 --- a/src/emu/model/emu-encode-decode.cc +++ b/src/emu/model/emu-encode-decode.cc @@ -41,7 +41,7 @@ EmuBufferToString (uint8_t *buffer, uint32_t len) // Tell the stream to make hex characters, zero-filled // oss.setf (std::ios::hex, std::ios::basefield); - oss.fill('0'); + oss.fill ('0'); // // Loop through the buffer, separating the two-digit-wide hex bytes diff --git a/src/emu/model/emu-net-device.cc b/src/emu/model/emu-net-device.cc index de59412d5..ef4dd217d 100644 --- a/src/emu/model/emu-net-device.cc +++ b/src/emu/model/emu-net-device.cc @@ -208,7 +208,7 @@ EmuNetDevice::~EmuNetDevice () } void -EmuNetDevice::DoDispose() +EmuNetDevice::DoDispose () { NS_LOG_FUNCTION_NOARGS (); if (m_readThread != 0) @@ -334,7 +334,7 @@ EmuNetDevice::StartDevice (void) ll.sll_family = AF_PACKET; ll.sll_ifindex = m_sll_ifindex; - ll.sll_protocol = htons(ETH_P_ALL); + ll.sll_protocol = htons (ETH_P_ALL); NS_LOG_LOGIC ("Binding socket to interface"); @@ -344,7 +344,7 @@ EmuNetDevice::StartDevice (void) NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Can't bind to specified interface"); } - rc = ioctl(m_sock, SIOCGIFFLAGS, &ifr); + rc = ioctl (m_sock, SIOCGIFFLAGS, &ifr); if (rc == -1) { NS_FATAL_ERROR ("EmuNetDevice::StartDevice(): Can't get interface flags"); @@ -446,7 +446,7 @@ EmuNetDevice::CreateSocket (void) // // Now encode that socket name (family and path) as a string of hex digits // - std::string path = EmuBufferToString((uint8_t *)&un, len); + std::string path = EmuBufferToString ((uint8_t *)&un, len); NS_LOG_INFO ("Encoded Unix socket as \"" << path << "\""); // // Fork and exec the process to create our socket. If we're us (the parent) @@ -548,7 +548,7 @@ EmuNetDevice::CreateSocket (void) // so we call it "control." // size_t msg_size = sizeof(int); - char control[CMSG_SPACE(msg_size)]; + char control[CMSG_SPACE (msg_size)]; // // There is a msghdr that is used to minimize the number of parameters @@ -585,7 +585,7 @@ EmuNetDevice::CreateSocket (void) // one we're interested in. // struct cmsghdr *cmsg; - for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) + for (cmsg = CMSG_FIRSTHDR (&msg); cmsg != NULL; cmsg = CMSG_NXTHDR (&msg, cmsg)) { if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) @@ -660,7 +660,7 @@ EmuNetDevice::ForwardUp (uint8_t *buf, uint32_t len) // filter out packets we think are completely bogus, so we always check to see // that the packet is long enough to contain the header we want to remove. // - if (packet->GetSize() < header.GetSerializedSize()) + if (packet->GetSize () < header.GetSerializedSize ()) { m_phyRxDropTrace (originalPacket); return; @@ -689,7 +689,7 @@ EmuNetDevice::ForwardUp (uint8_t *buf, uint32_t len) // Check to see that the packet is long enough to possibly contain the // header we want to remove before just naively calling. // - if (packet->GetSize() < llc.GetSerializedSize()) + if (packet->GetSize () < llc.GetSerializedSize ()) { m_phyRxDropTrace (originalPacket); return; @@ -922,7 +922,7 @@ EmuNetDevice::SendFrom (Ptr packet, const Address &src, const Address &d ll.sll_family = AF_PACKET; ll.sll_ifindex = m_sll_ifindex; - ll.sll_protocol = htons(ETH_P_ALL); + ll.sll_protocol = htons (ETH_P_ALL); NS_LOG_LOGIC ("calling sendto"); @@ -936,7 +936,7 @@ EmuNetDevice::SendFrom (Ptr packet, const Address &src, const Address &d } void -EmuNetDevice::SetDataRate(DataRate bps) +EmuNetDevice::SetDataRate (DataRate bps) { NS_LOG_FUNCTION (this << bps); NS_FATAL_ERROR ("EmuNetDevice::SetDataRate(): Unable."); @@ -950,7 +950,7 @@ EmuNetDevice::SetQueue (Ptr q) } Ptr -EmuNetDevice::GetQueue(void) const +EmuNetDevice::GetQueue (void) const { NS_LOG_FUNCTION_NOARGS (); return m_queue; @@ -964,13 +964,13 @@ EmuNetDevice::NotifyLinkUp (void) } void -EmuNetDevice::SetIfIndex(const uint32_t index) +EmuNetDevice::SetIfIndex (const uint32_t index) { m_ifIndex = index; } uint32_t -EmuNetDevice::GetIfIndex(void) const +EmuNetDevice::GetIfIndex (void) const { return m_ifIndex; } @@ -1008,12 +1008,12 @@ EmuNetDevice::GetMtu (void) const { struct ifreq ifr; bzero (&ifr, sizeof (ifr)); - strcpy(ifr.ifr_name, m_deviceName.c_str ()); + strcpy (ifr.ifr_name, m_deviceName.c_str ()); - int32_t fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); + int32_t fd = socket (PF_INET, SOCK_DGRAM, IPPROTO_IP); - int32_t rc = ioctl(fd, SIOCGIFMTU, &ifr); + int32_t rc = ioctl (fd, SIOCGIFMTU, &ifr); if (rc == -1) { NS_FATAL_ERROR ("EmuNetDevice::GetMtu(): Can't ioctl SIOCGIFMTU"); @@ -1074,10 +1074,10 @@ EmuNetDevice::GetMulticast (Ipv4Address multicastGroup) const Address EmuNetDevice::GetMulticast (Ipv6Address addr) const { - NS_LOG_FUNCTION(this << addr); + NS_LOG_FUNCTION (this << addr); Mac48Address ad = Mac48Address::GetMulticast (addr); - NS_LOG_LOGIC("MAC IPv6 multicast address is " << ad); + NS_LOG_LOGIC ("MAC IPv6 multicast address is " << ad); return ad; } diff --git a/src/emu/model/emu-net-device.h b/src/emu/model/emu-net-device.h index f329894a6..38b4613d5 100644 --- a/src/emu/model/emu-net-device.h +++ b/src/emu/model/emu-net-device.h @@ -40,6 +40,12 @@ namespace ns3 { class Queue; /** + * \defgroup emu EmuNetDevice + * This section documents the API of the ns-3 emu module. For a generic functional description, please refer to the ns-3 manual. + */ + +/** + * \ingroup emu * \class EmuNetDevice * \brief A Device for an Emu Network Link. */ @@ -110,14 +116,14 @@ public: * * @returns Ptr to the queue. */ - Ptr GetQueue(void) const; + Ptr GetQueue (void) const; // // Pure virtual methods inherited from NetDevice we must implement. // - virtual void SetIfIndex(const uint32_t index); - virtual uint32_t GetIfIndex(void) const; + virtual void SetIfIndex (const uint32_t index); + virtual uint32_t GetIfIndex (void) const; virtual Ptr GetChannel (void) const; @@ -181,9 +187,9 @@ public: */ virtual bool IsBridge (void) const; - virtual bool Send(Ptr packet, const Address &dest, uint16_t protocolNumber); + virtual bool Send (Ptr packet, const Address &dest, uint16_t protocolNumber); - virtual bool SendFrom(Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber); + virtual bool SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber); virtual Ptr GetNode (void) const; virtual void SetNode (Ptr node); @@ -265,7 +271,7 @@ private: * \return Returns true if the packet should be forwarded up the * protocol stack. */ - bool ProcessHeader(Ptr p, uint16_t& param); + bool ProcessHeader (Ptr p, uint16_t& param); /** * Start Sending a Packet Down the Wire. diff --git a/src/emu/model/emu-sock-creator.cc b/src/emu/model/emu-sock-creator.cc index b24f5d39d..f380c3145 100644 --- a/src/emu/model/emu-sock-creator.cc +++ b/src/emu/model/emu-sock-creator.cc @@ -56,7 +56,7 @@ static int gVerbose = 0; #define ABORT_IF(cond, msg, printErrno) \ if (cond) \ { \ - ABORT(msg, printErrno); \ + ABORT (msg, printErrno); \ } /** @@ -131,7 +131,7 @@ SendSocket (const char *path, int fd) // so we call it "control." // size_t msg_size = sizeof(int); - char control[CMSG_SPACE(msg_size)]; + char control[CMSG_SPACE (msg_size)]; // // There is a msghdr that is used to minimize the number of parameters @@ -165,10 +165,10 @@ SendSocket (const char *path, int fd) // the whole package we're sending. // struct cmsghdr *cmsg; - cmsg = CMSG_FIRSTHDR(&msg); + cmsg = CMSG_FIRSTHDR (&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(msg_size); + cmsg->cmsg_len = CMSG_LEN (msg_size); // // We also have to update the controllen in case other stuff is actually // in there we may not be aware of (due to macros). @@ -179,13 +179,13 @@ SendSocket (const char *path, int fd) // Finally, we get a pointer to the start of the ancillary data array and // put our file descriptor in. // - int *fdptr = (int*)(CMSG_DATA(cmsg)); + int *fdptr = (int*)(CMSG_DATA (cmsg)); *fdptr = fd; // // // Actually send the file descriptor back to the emulated net device. // - ssize_t len = sendmsg(sock, &msg, 0); + ssize_t len = sendmsg (sock, &msg, 0); ABORT_IF (len == -1, "Could not send socket back to emu net device", 1); LOG ("sendmsg complete"); @@ -234,7 +234,7 @@ main (int argc, char *argv[]) // single line of code: // LOG ("Creating raw socket"); - int sock = socket (PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); + int sock = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL)); ABORT_IF (sock == -1, "CreateSocket(): Unable to open raw socket", 1); // diff --git a/src/emu/wscript b/src/emu/wscript index 2701a2616..97fa4cb9f 100644 --- a/src/emu/wscript +++ b/src/emu/wscript @@ -16,31 +16,31 @@ def configure(conf): if conf.env['ENABLE_EMU']: blddir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant())) - emucreatordir = os.path.abspath(os.path.join(blddir, "src/devices/emu")) + emucreatordir = os.path.abspath(os.path.join(blddir, "src/emu")) conf.env.append_value('NS3_EXECUTABLE_PATH', emucreatordir) + else: + # Add this module to the list of modules that won't be built + # if they are enabled. + conf.env['MODULES_NOT_BUILT'].append('emu') def build(bld): - module = bld.create_ns3_module('emu', ['network']) - module.source = [ - ] - headers = bld.new_task_gen('ns3header') - headers.module = 'emu' - headers.source = [ - 'doc/emu.h', - ] - + # Don't do anything for this module if emu's not enabled. if not bld.env['ENABLE_EMU']: return - module.source.extend([ + module = bld.create_ns3_module('emu', ['network']) + module.source = [ 'model/emu-net-device.cc', 'model/emu-encode-decode.cc', 'helper/emu-helper.cc', - ]) - headers.source.extend([ + ] + + headers = bld.new_task_gen('ns3header') + headers.module = 'emu' + headers.source = [ 'model/emu-net-device.h', 'helper/emu-helper.h', - ]) + ] obj = bld.create_suid_program('emu-sock-creator') obj.source = [ diff --git a/src/energy/model/rv-battery-model.cc b/src/energy/model/rv-battery-model.cc index 8c5111a23..f9d1dfba0 100644 --- a/src/energy/model/rv-battery-model.cc +++ b/src/energy/model/rv-battery-model.cc @@ -328,7 +328,7 @@ RvBatteryModel::Discharge (double load, Time t) if (m_timeStamps.size () == 1) { // constant load - calculatedAlpha = m_load[0] * RvModelAFunction (t, t, Seconds(0.0), + calculatedAlpha = m_load[0] * RvModelAFunction (t, t, Seconds (0.0), m_beta); } else diff --git a/src/energy/test/basic-energy-model-test.cc b/src/energy/test/basic-energy-model-test.cc index d3e967a2c..64c2aae5f 100644 --- a/src/energy/test/basic-energy-model-test.cc +++ b/src/energy/test/basic-energy-model-test.cc @@ -312,15 +312,15 @@ BasicEnergyDepletionTest::DepletionTestCase (double simTimeS, // ns-3 supports RadioTap and Prism tracing extensions for 802.11b wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - YansWifiChannelHelper wifiChannel ; + YansWifiChannelHelper wifiChannel; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); wifiPhy.SetChannel (wifiChannel.Create ()); // Add a non-QoS upper MAC, and disable rate control NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode", StringValue(phyMode), - "ControlMode", StringValue(phyMode)); + "DataMode", StringValue (phyMode), + "ControlMode", StringValue (phyMode)); // Set it to ad-hoc mode wifiMac.SetType ("ns3::AdhocWifiMac"); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c); diff --git a/src/energy/test/rv-battery-model-test.cc b/src/energy/test/rv-battery-model-test.cc index 8746be652..639a7eb14 100644 --- a/src/energy/test/rv-battery-model-test.cc +++ b/src/energy/test/rv-battery-model-test.cc @@ -721,15 +721,15 @@ BatteryLifetimeTest::ConstantLoadTest (double load, Time expLifetime) // ns-3 supports RadioTap and Prism tracing extensions for 802.11b wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - YansWifiChannelHelper wifiChannel ; + YansWifiChannelHelper wifiChannel; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); wifiPhy.SetChannel (wifiChannel.Create ()); // Add a non-QoS upper MAC, and disable rate control NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode", StringValue(phyMode), - "ControlMode", StringValue(phyMode)); + "DataMode", StringValue (phyMode), + "ControlMode", StringValue (phyMode)); // Set it to ad-hoc mode wifiMac.SetType ("ns3::AdhocWifiMac"); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c); @@ -808,15 +808,15 @@ BatteryLifetimeTest::VariableLoadTest (std::vector loads, // ns-3 supports RadioTap and Prism tracing extensions for 802.11b wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - YansWifiChannelHelper wifiChannel ; + YansWifiChannelHelper wifiChannel; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); wifiPhy.SetChannel (wifiChannel.Create ()); // Add a non-QoS upper MAC, and disable rate control NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode", StringValue(phyMode), - "ControlMode", StringValue(phyMode)); + "DataMode", StringValue (phyMode), + "ControlMode", StringValue (phyMode)); // Set it to ad-hoc mode wifiMac.SetType ("ns3::AdhocWifiMac"); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c); diff --git a/src/flow-monitor/examples/wifi-olsr-flowmon.py b/src/flow-monitor/examples/wifi-olsr-flowmon.py index 9ac6a740d..3befd681a 100644 --- a/src/flow-monitor/examples/wifi-olsr-flowmon.py +++ b/src/flow-monitor/examples/wifi-olsr-flowmon.py @@ -108,6 +108,7 @@ def main(argv): flowmon_helper = ns.flow_monitor.FlowMonitorHelper() #flowmon_helper.SetMonitorAttribute("StartTime", ns.core.TimeValue(ns.core.Seconds(31))) monitor = flowmon_helper.InstallAll() + monitor = flowmon_helper.GetMonitor() monitor.SetAttribute("DelayBinWidth", ns.core.DoubleValue(0.001)) monitor.SetAttribute("JitterBinWidth", ns.core.DoubleValue(0.001)) monitor.SetAttribute("PacketSizeBinWidth", ns.core.DoubleValue(20)) diff --git a/src/flow-monitor/model/flow-monitor.cc b/src/flow-monitor/model/flow-monitor.cc index 328dfd274..0a1c2c2ad 100644 --- a/src/flow-monitor/model/flow-monitor.cc +++ b/src/flow-monitor/model/flow-monitor.cc @@ -203,7 +203,7 @@ FlowMonitor::ReportLastRx (Ptr probe, uint32_t flowId, uint32_t packe else { stats.jitterSum -= jitter; - stats.jitterHistogram.AddValue (-jitter.GetSeconds()); + stats.jitterHistogram.AddValue (-jitter.GetSeconds ()); } } stats.lastDelay = delay; @@ -285,7 +285,7 @@ FlowMonitor::CheckForLostPackets (Time maxDelay) { // packet is considered lost, add it to the loss statistics std::map::iterator - flow = m_flowStats.find (iter->first.first); + flow = m_flowStats.find (iter->first.first); NS_ASSERT (flow != m_flowStats.end ()); flow->second.lostPackets++; @@ -388,48 +388,48 @@ FlowMonitor::SerializeToXmlStream (std::ostream &os, int indent, bool enableHist { CheckForLostPackets (); - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; indent += 2; - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; indent += 2; for (std::map::const_iterator flowI = m_flowStats.begin (); flowI != m_flowStats.end (); flowI++) { - INDENT(indent); + INDENT (indent); #define ATTRIB(name) << " " # name "=\"" << flowI->second.name << "\"" os << "first << "\"" - ATTRIB(timeFirstTxPacket) - ATTRIB(timeFirstRxPacket) - ATTRIB(timeLastTxPacket) - ATTRIB(timeLastRxPacket) - ATTRIB(delaySum) - ATTRIB(jitterSum) - ATTRIB(lastDelay) - ATTRIB(txBytes) - ATTRIB(rxBytes) - ATTRIB(txPackets) - ATTRIB(rxPackets) - ATTRIB(lostPackets) - ATTRIB(timesForwarded) - << ">\n"; + ATTRIB (timeFirstTxPacket) + ATTRIB (timeFirstRxPacket) + ATTRIB (timeLastTxPacket) + ATTRIB (timeLastRxPacket) + ATTRIB (delaySum) + ATTRIB (jitterSum) + ATTRIB (lastDelay) + ATTRIB (txBytes) + ATTRIB (rxBytes) + ATTRIB (txPackets) + ATTRIB (rxPackets) + ATTRIB (lostPackets) + ATTRIB (timesForwarded) + << ">\n"; #undef ATTRIB indent += 2; for (uint32_t reasonCode = 0; reasonCode < flowI->second.packetsDropped.size (); reasonCode++) { - INDENT(indent); + INDENT (indent); os << "second.packetsDropped[reasonCode] - << "\" />\n"; + << " number=\"" << flowI->second.packetsDropped[reasonCode] + << "\" />\n"; } for (uint32_t reasonCode = 0; reasonCode < flowI->second.bytesDropped.size (); reasonCode++) { - INDENT(indent); + INDENT (indent); os << "second.bytesDropped[reasonCode] - << "\" />\n"; + << " bytes=\"" << flowI->second.bytesDropped[reasonCode] + << "\" />\n"; } if (enableHistograms) { @@ -440,27 +440,27 @@ FlowMonitor::SerializeToXmlStream (std::ostream &os, int indent, bool enableHist } indent -= 2; - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; } indent -= 2; - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; m_classifier->SerializeToXmlStream (os, indent); if (enableProbes) { - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; indent += 2; for (uint32_t i = 0; i < m_flowProbes.size (); i++) { m_flowProbes[i]->SerializeToXmlStream (os, indent, i); } indent -= 2; - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; } indent -= 2; - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; } diff --git a/src/flow-monitor/model/flow-probe.cc b/src/flow-monitor/model/flow-probe.cc index d059aec14..a795680c8 100644 --- a/src/flow-monitor/model/flow-probe.cc +++ b/src/flow-monitor/model/flow-probe.cc @@ -69,13 +69,13 @@ FlowProbe::SerializeToXmlStream (std::ostream &os, int indent, uint32_t index) c { #define INDENT(level) for (int __xpto = 0; __xpto < level; __xpto++) os << ' '; - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; indent += 2; for (Stats::const_iterator iter = m_stats.begin (); iter != m_stats.end (); iter++) { - INDENT(indent); + INDENT (indent); os << "first << "\"" << " packets=\"" << iter->second.packets << "\"" @@ -85,23 +85,23 @@ FlowProbe::SerializeToXmlStream (std::ostream &os, int indent, uint32_t index) c indent += 2; for (uint32_t reasonCode = 0; reasonCode < iter->second.packetsDropped.size (); reasonCode++) { - INDENT(indent); + INDENT (indent); os << "second.packetsDropped[reasonCode] << "\" />\n"; } for (uint32_t reasonCode = 0; reasonCode < iter->second.bytesDropped.size (); reasonCode++) { - INDENT(indent); + INDENT (indent); os << "second.bytesDropped[reasonCode] << "\" />\n"; } indent -= 2; - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; } indent -= 2; - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; } diff --git a/src/flow-monitor/model/histogram.cc b/src/flow-monitor/model/histogram.cc index 0927c1025..26c154c9e 100644 --- a/src/flow-monitor/model/histogram.cc +++ b/src/flow-monitor/model/histogram.cc @@ -106,9 +106,9 @@ Histogram::SerializeToXmlStream (std::ostream &os, int indent, std::string eleme { #define INDENT(level) for (int __xpto = 0; __xpto < level; __xpto++) os << ' '; - INDENT(indent); os << "<" << elementName // << " binWidth=\"" << m_binWidth << "\"" - << " nBins=\"" << m_histogram.size () << "\"" - << " >\n"; + INDENT (indent); os << "<" << elementName // << " binWidth=\"" << m_binWidth << "\"" + << " nBins=\"" << m_histogram.size () << "\"" + << " >\n"; indent += 2; #if 1 // two alternative forms of representing bin data, one more verbose than the other one @@ -116,7 +116,7 @@ Histogram::SerializeToXmlStream (std::ostream &os, int indent, std::string eleme { if (m_histogram[index]) { - INDENT(indent); + INDENT (indent); os << " 0) @@ -138,7 +138,7 @@ Histogram::SerializeToXmlStream (std::ostream &os, int indent, std::string eleme os << "\n"; #endif indent -= 2; - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; #undef INDENT } diff --git a/src/flow-monitor/model/ipv4-flow-classifier.cc b/src/flow-monitor/model/ipv4-flow-classifier.cc index 7f40a862c..be5a7784b 100644 --- a/src/flow-monitor/model/ipv4-flow-classifier.cc +++ b/src/flow-monitor/model/ipv4-flow-classifier.cc @@ -176,13 +176,13 @@ Ipv4FlowClassifier::SerializeToXmlStream (std::ostream &os, int indent) const { #define INDENT(level) for (int __xpto = 0; __xpto < level; __xpto++) os << ' '; - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; indent += 2; for (std::map::const_iterator iter = m_flowMap.begin (); iter != m_flowMap.end (); iter++) { - INDENT(indent); + INDENT (indent); os << "second << "\"" << " sourceAddress=\"" << iter->first.sourceAddress << "\"" << " destinationAddress=\"" << iter->first.destinationAddress << "\"" @@ -193,7 +193,7 @@ Ipv4FlowClassifier::SerializeToXmlStream (std::ostream &os, int indent) const } indent -= 2; - INDENT(indent); os << "\n"; + INDENT (indent); os << "\n"; #undef INDENT } diff --git a/src/flow-monitor/test/histogram-test-suite.cc b/src/flow-monitor/test/histogram-test-suite.cc index eedfeb4e7..559af7cb9 100644 --- a/src/flow-monitor/test/histogram-test-suite.cc +++ b/src/flow-monitor/test/histogram-test-suite.cc @@ -41,7 +41,7 @@ HistogramTestCase::HistogramTestCase () void HistogramTestCase::DoRun (void) { - Histogram h0(3.5); + Histogram h0 (3.5); // Testing floating-point bin widths { for (int i=1; i <= 10; i++) diff --git a/src/internet/bindings/modulegen__gcc_ILP32.py b/src/internet/bindings/modulegen__gcc_ILP32.py index ac2f9e5f2..c4f3c5732 100644 --- a/src/internet/bindings/modulegen__gcc_ILP32.py +++ b/src/internet/bindings/modulegen__gcc_ILP32.py @@ -591,6 +591,7 @@ def register_types(module): module.add_container('std::vector< unsigned int >', 'unsigned int', container_type='vector') module.add_container('std::vector< bool >', 'bool', container_type='vector') module.add_container('std::list< ns3::Ptr< ns3::Packet > >', 'ns3::Ptr< ns3::Packet >', container_type='list') + module.add_container('std::map< unsigned int, unsigned int >', ('unsigned int', 'unsigned int'), container_type='map') module.add_container('std::vector< ns3::Ipv6Address >', 'ns3::Ipv6Address', container_type='vector') typehandlers.add_type_alias('ns3::SequenceNumber< short unsigned int, short int >', 'ns3::SequenceNumber16') typehandlers.add_type_alias('ns3::SequenceNumber< short unsigned int, short int >*', 'ns3::SequenceNumber16*') @@ -9428,10 +9429,15 @@ def register_Ns3Ipv4MulticastRoute_methods(root_module, cls): 'ns3::Ipv4Address', [], is_const=True) - ## ipv4-route.h (module 'internet'): uint32_t ns3::Ipv4MulticastRoute::GetOutputTtl(uint32_t oif) const [member function] + ## ipv4-route.h (module 'internet'): uint32_t ns3::Ipv4MulticastRoute::GetOutputTtl(uint32_t oif) [member function] cls.add_method('GetOutputTtl', 'uint32_t', [param('uint32_t', 'oif')], + deprecated=True) + ## ipv4-route.h (module 'internet'): std::map, std::allocator > > ns3::Ipv4MulticastRoute::GetOutputTtlMap() const [member function] + cls.add_method('GetOutputTtlMap', + 'std::map< unsigned int, unsigned int >', + [], is_const=True) ## ipv4-route.h (module 'internet'): uint32_t ns3::Ipv4MulticastRoute::GetParent() const [member function] cls.add_method('GetParent', @@ -10606,10 +10612,15 @@ def register_Ns3Ipv6MulticastRoute_methods(root_module, cls): 'ns3::Ipv6Address', [], is_const=True) - ## ipv6-route.h (module 'internet'): uint32_t ns3::Ipv6MulticastRoute::GetOutputTtl(uint32_t oif) const [member function] + ## ipv6-route.h (module 'internet'): uint32_t ns3::Ipv6MulticastRoute::GetOutputTtl(uint32_t oif) [member function] cls.add_method('GetOutputTtl', 'uint32_t', [param('uint32_t', 'oif')], + deprecated=True) + ## ipv6-route.h (module 'internet'): std::map, std::allocator > > ns3::Ipv6MulticastRoute::GetOutputTtlMap() const [member function] + cls.add_method('GetOutputTtlMap', + 'std::map< unsigned int, unsigned int >', + [], is_const=True) ## ipv6-route.h (module 'internet'): uint32_t ns3::Ipv6MulticastRoute::GetParent() const [member function] cls.add_method('GetParent', diff --git a/src/internet/bindings/modulegen__gcc_LP64.py b/src/internet/bindings/modulegen__gcc_LP64.py index ac2f9e5f2..c4f3c5732 100644 --- a/src/internet/bindings/modulegen__gcc_LP64.py +++ b/src/internet/bindings/modulegen__gcc_LP64.py @@ -591,6 +591,7 @@ def register_types(module): module.add_container('std::vector< unsigned int >', 'unsigned int', container_type='vector') module.add_container('std::vector< bool >', 'bool', container_type='vector') module.add_container('std::list< ns3::Ptr< ns3::Packet > >', 'ns3::Ptr< ns3::Packet >', container_type='list') + module.add_container('std::map< unsigned int, unsigned int >', ('unsigned int', 'unsigned int'), container_type='map') module.add_container('std::vector< ns3::Ipv6Address >', 'ns3::Ipv6Address', container_type='vector') typehandlers.add_type_alias('ns3::SequenceNumber< short unsigned int, short int >', 'ns3::SequenceNumber16') typehandlers.add_type_alias('ns3::SequenceNumber< short unsigned int, short int >*', 'ns3::SequenceNumber16*') @@ -9428,10 +9429,15 @@ def register_Ns3Ipv4MulticastRoute_methods(root_module, cls): 'ns3::Ipv4Address', [], is_const=True) - ## ipv4-route.h (module 'internet'): uint32_t ns3::Ipv4MulticastRoute::GetOutputTtl(uint32_t oif) const [member function] + ## ipv4-route.h (module 'internet'): uint32_t ns3::Ipv4MulticastRoute::GetOutputTtl(uint32_t oif) [member function] cls.add_method('GetOutputTtl', 'uint32_t', [param('uint32_t', 'oif')], + deprecated=True) + ## ipv4-route.h (module 'internet'): std::map, std::allocator > > ns3::Ipv4MulticastRoute::GetOutputTtlMap() const [member function] + cls.add_method('GetOutputTtlMap', + 'std::map< unsigned int, unsigned int >', + [], is_const=True) ## ipv4-route.h (module 'internet'): uint32_t ns3::Ipv4MulticastRoute::GetParent() const [member function] cls.add_method('GetParent', @@ -10606,10 +10612,15 @@ def register_Ns3Ipv6MulticastRoute_methods(root_module, cls): 'ns3::Ipv6Address', [], is_const=True) - ## ipv6-route.h (module 'internet'): uint32_t ns3::Ipv6MulticastRoute::GetOutputTtl(uint32_t oif) const [member function] + ## ipv6-route.h (module 'internet'): uint32_t ns3::Ipv6MulticastRoute::GetOutputTtl(uint32_t oif) [member function] cls.add_method('GetOutputTtl', 'uint32_t', [param('uint32_t', 'oif')], + deprecated=True) + ## ipv6-route.h (module 'internet'): std::map, std::allocator > > ns3::Ipv6MulticastRoute::GetOutputTtlMap() const [member function] + cls.add_method('GetOutputTtlMap', + 'std::map< unsigned int, unsigned int >', + [], is_const=True) ## ipv6-route.h (module 'internet'): uint32_t ns3::Ipv6MulticastRoute::GetParent() const [member function] cls.add_method('GetParent', diff --git a/src/internet/doc/internet.h b/src/internet/doc/internet.h new file mode 100644 index 000000000..7c4a4cfdd --- /dev/null +++ b/src/internet/doc/internet.h @@ -0,0 +1,27 @@ +/* -*- 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 + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef INTERNET_H +#define INTERNET_H + +/** + * \defgroup internet Internet + * + * This section documents the API of the ns-3 internet module. For a generic functional description, please refer to the ns-3 manual. + */ + +#endif /* INTERNET_H */ diff --git a/src/internet/helper/internet-stack-helper.cc b/src/internet/helper/internet-stack-helper.cc index 93c220bdb..152a640b6 100644 --- a/src/internet/helper/internet-stack-helper.cc +++ b/src/internet/helper/internet-stack-helper.cc @@ -424,7 +424,7 @@ Ipv4L3ProtocolRxTxSink (Ptr p, Ptr ipv4, uint32_t interface) } Ptr file = g_interfaceFileMapIpv4[pair]; - file->Write(Simulator::Now(), p); + file->Write (Simulator::Now (), p); } bool @@ -519,7 +519,7 @@ Ipv6L3ProtocolRxTxSink (Ptr p, Ptr ipv6, uint32_t interface) } Ptr file = g_interfaceFileMapIpv6[pair]; - file->Write(Simulator::Now(), p); + file->Write (Simulator::Now (), p); } bool diff --git a/src/internet/helper/internet-stack-helper.h b/src/internet/helper/internet-stack-helper.h index 4a43e650b..eb63dcdc3 100644 --- a/src/internet/helper/internet-stack-helper.h +++ b/src/internet/helper/internet-stack-helper.h @@ -141,7 +141,7 @@ public: * * \param tid the type id, typically it is set to "ns3::TcpL4Protocol" */ - void SetTcp(std::string tid); + void SetTcp (std::string tid); /** * \brief This function is used to setup the Network Simulation Cradle stack with library value. diff --git a/src/internet/helper/internet-trace-helper.cc b/src/internet/helper/internet-trace-helper.cc index 0e5ec7b74..f56d6a7a0 100644 --- a/src/internet/helper/internet-trace-helper.cc +++ b/src/internet/helper/internet-trace-helper.cc @@ -31,7 +31,7 @@ #include "internet-trace-helper.h" -NS_LOG_COMPONENT_DEFINE("InternetTraceHelper"); +NS_LOG_COMPONENT_DEFINE ("InternetTraceHelper"); namespace ns3 { diff --git a/src/internet/helper/ipv4-address-helper.cc b/src/internet/helper/ipv4-address-helper.cc index de273203b..7228f7057 100644 --- a/src/internet/helper/ipv4-address-helper.cc +++ b/src/internet/helper/ipv4-address-helper.cc @@ -26,7 +26,7 @@ #include "ns3/simulator.h" #include "ipv4-address-helper.h" -NS_LOG_COMPONENT_DEFINE("Ipv4AddressHelper"); +NS_LOG_COMPONENT_DEFINE ("Ipv4AddressHelper"); namespace ns3 { @@ -71,8 +71,8 @@ Ipv4AddressHelper::SetBase ( // // Some quick reasonableness testing. // - NS_ASSERT_MSG((m_network & ~m_mask) == 0, - "Ipv4AddressHelper::SetBase(): Inconsistent network and mask"); + NS_ASSERT_MSG ((m_network & ~m_mask) == 0, + "Ipv4AddressHelper::SetBase(): Inconsistent network and mask"); // // Figure out how much to shift network numbers to get them aligned, and what @@ -81,8 +81,8 @@ Ipv4AddressHelper::SetBase ( m_shift = NumAddressBits (m_mask); m_max = (1 << m_shift) - 2; - NS_ASSERT_MSG(m_shift <= 32, - "Ipv4AddressHelper::SetBase(): Unreasonable address length"); + NS_ASSERT_MSG (m_shift <= 32, + "Ipv4AddressHelper::SetBase(): Unreasonable address length"); // // Shift the network down into the normalized position. @@ -177,7 +177,7 @@ Ipv4AddressHelper::NumAddressBits (uint32_t maskbits) const maskbits >>= 1; } - NS_ASSERT_MSG(false, "Ipv4AddressHelper::NumAddressBits(): Bad Mask"); + NS_ASSERT_MSG (false, "Ipv4AddressHelper::NumAddressBits(): Bad Mask"); return 0; } diff --git a/src/internet/helper/ipv4-global-routing-helper.cc b/src/internet/helper/ipv4-global-routing-helper.cc index 1aa64d332..bb95737d5 100644 --- a/src/internet/helper/ipv4-global-routing-helper.cc +++ b/src/internet/helper/ipv4-global-routing-helper.cc @@ -23,7 +23,7 @@ #include "ns3/ipv4-list-routing.h" #include "ns3/log.h" -NS_LOG_COMPONENT_DEFINE("GlobalRoutingHelper"); +NS_LOG_COMPONENT_DEFINE ("GlobalRoutingHelper"); namespace ns3 { diff --git a/src/internet/helper/ipv4-interface-container.cc b/src/internet/helper/ipv4-interface-container.cc index 8df525cc0..fbc184368 100644 --- a/src/internet/helper/ipv4-interface-container.cc +++ b/src/internet/helper/ipv4-interface-container.cc @@ -67,7 +67,7 @@ Ipv4InterfaceContainer::Add (std::string ipv4Name, uint32_t interface) } std::pair, uint32_t> -Ipv4InterfaceContainer::Get(uint32_t i) const +Ipv4InterfaceContainer::Get (uint32_t i) const { return m_interfaces[i]; } diff --git a/src/internet/helper/ipv4-static-routing-helper.cc b/src/internet/helper/ipv4-static-routing-helper.cc index 6c985675a..b0f6ec47a 100644 --- a/src/internet/helper/ipv4-static-routing-helper.cc +++ b/src/internet/helper/ipv4-static-routing-helper.cc @@ -29,7 +29,7 @@ #include "ns3/ipv4-routing-protocol.h" #include "ipv4-static-routing-helper.h" -NS_LOG_COMPONENT_DEFINE("Ipv4StaticRoutingHelper"); +NS_LOG_COMPONENT_DEFINE ("Ipv4StaticRoutingHelper"); namespace ns3 { @@ -101,16 +101,16 @@ Ipv4StaticRoutingHelper::AddMulticastRoute ( { Ptr nd = *i; int32_t interface = ipv4->GetInterfaceForDevice (nd); - NS_ASSERT_MSG(interface >= 0, - "Ipv4StaticRoutingHelper::AddMulticastRoute(): " - "Expected an interface associated with the device nd"); - outputInterfaces.push_back(interface); + NS_ASSERT_MSG (interface >= 0, + "Ipv4StaticRoutingHelper::AddMulticastRoute(): " + "Expected an interface associated with the device nd"); + outputInterfaces.push_back (interface); } int32_t inputInterface = ipv4->GetInterfaceForDevice (input); - NS_ASSERT_MSG(inputInterface >= 0, - "Ipv4StaticRoutingHelper::AddMulticastRoute(): " - "Expected an interface associated with the device input"); + NS_ASSERT_MSG (inputInterface >= 0, + "Ipv4StaticRoutingHelper::AddMulticastRoute(): " + "Expected an interface associated with the device input"); Ipv4StaticRoutingHelper helper; Ptr ipv4StaticRouting = helper.GetStaticRouting (ipv4); if (!ipv4StaticRouting) @@ -166,9 +166,9 @@ Ipv4StaticRoutingHelper::SetDefaultMulticastRoute ( { Ptr ipv4 = n->GetObject (); int32_t interfaceSrc = ipv4->GetInterfaceForDevice (nd); - NS_ASSERT_MSG(interfaceSrc >= 0, - "Ipv4StaticRoutingHelper::SetDefaultMulticastRoute(): " - "Expected an interface associated with the device"); + NS_ASSERT_MSG (interfaceSrc >= 0, + "Ipv4StaticRoutingHelper::SetDefaultMulticastRoute(): " + "Expected an interface associated with the device"); Ipv4StaticRoutingHelper helper; Ptr ipv4StaticRouting = helper.GetStaticRouting (ipv4); if (!ipv4StaticRouting) diff --git a/src/internet/helper/ipv6-interface-container.cc b/src/internet/helper/ipv6-interface-container.cc index 2d3a6d0ad..f22177b59 100644 --- a/src/internet/helper/ipv6-interface-container.cc +++ b/src/internet/helper/ipv6-interface-container.cc @@ -73,7 +73,7 @@ void Ipv6InterfaceContainer::Add (std::string ipv6Name, uint32_t interface) void Ipv6InterfaceContainer::Add (Ipv6InterfaceContainer& c) { - for (InterfaceVector::const_iterator it = c.m_interfaces.begin () ; it != c.m_interfaces.end () ; it++) + for (InterfaceVector::const_iterator it = c.m_interfaces.begin (); it != c.m_interfaces.end (); it++) { m_interfaces.push_back (*it); } @@ -90,7 +90,7 @@ void Ipv6InterfaceContainer::SetRouter (uint32_t i, bool router) /* assume first global address is index 1 (0 is link-local) */ Ipv6Address routerAddress = ipv6->GetAddress (m_interfaces[i].second, 1).GetAddress (); - for (other = 0 ; other < m_interfaces.size () ; other++) + for (other = 0; other < m_interfaces.size (); other++) { if (other != i) { diff --git a/src/internet/model/arp-cache.cc b/src/internet/model/arp-cache.cc index b84401208..44d7f0093 100644 --- a/src/internet/model/arp-cache.cc +++ b/src/internet/model/arp-cache.cc @@ -203,11 +203,11 @@ ArpCache::HandleWaitReplyTimeout (void) entry->GetRetries ()); entry->MarkDead (); entry->ClearRetries (); - Ptr pending = entry->DequeuePending(); + Ptr pending = entry->DequeuePending (); while (pending != 0) { m_dropTrace (pending); - pending = entry->DequeuePending(); + pending = entry->DequeuePending (); } } } diff --git a/src/internet/model/arp-l3-protocol.cc b/src/internet/model/arp-l3-protocol.cc index 29f866814..f780c760e 100644 --- a/src/internet/model/arp-l3-protocol.cc +++ b/src/internet/model/arp-l3-protocol.cc @@ -138,8 +138,8 @@ ArpL3Protocol::FindCache (Ptr device) } void -ArpL3Protocol::Receive(Ptr device, Ptr p, uint16_t protocol, const Address &from, - const Address &to, NetDevice::PacketType packetType) +ArpL3Protocol::Receive (Ptr device, Ptr p, uint16_t protocol, const Address &from, + const Address &to, NetDevice::PacketType packetType) { NS_LOG_FUNCTION (this << device << p->GetSize () << protocol << from << to << packetType); @@ -205,21 +205,21 @@ ArpL3Protocol::Receive(Ptr device, Ptr p, uint16_t prot << " for waiting entry -- flush"); Address from_mac = arp.GetSourceHardwareAddress (); entry->MarkAlive (from_mac); - Ptr pending = entry->DequeuePending(); + Ptr pending = entry->DequeuePending (); while (pending != 0) { cache->GetInterface ()->Send (pending, arp.GetSourceIpv4Address ()); - pending = entry->DequeuePending(); + pending = entry->DequeuePending (); } } else { // ignore this reply which might well be an attempt // at poisening my arp cache. - NS_LOG_LOGIC("node="<GetId ()<<", got reply from " << - arp.GetSourceIpv4Address () << - " for non-waiting entry -- drop"); + NS_LOG_LOGIC ("node="<GetId ()<<", got reply from " << + arp.GetSourceIpv4Address () << + " for non-waiting entry -- drop"); m_dropTrace (packet); } } diff --git a/src/internet/model/arp-l3-protocol.h b/src/internet/model/arp-l3-protocol.h index 0353b5b9d..ebf7fcc00 100644 --- a/src/internet/model/arp-l3-protocol.h +++ b/src/internet/model/arp-l3-protocol.h @@ -61,8 +61,8 @@ public: /** * \brief Receive a packet */ - void Receive(Ptr device, Ptr p, uint16_t protocol, const Address &from, const Address &to, - NetDevice::PacketType packetType); + void Receive (Ptr device, Ptr p, uint16_t protocol, const Address &from, const Address &to, + NetDevice::PacketType packetType); /** * \brief Perform an ARP lookup * \param p diff --git a/src/internet/model/candidate-queue.cc b/src/internet/model/candidate-queue.cc index 8d256c21b..c12bbbec5 100644 --- a/src/internet/model/candidate-queue.cc +++ b/src/internet/model/candidate-queue.cc @@ -50,9 +50,9 @@ operator<< (std::ostream& os, const CandidateQueue& q) for (CIter_t iter = list.begin (); iter != list.end (); iter++) { os << "<" - << (*iter)->GetVertexId () << ", " - << (*iter)->GetDistanceFromRoot () << ", " - << (*iter)->GetVertexType () << ">" << std::endl; + << (*iter)->GetVertexId () << ", " + << (*iter)->GetDistanceFromRoot () << ", " + << (*iter)->GetVertexType () << ">" << std::endl; } os << "*** CandidateQueue End ***"; return os; @@ -143,7 +143,7 @@ CandidateQueue::Find (const Ipv4Address addr) const for (; i != m_candidates.end (); i++) { SPFVertex *v = *i; - if (v->GetVertexId() == addr) + if (v->GetVertexId () == addr) { return v; } diff --git a/src/internet/model/global-route-manager-impl.cc b/src/internet/model/global-route-manager-impl.cc index a7a77610f..68b3bb3b0 100644 --- a/src/internet/model/global-route-manager-impl.cc +++ b/src/internet/model/global-route-manager-impl.cc @@ -296,7 +296,7 @@ SPFVertex::GetRootExitDirection (uint32_t i) const NS_ASSERT_MSG (i < m_ecmpRootExits.size (), "Index out-of-range when accessing SPFVertex::m_ecmpRootExits!"); CIter_t iter = m_ecmpRootExits.begin (); - while (i-- > 0) { iter++;} + while (i-- > 0) { iter++; } return *iter; } @@ -320,7 +320,7 @@ SPFVertex::MergeRootExitDirections (const SPFVertex* vertex) // Append the external list into 'this' and remove duplication afterward const ListOfNodeExit_t& extList = vertex->m_ecmpRootExits; m_ecmpRootExits.insert (m_ecmpRootExits.end (), - extList.begin(), extList.end ()); + extList.begin (), extList.end ()); m_ecmpRootExits.sort (); m_ecmpRootExits.unique (); } @@ -805,7 +805,7 @@ GlobalRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate) if (v->GetVertexType () == SPFVertex::VertexNetwork) { w_lsa = m_lsdb->GetLSAByLinkData - (v->GetLSA ()->GetAttachedRouter (i)); + (v->GetLSA ()->GetAttachedRouter (i)); if (!w_lsa) { continue; @@ -871,7 +871,7 @@ GlobalRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate) } else NS_ASSERT_MSG (0, "SPFNexthopCalculation never " - << "return false, but it does now!"); + << "return false, but it does now!"); } else if (w_lsa->GetStatus () == GlobalRoutingLSA::LSA_SPF_CANDIDATE) { @@ -1313,7 +1313,7 @@ GlobalRouteManagerImpl::CheckForStubNode (Ipv4Address root) FindOutgoingInterfaceId (transitLink->GetLinkData ())); NS_LOG_LOGIC ("Inserting default route for node " << myRouterId << " to next hop " << lr->GetLinkData () << " via interface " << - FindOutgoingInterfaceId(transitLink->GetLinkData())); + FindOutgoingInterfaceId (transitLink->GetLinkData ())); return true; } } @@ -1504,7 +1504,7 @@ GlobalRouteManagerImpl::ProcessASExternals (SPFVertex* v, GlobalRoutingLSA* extl if ((rlsa->GetLinkStateId ()) == (extlsa->GetAdvertisingRouter ())) { NS_LOG_LOGIC ("Found advertising router to destination"); - SPFAddASExternal(extlsa,v); + SPFAddASExternal (extlsa,v); } } for (uint32_t i = 0; i < v->GetNChildren (); i++) @@ -1535,11 +1535,11 @@ GlobalRouteManagerImpl::SPFAddASExternal (GlobalRoutingLSA *extlsa, SPFVertex *v if (v->GetVertexId () == m_spfroot->GetVertexId ()) { NS_LOG_LOGIC ("External is on local host: " - << v->GetVertexId () << "; returning"); + << v->GetVertexId () << "; returning"); return; } NS_LOG_LOGIC ("External is on remote host: " - << extlsa->GetAdvertisingRouter () << "; installing"); + << extlsa->GetAdvertisingRouter () << "; installing"); Ipv4Address routerId = m_spfroot->GetVertexId (); diff --git a/src/internet/model/global-route-manager-impl.h b/src/internet/model/global-route-manager-impl.h index 1ea6114b4..df8da67ae 100644 --- a/src/internet/model/global-route-manager-impl.h +++ b/src/internet/model/global-route-manager-impl.h @@ -617,7 +617,7 @@ public: * ID. * @param lsa A pointer to the Link State Advertisement for the router. */ - void Insert(Ipv4Address addr, GlobalRoutingLSA* lsa); + void Insert (Ipv4Address addr, GlobalRoutingLSA* lsa); /** * @brief Look up the Link State Advertisement associated with the given @@ -773,7 +773,7 @@ private: void SPFIntraAddStub (GlobalRoutingLinkRecord *l, SPFVertex* v); void SPFAddASExternal (GlobalRoutingLSA *extlsa, SPFVertex *v); int32_t FindOutgoingInterfaceId (Ipv4Address a, - Ipv4Mask amask = Ipv4Mask("255.255.255.255")); + Ipv4Mask amask = Ipv4Mask ("255.255.255.255")); }; } // namespace ns3 diff --git a/src/internet/model/global-router-interface.cc b/src/internet/model/global-router-interface.cc index cc770b4d4..1c8160b5b 100644 --- a/src/internet/model/global-router-interface.cc +++ b/src/internet/model/global-router-interface.cc @@ -136,13 +136,13 @@ GlobalRoutingLinkRecord::SetMetric (uint16_t metric) GlobalRoutingLSA::GlobalRoutingLSA() : m_lsType (GlobalRoutingLSA::Unknown), - m_linkStateId("0.0.0.0"), - m_advertisingRtr("0.0.0.0"), - m_linkRecords(), - m_networkLSANetworkMask("0.0.0.0"), - m_attachedRouters(), - m_status(GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED), - m_node_id(0) + m_linkStateId ("0.0.0.0"), + m_advertisingRtr ("0.0.0.0"), + m_linkRecords (), + m_networkLSANetworkMask ("0.0.0.0"), + m_attachedRouters (), + m_status (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED), + m_node_id (0) { NS_LOG_FUNCTION_NOARGS (); } @@ -153,27 +153,27 @@ GlobalRoutingLSA::GlobalRoutingLSA ( Ipv4Address advertisingRtr) : m_lsType (GlobalRoutingLSA::Unknown), - m_linkStateId(linkStateId), - m_advertisingRtr(advertisingRtr), - m_linkRecords(), - m_networkLSANetworkMask("0.0.0.0"), - m_attachedRouters(), - m_status(status), - m_node_id(0) + m_linkStateId (linkStateId), + m_advertisingRtr (advertisingRtr), + m_linkRecords (), + m_networkLSANetworkMask ("0.0.0.0"), + m_attachedRouters (), + m_status (status), + m_node_id (0) { NS_LOG_FUNCTION (this << status << linkStateId << advertisingRtr); } GlobalRoutingLSA::GlobalRoutingLSA (GlobalRoutingLSA& lsa) - : m_lsType(lsa.m_lsType), m_linkStateId(lsa.m_linkStateId), - m_advertisingRtr(lsa.m_advertisingRtr), - m_networkLSANetworkMask(lsa.m_networkLSANetworkMask), - m_status(lsa.m_status), - m_node_id(lsa.m_node_id) + : m_lsType (lsa.m_lsType), m_linkStateId (lsa.m_linkStateId), + m_advertisingRtr (lsa.m_advertisingRtr), + m_networkLSANetworkMask (lsa.m_networkLSANetworkMask), + m_status (lsa.m_status), + m_node_id (lsa.m_node_id) { NS_LOG_FUNCTION_NOARGS (); - NS_ASSERT_MSG(IsEmpty(), - "GlobalRoutingLSA::GlobalRoutingLSA (): Non-empty LSA in constructor"); + NS_ASSERT_MSG (IsEmpty (), + "GlobalRoutingLSA::GlobalRoutingLSA (): Non-empty LSA in constructor"); CopyLinkRecords (lsa); } @@ -209,7 +209,7 @@ GlobalRoutingLSA::CopyLinkRecords (const GlobalRoutingLSA& lsa) pDst->SetLinkData (pSrc->GetLinkData ()); pDst->SetMetric (pSrc->GetMetric ()); - m_linkRecords.push_back(pDst); + m_linkRecords.push_back (pDst); pDst = 0; } @@ -223,7 +223,7 @@ GlobalRoutingLSA::~GlobalRoutingLSA() } void -GlobalRoutingLSA::ClearLinkRecords(void) +GlobalRoutingLSA::ClearLinkRecords (void) { NS_LOG_FUNCTION_NOARGS (); for ( ListOfLinkRecords_t::iterator i = m_linkRecords.begin (); @@ -239,7 +239,7 @@ GlobalRoutingLSA::ClearLinkRecords(void) *i = 0; } NS_LOG_LOGIC ("Clear list"); - m_linkRecords.clear(); + m_linkRecords.clear (); } uint32_t @@ -271,7 +271,7 @@ GlobalRoutingLSA::GetLinkRecord (uint32_t n) const return *i; } } - NS_ASSERT_MSG(false, "GlobalRoutingLSA::GetLinkRecord (): invalid index"); + NS_ASSERT_MSG (false, "GlobalRoutingLSA::GetLinkRecord (): invalid index"); return 0; } @@ -374,8 +374,8 @@ GlobalRoutingLSA::GetAttachedRouter (uint32_t n) const return *i; } } - NS_ASSERT_MSG(false, "GlobalRoutingLSA::GetAttachedRouter (): invalid index"); - return Ipv4Address("0.0.0.0"); + NS_ASSERT_MSG (false, "GlobalRoutingLSA::GetAttachedRouter (): invalid index"); + return Ipv4Address ("0.0.0.0"); } void @@ -486,7 +486,7 @@ GlobalRoutingLSA::Print (std::ostream &os) const } else { - NS_ASSERT_MSG(0, "Illegal LSA LSType: " << m_lsType); + NS_ASSERT_MSG (0, "Illegal LSA LSType: " << m_lsType); } os << "========== End Global Routing LSA ==========" << std::endl; } @@ -514,16 +514,16 @@ GlobalRouter::GetTypeId (void) } GlobalRouter::GlobalRouter () - : m_LSAs() + : m_LSAs () { NS_LOG_FUNCTION_NOARGS (); - m_routerId.Set(GlobalRouteManager::AllocateRouterId ()); + m_routerId.Set (GlobalRouteManager::AllocateRouterId ()); } GlobalRouter::~GlobalRouter () { NS_LOG_FUNCTION_NOARGS (); - ClearLSAs(); + ClearLSAs (); } void @@ -568,7 +568,7 @@ GlobalRouter::ClearLSAs () *i = 0; } NS_LOG_LOGIC ("Clear list of LSAs"); - m_LSAs.clear(); + m_LSAs.clear (); } Ipv4Address @@ -625,7 +625,7 @@ GlobalRouter::DiscoverLSAs () // of devices may include those for stub networks (e.g., ethernets, etc.) and // bridge devices also take up an "extra" net device. // - uint32_t numDevices = node->GetNDevices(); + uint32_t numDevices = node->GetNDevices (); // // Iterate through the devices on the node and walk the channel to see what's @@ -633,7 +633,7 @@ GlobalRouter::DiscoverLSAs () // for (uint32_t i = 0; i < numDevices; ++i) { - Ptr ndLocal = node->GetDevice(i); + Ptr ndLocal = node->GetDevice (i); // // There is an assumption that bridge ports must never have an IP address @@ -644,7 +644,7 @@ GlobalRouter::DiscoverLSAs () { // Initialize to value out of bounds to silence compiler uint32_t interfaceBridge = ipv4Local->GetNInterfaces () + 1; - bool rc = FindInterfaceForDevice(node, ndLocal, interfaceBridge); + bool rc = FindInterfaceForDevice (node, ndLocal, interfaceBridge); NS_ABORT_MSG_IF (rc, "GlobalRouter::DiscoverLSAs(): Bridge ports must not have an IPv4 interface index"); } @@ -693,7 +693,7 @@ GlobalRouter::DiscoverLSAs () } else { - NS_ASSERT_MSG(0, "GlobalRouter::DiscoverLSAs (): unknown link type"); + NS_ASSERT_MSG (0, "GlobalRouter::DiscoverLSAs (): unknown link type"); } } @@ -717,8 +717,8 @@ GlobalRouter::DiscoverLSAs () // Build injected route LSAs as external routes // RFC 2328, section 12.4.4 // - for (InjectedRoutesCI i = m_injectedRoutes.begin(); - i != m_injectedRoutes.end(); + for (InjectedRoutesCI i = m_injectedRoutes.begin (); + i != m_injectedRoutes.end (); i++) { GlobalRoutingLSA *pLSA = new GlobalRoutingLSA; @@ -769,7 +769,7 @@ GlobalRouter::ProcessSingleBroadcastLink (Ptr nd, GlobalRoutingLSA *p // Initialize to value out of bounds to silence compiler uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1; - bool rc = FindInterfaceForDevice(node, nd, interfaceLocal); + bool rc = FindInterfaceForDevice (node, nd, interfaceLocal); NS_ABORT_MSG_IF (rc == false, "GlobalRouter::ProcessSingleBroadcastLink(): No interface index associated with device"); if (ipv4Local->GetNAddresses (interfaceLocal) > 1) @@ -792,23 +792,23 @@ GlobalRouter::ProcessSingleBroadcastLink (Ptr nd, GlobalRoutingLSA *p // // This is a net device connected to a stub network // - NS_LOG_LOGIC("Router-LSA Stub Network"); + NS_LOG_LOGIC ("Router-LSA Stub Network"); plr->SetLinkType (GlobalRoutingLinkRecord::StubNetwork); // // According to OSPF, the Link ID is the IP network number of // the attached network. // - plr->SetLinkId (addrLocal.CombineMask(maskLocal)); + plr->SetLinkId (addrLocal.CombineMask (maskLocal)); // // and the Link Data is the network mask; converted to Ipv4Address // Ipv4Address maskLocalAddr; - maskLocalAddr.Set(maskLocal.Get ()); + maskLocalAddr.Set (maskLocal.Get ()); plr->SetLinkData (maskLocalAddr); plr->SetMetric (metricLocal); - pLSA->AddLinkRecord(plr); + pLSA->AddLinkRecord (plr); plr = 0; } else @@ -889,7 +889,7 @@ GlobalRouter::ProcessBridgedBroadcastLink (Ptr nd, GlobalRoutingLSA * // Initialize to value out of bounds to silence compiler uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1; - bool rc = FindInterfaceForDevice(node, nd, interfaceLocal); + bool rc = FindInterfaceForDevice (node, nd, interfaceLocal); NS_ABORT_MSG_IF (rc == false, "GlobalRouter::ProcessBridgedBroadcastLink(): No interface index associated with device"); if (ipv4Local->GetNAddresses (interfaceLocal) > 1) @@ -965,23 +965,23 @@ GlobalRouter::ProcessBridgedBroadcastLink (Ptr nd, GlobalRoutingLSA * // // This is a net device connected to a bridge of stub networks // - NS_LOG_LOGIC("Router-LSA Stub Network"); + NS_LOG_LOGIC ("Router-LSA Stub Network"); plr->SetLinkType (GlobalRoutingLinkRecord::StubNetwork); // // According to OSPF, the Link ID is the IP network number of // the attached network. // - plr->SetLinkId (addrLocal.CombineMask(maskLocal)); + plr->SetLinkId (addrLocal.CombineMask (maskLocal)); // // and the Link Data is the network mask; converted to Ipv4Address // Ipv4Address maskLocalAddr; - maskLocalAddr.Set(maskLocal.Get ()); + maskLocalAddr.Set (maskLocal.Get ()); plr->SetLinkData (maskLocalAddr); plr->SetMetric (metricLocal); - pLSA->AddLinkRecord(plr); + pLSA->AddLinkRecord (plr); plr = 0; } else @@ -1035,7 +1035,7 @@ GlobalRouter::ProcessPointToPointLink (Ptr ndLocal, GlobalRoutingLSA NS_ABORT_MSG_UNLESS (ipv4Local, "GlobalRouter::ProcessPointToPointLink (): GetObject for interface failed"); uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1; - bool rc = FindInterfaceForDevice(nodeLocal, ndLocal, interfaceLocal); + bool rc = FindInterfaceForDevice (nodeLocal, ndLocal, interfaceLocal); NS_ABORT_MSG_IF (rc == false, "GlobalRouter::ProcessPointToPointLink (): No interface index associated with device"); if (ipv4Local->GetNAddresses (interfaceLocal) > 1) @@ -1051,12 +1051,12 @@ GlobalRouter::ProcessPointToPointLink (Ptr ndLocal, GlobalRoutingLSA // the point-to-point channel we know we have. This is where our adjacent // router (to use OSPF lingo) is running. // - Ptr ch = ndLocal->GetChannel(); + Ptr ch = ndLocal->GetChannel (); // // Get the net device on the other side of the point-to-point channel. // - Ptr ndRemote = GetAdjacent(ndLocal, ch); + Ptr ndRemote = GetAdjacent (ndLocal, ch); // // The adjacent net device is aggregated to a node. We need to ask that net @@ -1065,7 +1065,7 @@ GlobalRouter::ProcessPointToPointLink (Ptr ndLocal, GlobalRoutingLSA // internet stacks; and an assumption that point-to-point links are incompatible // with bridging. // - Ptr nodeRemote = ndRemote->GetNode(); + Ptr nodeRemote = ndRemote->GetNode (); Ptr ipv4Remote = nodeRemote->GetObject (); NS_ABORT_MSG_UNLESS (ipv4Remote, "GlobalRouter::ProcessPointToPointLink(): GetObject for remote failed"); @@ -1084,7 +1084,7 @@ GlobalRouter::ProcessPointToPointLink (Ptr ndLocal, GlobalRoutingLSA // // We're going to need the remote router ID, so we might as well get it now. // - Ipv4Address rtrIdRemote = rtrRemote->GetRouterId(); + Ipv4Address rtrIdRemote = rtrRemote->GetRouterId (); NS_LOG_LOGIC ("Working with remote router " << rtrIdRemote); // @@ -1092,7 +1092,7 @@ GlobalRouter::ProcessPointToPointLink (Ptr ndLocal, GlobalRoutingLSA // net device on the other end of the point-to-point channel. // uint32_t interfaceRemote = ipv4Remote->GetNInterfaces () + 1; - rc = FindInterfaceForDevice(nodeRemote, ndRemote, interfaceRemote); + rc = FindInterfaceForDevice (nodeRemote, ndRemote, interfaceRemote); NS_ABORT_MSG_IF (rc == false, "GlobalRouter::ProcessPointToPointLinks(): No interface index associated with remote device"); // @@ -1132,7 +1132,7 @@ GlobalRouter::ProcessPointToPointLink (Ptr ndLocal, GlobalRoutingLSA NS_ABORT_MSG_IF (plr == 0, "GlobalRouter::ProcessPointToPointLink(): Can't alloc link record"); plr->SetLinkType (GlobalRoutingLinkRecord::StubNetwork); plr->SetLinkId (addrRemote); - plr->SetLinkData (Ipv4Address(maskRemote.Get())); // Frown + plr->SetLinkData (Ipv4Address (maskRemote.Get ())); // Frown plr->SetMetric (metricLocal); pLSA->AddLinkRecord (plr); plr = 0; @@ -1158,7 +1158,7 @@ GlobalRouter::BuildNetworkLSAs (NetDeviceContainer c) NS_ABORT_MSG_UNLESS (ipv4Local, "GlobalRouter::ProcessPointToPointLink (): GetObject for interface failed"); uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1; - bool rc = FindInterfaceForDevice(node, ndLocal, interfaceLocal); + bool rc = FindInterfaceForDevice (node, ndLocal, interfaceLocal); NS_ABORT_MSG_IF (rc == false, "GlobalRouter::BuildNetworkLSAs (): No interface index associated with device"); if (ipv4Local->GetNAddresses (interfaceLocal) > 1) @@ -1183,8 +1183,8 @@ GlobalRouter::BuildNetworkLSAs (NetDeviceContainer c) // and, if we find a node with a GlobalRouter interface and an IPv4 // interface associated with that device, we call it an attached router. // - Ptr ch = ndLocal->GetChannel(); - uint32_t nDevices = ch->GetNDevices(); + Ptr ch = ndLocal->GetChannel (); + uint32_t nDevices = ch->GetNDevices (); NS_ASSERT (nDevices); for (uint32_t i = 0; i < nDevices; i++) @@ -1222,7 +1222,7 @@ GlobalRouter::BuildNetworkLSAs (NetDeviceContainer c) { NS_LOG_WARN ("Warning, interface has multiple IP addresses; using only the primary one"); } - Ipv4Address tempAddr = tempIpv4->GetAddress(tempInterface, 0).GetLocal (); + Ipv4Address tempAddr = tempIpv4->GetAddress (tempInterface, 0).GetLocal (); pLSA->AddAttachedRouter (tempAddr); } } @@ -1243,8 +1243,8 @@ GlobalRouter::FindDesignatedRouterForLink (Ptr ndLocal, bool allowRec { NS_LOG_FUNCTION (ndLocal << allowRecursion); - Ptr ch = ndLocal->GetChannel(); - uint32_t nDevices = ch->GetNDevices(); + Ptr ch = ndLocal->GetChannel (); + uint32_t nDevices = ch->GetNDevices (); NS_ASSERT (nDevices); NS_LOG_LOGIC ("Looking for designated router off of net device " << ndLocal << " on node " << @@ -1293,7 +1293,7 @@ GlobalRouter::FindDesignatedRouterForLink (Ptr ndLocal, bool allowRec { // Initialize to value out of bounds to silence compiler uint32_t interfaceOther = ipv4->GetNInterfaces () + 1; - if (FindInterfaceForDevice(nodeOther, bnd, interfaceOther)) + if (FindInterfaceForDevice (nodeOther, bnd, interfaceOther)) { NS_LOG_LOGIC ("Found router on bridge net device " << bnd); if (!ipv4->IsUp (interfaceOther)) @@ -1347,7 +1347,7 @@ GlobalRouter::FindDesignatedRouterForLink (Ptr ndLocal, bool allowRec { // Initialize to value out of bounds to silence compiler uint32_t interfaceOther = ipv4->GetNInterfaces () + 1; - if (FindInterfaceForDevice(nodeOther, ndOther, interfaceOther)) + if (FindInterfaceForDevice (nodeOther, ndOther, interfaceOther)) { if (!ipv4->IsUp (interfaceOther)) { @@ -1380,13 +1380,13 @@ GlobalRouter::AnotherRouterOnLink (Ptr nd, bool allowRecursion) const { NS_LOG_FUNCTION (nd << allowRecursion); - Ptr ch = nd->GetChannel(); + Ptr ch = nd->GetChannel (); if (!ch) { // It may be that this net device is a stub device, without a channel return false; } - uint32_t nDevices = ch->GetNDevices(); + uint32_t nDevices = ch->GetNDevices (); NS_ASSERT (nDevices); NS_LOG_LOGIC ("Looking for routers off of net device " << nd << " on node " << nd->GetNode ()->GetId ()); @@ -1480,7 +1480,7 @@ bool GlobalRouter::GetLSA (uint32_t n, GlobalRoutingLSA &lsa) const { NS_LOG_FUNCTION_NOARGS (); - NS_ASSERT_MSG(lsa.IsEmpty(), "GlobalRouter::GetLSA (): Must pass empty LSA"); + NS_ASSERT_MSG (lsa.IsEmpty (), "GlobalRouter::GetLSA (): Must pass empty LSA"); // // All of the work was done in GetNumLSAs. All we have to do here is to // walk the list of link state advertisements created there and return the @@ -1555,7 +1555,7 @@ GlobalRouter::RemoveInjectedRoute (uint32_t index) { if (tmp == index) { - NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_injectedRoutes.size()); + NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_injectedRoutes.size ()); delete *i; m_injectedRoutes.erase (i); return; @@ -1590,12 +1590,12 @@ Ptr GlobalRouter::GetAdjacent (Ptr nd, Ptr ch) const { NS_LOG_FUNCTION_NOARGS (); - NS_ASSERT_MSG(ch->GetNDevices() == 2, "GlobalRouter::GetAdjacent (): Channel with other than two devices"); + NS_ASSERT_MSG (ch->GetNDevices () == 2, "GlobalRouter::GetAdjacent (): Channel with other than two devices"); // // This is a point to point channel with two endpoints. Get both of them. // - Ptr nd1 = ch->GetDevice(0); - Ptr nd2 = ch->GetDevice(1); + Ptr nd1 = ch->GetDevice (0); + Ptr nd2 = ch->GetDevice (1); // // One of the endpoints is going to be "us" -- that is the net device attached // to the node on which we're running -- i.e., "nd". The other endpoint (the @@ -1611,8 +1611,8 @@ GlobalRouter::GetAdjacent (Ptr nd, Ptr ch) const } else { - NS_ASSERT_MSG(false, - "GlobalRouter::GetAdjacent (): Wrong or confused channel?"); + NS_ASSERT_MSG (false, + "GlobalRouter::GetAdjacent (): Wrong or confused channel?"); return 0; } } @@ -1628,7 +1628,7 @@ bool GlobalRouter::FindInterfaceForDevice (Ptr node, Ptr nd, uint32_t &index) const { NS_LOG_FUNCTION_NOARGS (); - NS_LOG_LOGIC("For node " << node->GetId () << " for net device " << nd ); + NS_LOG_LOGIC ("For node " << node->GetId () << " for net device " << nd ); Ptr ipv4 = node->GetObject (); if (ipv4 == 0) @@ -1637,9 +1637,9 @@ GlobalRouter::FindInterfaceForDevice (Ptr node, Ptr nd, uint32_ return false; } - for (uint32_t i = 0; i < ipv4->GetNInterfaces(); ++i ) + for (uint32_t i = 0; i < ipv4->GetNInterfaces (); ++i ) { - if (ipv4->GetNetDevice(i) == nd) + if (ipv4->GetNetDevice (i) == nd) { NS_LOG_LOGIC ("Device " << nd << " has associated ipv4 index " << i); index = i; @@ -1660,7 +1660,7 @@ GlobalRouter::NetDeviceIsBridged (Ptr nd) const NS_LOG_FUNCTION (nd); Ptr node = nd->GetNode (); - uint32_t nDevices = node->GetNDevices(); + uint32_t nDevices = node->GetNDevices (); // // There is no bit on a net device that says it is being bridged, so we have @@ -1670,7 +1670,7 @@ GlobalRouter::NetDeviceIsBridged (Ptr nd) const // for (uint32_t i = 0; i < nDevices; ++i) { - Ptr ndTest = node->GetDevice(i); + Ptr ndTest = node->GetDevice (i); NS_LOG_LOGIC ("Examine device " << i << " " << ndTest); if (ndTest->IsBridge ()) diff --git a/src/internet/model/global-router-interface.h b/src/internet/model/global-router-interface.h index 75224f115..cad0b37c3 100644 --- a/src/internet/model/global-router-interface.h +++ b/src/internet/model/global-router-interface.h @@ -109,7 +109,7 @@ public: * * @returns The Ipv4Address corresponding to the Link ID field of the record. */ - Ipv4Address GetLinkId(void) const; + Ipv4Address GetLinkId (void) const; /** * @brief Set the Link ID field of the Global Routing Link Record. @@ -122,7 +122,7 @@ public: * * @param addr An Ipv4Address to store in the Link ID field of the record. */ - void SetLinkId(Ipv4Address addr); + void SetLinkId (Ipv4Address addr); /** * @brief Get the Link Data field of the Global Routing Link Record. @@ -135,7 +135,7 @@ public: * * @returns The Ipv4Address corresponding to the Link Data field of the record. */ - Ipv4Address GetLinkData(void) const; + Ipv4Address GetLinkData (void) const; /** * @brief Set the Link Data field of the Global Routing Link Record. @@ -148,7 +148,7 @@ public: * * @param addr An Ipv4Address to store in the Link Data field of the record. */ - void SetLinkData(Ipv4Address addr); + void SetLinkData (Ipv4Address addr); /** * @brief Get the Link Type field of the Global Routing Link Record. @@ -159,7 +159,7 @@ public: * @see LinkType * @returns The LinkType of the current Global Routing Link Record. */ - LinkType GetLinkType(void) const; + LinkType GetLinkType (void) const; /** * @brief Set the Link Type field of the Global Routing Link Record. @@ -170,7 +170,7 @@ public: * @see LinkType * @param linkType The new LinkType for the current Global Routing Link Record. */ - void SetLinkType(LinkType linkType); + void SetLinkType (LinkType linkType); /** * @brief Get the Metric Data field of the Global Routing Link Record. @@ -183,7 +183,7 @@ public: * * @returns The metric field of the Global Routing Link Record. */ - uint16_t GetMetric(void) const; + uint16_t GetMetric (void) const; /** * @brief Set the Metric Data field of the Global Routing Link Record. @@ -196,7 +196,7 @@ public: * * @param metric The new metric for the current Global Routing Link Record. */ - void SetMetric(uint16_t metric); + void SetMetric (uint16_t metric); private: /** @@ -363,7 +363,7 @@ public: * @brief Release all of the Global Routing Link Records present in the Global * Routing Link State Advertisement and make the list of link records empty. */ - void ClearLinkRecords(void); + void ClearLinkRecords (void); /** * @brief Check to see if the list of Global Routing Link Records present in the @@ -371,7 +371,7 @@ public: * * @returns True if the list is empty, false otherwise. */ - bool IsEmpty(void) const; + bool IsEmpty (void) const; /** * @brief Print the contents of the Global Routing Link State Advertisement and @@ -711,8 +711,8 @@ private: virtual ~GlobalRouter (); void ClearLSAs (void); - Ptr GetAdjacent(Ptr nd, Ptr ch) const; - bool FindInterfaceForDevice(Ptr node, Ptr nd, uint32_t &index) const; + Ptr GetAdjacent (Ptr nd, Ptr ch) const; + bool FindInterfaceForDevice (Ptr node, Ptr nd, uint32_t &index) const; Ipv4Address FindDesignatedRouterForLink (Ptr ndLocal, bool allowRecursion) const; bool AnotherRouterOnLink (Ptr nd, bool allowRecursion) const; void ProcessBroadcastLink (Ptr nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c); diff --git a/src/internet/model/icmpv4-l4-protocol.cc b/src/internet/model/icmpv4-l4-protocol.cc index e9272a2f9..948814f4b 100644 --- a/src/internet/model/icmpv4-l4-protocol.cc +++ b/src/internet/model/icmpv4-l4-protocol.cc @@ -63,7 +63,7 @@ Icmpv4L4Protocol::NotifyNewAggregate () ipv4->Insert (this); Ptr rawFactory = CreateObject (); ipv4->AggregateObject (rawFactory); - this->SetDownTarget (MakeCallback(&Ipv4L3Protocol::Send, ipv4)); + this->SetDownTarget (MakeCallback (&Ipv4L3Protocol::Send, ipv4)); } } } @@ -220,9 +220,9 @@ Icmpv4L4Protocol::HandleTimeExceeded (Ptr p, } enum Ipv4L4Protocol::RxStatus -Icmpv4L4Protocol::Receive(Ptr p, - Ipv4Header const &header, - Ptr incomingInterface) +Icmpv4L4Protocol::Receive (Ptr p, + Ipv4Header const &header, + Ptr incomingInterface) { NS_LOG_FUNCTION (this << p << header << incomingInterface); diff --git a/src/internet/model/icmpv4-l4-protocol.h b/src/internet/model/icmpv4-l4-protocol.h index 9571cd7f2..e1976a020 100644 --- a/src/internet/model/icmpv4-l4-protocol.h +++ b/src/internet/model/icmpv4-l4-protocol.h @@ -24,9 +24,9 @@ public: static uint16_t GetStaticProtocolNumber (void); virtual int GetProtocolNumber (void) const; - virtual enum Ipv4L4Protocol::RxStatus Receive(Ptr p, - Ipv4Header const &header, - Ptr incomingInterface); + virtual enum Ipv4L4Protocol::RxStatus Receive (Ptr p, + Ipv4Header const &header, + Ptr incomingInterface); void SendDestUnreachFragNeeded (Ipv4Header header, Ptr orgData, uint16_t nextHopMtu); void SendTimeExceededTtl (Ipv4Header header, Ptr orgData); diff --git a/src/internet/model/icmpv6-l4-protocol.cc b/src/internet/model/icmpv6-l4-protocol.cc index 3f059b9a5..cc4746a23 100644 --- a/src/internet/model/icmpv6-l4-protocol.cc +++ b/src/internet/model/icmpv6-l4-protocol.cc @@ -90,7 +90,7 @@ Icmpv6L4Protocol::~Icmpv6L4Protocol () void Icmpv6L4Protocol::DoDispose () { NS_LOG_FUNCTION_NOARGS (); - for (CacheList::const_iterator it = m_cacheList.begin () ; it != m_cacheList.end () ; it++) + for (CacheList::const_iterator it = m_cacheList.begin (); it != m_cacheList.end (); it++) { Ptr cache = *it; cache->Dispose (); @@ -413,7 +413,7 @@ void Icmpv6L4Protocol::HandleNS (Ptr packet, Ipv6Address const &src, Ipv Ipv6Address target = nsHeader.GetIpv6Target (); - for (i = 0 ; i < nb ; i++) + for (i = 0; i < nb; i++) { ifaddr = interface->GetAddress (i); @@ -558,7 +558,7 @@ void Icmpv6L4Protocol::HandleNA (Ptr packet, Ipv6Address const &src, Ipv uint32_t i = 0; uint32_t nb = 0; - for (i = 0 ; i < nb ; i++) + for (i = 0; i < nb; i++) { if (ifaddr.GetAddress () == target) { @@ -1093,7 +1093,7 @@ Ptr Icmpv6L4Protocol::FindCache (Ptr device) { NS_LOG_FUNCTION (this << device); - for (CacheList::const_iterator i = m_cacheList.begin () ; i != m_cacheList.end () ; i++) + for (CacheList::const_iterator i = m_cacheList.begin (); i != m_cacheList.end (); i++) { if ((*i)->GetDevice () == device) { @@ -1209,7 +1209,7 @@ void Icmpv6L4Protocol::FunctionDadTimeout (Ptr icmpv6, Ipv6Int uint32_t i = 0; uint32_t nb = interface->GetNAddresses (); - for (i = 0 ; i < nb ; i++) + for (i = 0; i < nb; i++) { ifaddr = interface->GetAddress (i); diff --git a/src/internet/model/ipv4-address-generator.cc b/src/internet/model/ipv4-address-generator.cc index c6dbfa858..4703167d1 100644 --- a/src/internet/model/ipv4-address-generator.cc +++ b/src/internet/model/ipv4-address-generator.cc @@ -23,7 +23,7 @@ #include "ns3/simulation-singleton.h" #include "ipv4-address-generator.h" -NS_LOG_COMPONENT_DEFINE("Ipv4AddressGenerator"); +NS_LOG_COMPONENT_DEFINE ("Ipv4AddressGenerator"); namespace ns3 { @@ -330,7 +330,7 @@ Ipv4AddressGeneratorImpl::AddAllocated (const Ipv4Address address) Entry entry; entry.addrLow = entry.addrHigh = addr; - m_entries.insert(i, entry); + m_entries.insert (i, entry); return true; } @@ -367,7 +367,7 @@ Ipv4AddressGeneratorImpl::MaskToIndex (Ipv4Mask mask) const } maskBits >>= 1; } - NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible"); + NS_ASSERT_MSG (false, "Ipv4AddressGenerator::MaskToIndex(): Impossible"); return 0; } diff --git a/src/internet/model/ipv4-end-point-demux.cc b/src/internet/model/ipv4-end-point-demux.cc index 99a94bb66..0ae869f0f 100644 --- a/src/internet/model/ipv4-end-point-demux.cc +++ b/src/internet/model/ipv4-end-point-demux.cc @@ -180,7 +180,7 @@ Ipv4EndPointDemux::GetAllEndPoints (void) for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) { Ipv4EndPoint* endP = *i; - ret.push_back(endP); + ret.push_back (endP); } return ret; } @@ -245,15 +245,15 @@ Ipv4EndPointDemux::Lookup (Ipv4Address daddr, uint16_t dport, bool isBroadcast = (daddr.IsBroadcast () || subnetDirected == true); NS_LOG_DEBUG ("dest addr " << daddr << " broadcast? " << isBroadcast); bool localAddressMatchesWildCard = - endP->GetLocalAddress() == Ipv4Address::GetAny(); + endP->GetLocalAddress () == Ipv4Address::GetAny (); bool localAddressMatchesExact = endP->GetLocalAddress () == daddr; if (isBroadcast) { - NS_LOG_DEBUG("Found bcast, localaddr " << endP->GetLocalAddress()); + NS_LOG_DEBUG ("Found bcast, localaddr " << endP->GetLocalAddress ()); } - if (isBroadcast && (endP->GetLocalAddress() != Ipv4Address::GetAny())) + if (isBroadcast && (endP->GetLocalAddress () != Ipv4Address::GetAny ())) { localAddressMatchesExact = (endP->GetLocalAddress () == incomingInterfaceAddr); @@ -262,10 +262,10 @@ Ipv4EndPointDemux::Lookup (Ipv4Address daddr, uint16_t dport, if (!(localAddressMatchesExact || localAddressMatchesWildCard)) continue; bool remotePeerMatchesExact = endP->GetPeerPort () == sport; - bool remotePeerMatchesWildCard = endP->GetPeerPort() == 0; + bool remotePeerMatchesWildCard = endP->GetPeerPort () == 0; bool remoteAddressMatchesExact = endP->GetPeerAddress () == saddr; bool remoteAddressMatchesWildCard = endP->GetPeerAddress () == - Ipv4Address::GetAny(); + Ipv4Address::GetAny (); // If remote does not match either with exact or wildcard, // skip this one if (!(remotePeerMatchesExact || remotePeerMatchesWildCard)) @@ -278,32 +278,32 @@ Ipv4EndPointDemux::Lookup (Ipv4Address daddr, uint16_t dport, remotePeerMatchesWildCard && remoteAddressMatchesWildCard) { // Only local port matches exactly - retval1.push_back(endP); + retval1.push_back (endP); } if ((localAddressMatchesExact || (isBroadcast && localAddressMatchesWildCard))&& remotePeerMatchesWildCard && remoteAddressMatchesWildCard) { // Only local port and local address matches exactly - retval2.push_back(endP); + retval2.push_back (endP); } if (localAddressMatchesWildCard && remotePeerMatchesExact && remoteAddressMatchesExact) { // All but local address - retval3.push_back(endP); + retval3.push_back (endP); } if (localAddressMatchesExact && remotePeerMatchesExact && remoteAddressMatchesExact) { // All 4 match - retval4.push_back(endP); + retval4.push_back (endP); } } // Here we find the most exact match - if (!retval4.empty()) return retval4; - if (!retval3.empty()) return retval3; - if (!retval2.empty()) return retval2; + if (!retval4.empty ()) return retval4; + if (!retval3.empty ()) return retval3; + if (!retval2.empty ()) return retval2; return retval1; // might be empty if no matches } diff --git a/src/internet/model/ipv4-global-routing.cc b/src/internet/model/ipv4-global-routing.cc index d300ecb1e..e35d93e58 100644 --- a/src/internet/model/ipv4-global-routing.cc +++ b/src/internet/model/ipv4-global-routing.cc @@ -43,12 +43,12 @@ Ipv4GlobalRouting::GetTypeId (void) .SetParent () .AddAttribute ("RandomEcmpRouting", "Set to true if packets are randomly routed among ECMP; set to false for using only one route consistently", - BooleanValue(false), + BooleanValue (false), MakeBooleanAccessor (&Ipv4GlobalRouting::m_randomEcmpRouting), MakeBooleanChecker ()) .AddAttribute ("RespondToInterfaceEvents", "Set to true if you want to dynamically recompute the global routes upon Interface notification events (up/down, or add/remove address)", - BooleanValue(false), + BooleanValue (false), MakeBooleanAccessor (&Ipv4GlobalRouting::m_respondToInterfaceEvents), MakeBooleanChecker ()) ; @@ -152,7 +152,7 @@ Ipv4GlobalRouting::LookupGlobal (Ipv4Address dest, Ptr oif) { if (oif != 0) { - if (oif != m_ipv4->GetNetDevice((*i)->GetInterface ())) + if (oif != m_ipv4->GetNetDevice ((*i)->GetInterface ())) { NS_LOG_LOGIC ("Not on requested interface, skipping"); continue; @@ -175,7 +175,7 @@ Ipv4GlobalRouting::LookupGlobal (Ipv4Address dest, Ptr oif) { if (oif != 0) { - if (oif != m_ipv4->GetNetDevice((*j)->GetInterface ())) + if (oif != m_ipv4->GetNetDevice ((*j)->GetInterface ())) { NS_LOG_LOGIC ("Not on requested interface, skipping"); continue; @@ -199,7 +199,7 @@ Ipv4GlobalRouting::LookupGlobal (Ipv4Address dest, Ptr oif) NS_LOG_LOGIC ("Found external route" << *k); if (oif != 0) { - if (oif != m_ipv4->GetNetDevice((*k)->GetInterface ())) + if (oif != m_ipv4->GetNetDevice ((*k)->GetInterface ())) { NS_LOG_LOGIC ("Not on requested interface, skipping"); continue; @@ -229,7 +229,7 @@ Ipv4GlobalRouting::LookupGlobal (Ipv4Address dest, Ptr oif) rtentry = Create (); rtentry->SetDestination (route->GetDest ()); // XXX handle multi-address case - rtentry->SetSource (m_ipv4->GetAddress (route->GetInterface(), 0).GetLocal ()); + rtentry->SetSource (m_ipv4->GetAddress (route->GetInterface (), 0).GetLocal ()); rtentry->SetGateway (route->GetGateway ()); uint32_t interfaceIdx = route->GetInterface (); rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx)); @@ -272,7 +272,7 @@ Ipv4GlobalRouting::GetRoute (uint32_t index) const } index -= m_hostRoutes.size (); uint32_t tmp = 0; - if (index < m_networkRoutes.size()) + if (index < m_networkRoutes.size ()) { for (NetworkRoutesCI j = m_networkRoutes.begin (); j != m_networkRoutes.end (); @@ -285,7 +285,7 @@ Ipv4GlobalRouting::GetRoute (uint32_t index) const tmp++; } } - index -= m_networkRoutes.size(); + index -= m_networkRoutes.size (); tmp = 0; for (ASExternalRoutesCI k = m_ASexternalRoutes.begin (); k != m_ASexternalRoutes.end (); @@ -314,10 +314,10 @@ Ipv4GlobalRouting::RemoveRoute (uint32_t index) { if (tmp == index) { - NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_hostRoutes.size()); + NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_hostRoutes.size ()); delete *i; m_hostRoutes.erase (i); - NS_LOG_LOGIC ("Done removing host route " << index << "; host route remaining size = " << m_hostRoutes.size()); + NS_LOG_LOGIC ("Done removing host route " << index << "; host route remaining size = " << m_hostRoutes.size ()); return; } tmp++; @@ -331,10 +331,10 @@ Ipv4GlobalRouting::RemoveRoute (uint32_t index) { if (tmp == index) { - NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_networkRoutes.size()); + NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_networkRoutes.size ()); delete *j; m_networkRoutes.erase (j); - NS_LOG_LOGIC ("Done removing network route " << index << "; network route remaining size = " << m_networkRoutes.size()); + NS_LOG_LOGIC ("Done removing network route " << index << "; network route remaining size = " << m_networkRoutes.size ()); return; } tmp++; @@ -347,10 +347,10 @@ Ipv4GlobalRouting::RemoveRoute (uint32_t index) { if (tmp == index) { - NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_ASexternalRoutes.size()); + NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_ASexternalRoutes.size ()); delete *k; m_ASexternalRoutes.erase (k); - NS_LOG_LOGIC ("Done removing network route " << index << "; network route remaining size = " << m_networkRoutes.size()); + NS_LOG_LOGIC ("Done removing network route " << index << "; network route remaining size = " << m_networkRoutes.size ()); return; } tmp++; @@ -386,9 +386,9 @@ Ipv4GlobalRouting::DoDispose (void) // Formatted like output of "route -n" command void -Ipv4GlobalRouting::PrintRoutingTable(Ptr stream) const +Ipv4GlobalRouting::PrintRoutingTable (Ptr stream) const { - std::ostream* os = stream->GetStream(); + std::ostream* os = stream->GetStream (); if (GetNRoutes () > 0) { *os << "Destination Gateway Genmask Flags Metric Ref Use Iface" << std::endl; @@ -397,11 +397,11 @@ Ipv4GlobalRouting::PrintRoutingTable(Ptr stream) const std::ostringstream dest, gw, mask, flags; Ipv4RoutingTableEntry route = GetRoute (j); dest << route.GetDest (); - *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str(); + *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str (); gw << route.GetGateway (); - *os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str(); + *os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str (); mask << route.GetDestNetworkMask (); - *os << std::setiosflags (std::ios::left) << std::setw (16) << mask.str(); + *os << std::setiosflags (std::ios::left) << std::setw (16) << mask.str (); flags << "U"; if (route.IsHost ()) { @@ -411,7 +411,7 @@ Ipv4GlobalRouting::PrintRoutingTable(Ptr stream) const { flags << "G"; } - *os << std::setiosflags (std::ios::left) << std::setw (6) << flags.str(); + *os << std::setiosflags (std::ios::left) << std::setw (6) << flags.str (); // Metric not implemented *os << "-" << " "; // Ref ct not implemented @@ -424,7 +424,7 @@ Ipv4GlobalRouting::PrintRoutingTable(Ptr stream) const } else { - *os << route.GetInterface(); + *os << route.GetInterface (); } *os << std::endl; } @@ -439,7 +439,7 @@ Ipv4GlobalRouting::RouteOutput (Ptr p, const Ipv4Header &header, Ptr ipv4) { - NS_LOG_FUNCTION(this << ipv4); + NS_LOG_FUNCTION (this << ipv4); NS_ASSERT (m_ipv4 == 0 && ipv4 != 0); m_ipv4 = ipv4; } diff --git a/src/internet/model/ipv4-header.cc b/src/internet/model/ipv4-header.cc index 9ac20b492..5b70d3297 100644 --- a/src/internet/model/ipv4-header.cc +++ b/src/internet/model/ipv4-header.cc @@ -38,7 +38,7 @@ Ipv4Header::Ipv4Header () m_protocol (0), m_flags (0), m_fragmentOffset (0), - m_checksum(0), + m_checksum (0), m_goodChecksum (true) { } @@ -268,7 +268,7 @@ Ipv4Header::Serialize (Buffer::Iterator start) const if (m_calcChecksum) { i = start; - uint16_t checksum = i.CalculateIpChecksum(20); + uint16_t checksum = i.CalculateIpChecksum (20); NS_LOG_LOGIC ("checksum=" <IsMulticast (), - "ArpIpv4Interface::SendTo (): Sending multicast packet over " - "non-multicast device"); + NS_ASSERT_MSG (m_device->IsMulticast (), + "ArpIpv4Interface::SendTo (): Sending multicast packet over " + "non-multicast device"); - hardwareDestination = m_device->GetMulticast(dest); + hardwareDestination = m_device->GetMulticast (dest); found = true; } else @@ -282,7 +282,7 @@ uint32_t Ipv4Interface::GetNAddresses (void) const { NS_LOG_FUNCTION_NOARGS (); - return m_ifaddrs.size(); + return m_ifaddrs.size (); } bool diff --git a/src/internet/model/ipv4-interface.h b/src/internet/model/ipv4-interface.h index 7e9e1646c..3a49e05ec 100644 --- a/src/internet/model/ipv4-interface.h +++ b/src/internet/model/ipv4-interface.h @@ -127,7 +127,7 @@ public: * This method will eventually call the private * SendTo method which must be implemented by subclasses. */ - void Send(Ptr p, Ipv4Address dest); + void Send (Ptr p, Ipv4Address dest); /** * \param address The Ipv4InterfaceAddress to add to the interface diff --git a/src/internet/model/ipv4-l3-protocol.cc b/src/internet/model/ipv4-l3-protocol.cc index 92d6c1e5c..d29b387c9 100644 --- a/src/internet/model/ipv4-l3-protocol.cc +++ b/src/internet/model/ipv4-l3-protocol.cc @@ -93,14 +93,14 @@ Ipv4L3Protocol::~Ipv4L3Protocol () } void -Ipv4L3Protocol::Insert(Ptr protocol) +Ipv4L3Protocol::Insert (Ptr protocol) { m_protocols.push_back (protocol); } Ptr -Ipv4L3Protocol::GetProtocol(int protocolNumber) const +Ipv4L3Protocol::GetProtocol (int protocolNumber) const { - for (L4List_t::const_iterator i = m_protocols.begin(); i != m_protocols.end(); ++i) + for (L4List_t::const_iterator i = m_protocols.begin (); i != m_protocols.end (); ++i) { if ((*i)->GetProtocolNumber () == protocolNumber) { @@ -185,7 +185,7 @@ void Ipv4L3Protocol::DoDispose (void) { NS_LOG_FUNCTION (this); - for (L4List_t::iterator i = m_protocols.begin(); i != m_protocols.end(); ++i) + for (L4List_t::iterator i = m_protocols.begin (); i != m_protocols.end (); ++i) { *i = 0; } @@ -410,8 +410,8 @@ Ipv4L3Protocol::IsDestinationAddress (Ipv4Address address, uint32_t iif) const } void -Ipv4L3Protocol::Receive( Ptr device, Ptr p, uint16_t protocol, const Address &from, - const Address &to, NetDevice::PacketType packetType) +Ipv4L3Protocol::Receive ( Ptr device, Ptr p, uint16_t protocol, const Address &from, + const Address &to, NetDevice::PacketType packetType) { NS_LOG_FUNCTION (this << &device << p << protocol << from); @@ -523,7 +523,7 @@ Ipv4L3Protocol::Send (Ptr packet, uint8_t protocol, Ptr route) { - NS_LOG_FUNCTION (this << packet << source << destination << uint32_t(protocol) << route); + NS_LOG_FUNCTION (this << packet << source << destination << uint32_t (protocol) << route); Ipv4Header ipHeader; bool mayFragment = true; @@ -554,7 +554,7 @@ Ipv4L3Protocol::Send (Ptr packet, Ptr outInterface = *ifaceIter; Ptr packetCopy = packet->Copy (); - NS_ASSERT (packetCopy->GetSize () <= outInterface->GetDevice()->GetMtu ()); + NS_ASSERT (packetCopy->GetSize () <= outInterface->GetDevice ()->GetMtu ()); m_sendOutgoingTrace (ipHeader, packetCopy, ifaceIndex); packetCopy->AddHeader (ipHeader); @@ -740,10 +740,10 @@ Ipv4L3Protocol::IpMulticastForward (Ptr mrtentry, PtrGetId ()); - std::map ttlMap = mrtentry->GetOutputTtlMap(); + std::map ttlMap = mrtentry->GetOutputTtlMap (); std::map::iterator mapIter; - for (mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++) + for (mapIter = ttlMap.begin (); mapIter != ttlMap.end (); mapIter++) { uint32_t interfaceId = mapIter->first; //uint32_t outputTtl = mapIter->second; // Unused for now @@ -831,7 +831,7 @@ Ipv4L3Protocol::LocalDeliver (Ptr packet, Ipv4Header const&ip, uin for (uint32_t i = 0; i < GetNAddresses (iif); i++) { Ipv4InterfaceAddress addr = GetAddress (iif, i); - if (addr.GetLocal ().CombineMask (addr.GetMask ()) == ip.GetDestination().CombineMask (addr.GetMask ()) && + if (addr.GetLocal ().CombineMask (addr.GetMask ()) == ip.GetDestination ().CombineMask (addr.GetMask ()) && ip.GetDestination ().IsSubnetDirectedBroadcast (addr.GetMask ())) { subnetDirected = true; diff --git a/src/internet/model/ipv4-l3-protocol.h b/src/internet/model/ipv4-l3-protocol.h index 6add4354b..4d9466624 100644 --- a/src/internet/model/ipv4-l3-protocol.h +++ b/src/internet/model/ipv4-l3-protocol.h @@ -106,7 +106,7 @@ public: * a working L4 Protocol and returned from this method. * The caller does not get ownership of the returned pointer. */ - void Insert(Ptr protocol); + void Insert (Ptr protocol); /** * \param protocolNumber number of protocol to lookup * in this L4 Demux @@ -116,7 +116,7 @@ public: * to forward packets up the stack to the right protocol. * It is also called from NodeImpl::GetUdp for example. */ - Ptr GetProtocol(int protocolNumber) const; + Ptr GetProtocol (int protocolNumber) const; /** * \param protocol protocol to remove from this demux. * @@ -146,8 +146,8 @@ public: * \param to address of the destination * \param packetType type of the packet */ - void Receive( Ptr device, Ptr p, uint16_t protocol, const Address &from, - const Address &to, NetDevice::PacketType packetType); + void Receive ( Ptr device, Ptr p, uint16_t protocol, const Address &from, + const Address &to, NetDevice::PacketType packetType); /** * \param packet packet to send diff --git a/src/internet/model/ipv4-l4-protocol.h b/src/internet/model/ipv4-l4-protocol.h index b2cde5efc..0ebdab8de 100644 --- a/src/internet/model/ipv4-l4-protocol.h +++ b/src/internet/model/ipv4-l4-protocol.h @@ -68,9 +68,9 @@ public: * Called from lower-level layers to send the packet up * in the stack. */ - virtual enum RxStatus Receive(Ptr p, - Ipv4Header const &header, - Ptr incomingInterface) = 0; + virtual enum RxStatus Receive (Ptr p, + Ipv4Header const &header, + Ptr incomingInterface) = 0; /** * \param icmpSource the source address of the icmp message diff --git a/src/internet/model/ipv4-list-routing.cc b/src/internet/model/ipv4-list-routing.cc index 151de9b45..1b7516505 100644 --- a/src/internet/model/ipv4-list-routing.cc +++ b/src/internet/model/ipv4-list-routing.cc @@ -72,7 +72,7 @@ void Ipv4ListRouting::PrintRoutingTable (Ptr stream) const { *stream->GetStream () << "Node: " << m_ipv4->GetObject ()->GetId () - << " Time: " << Simulator::Now().GetSeconds () << "s " + << " Time: " << Simulator::Now ().GetSeconds () << "s " << "Ipv4ListRouting table" << std::endl; for (Ipv4RoutingProtocolList::const_iterator i = m_routingProtocols.begin (); i != m_routingProtocols.end (); i++) @@ -142,7 +142,7 @@ Ipv4ListRouting::RouteInput (Ptr p, const Ipv4Header &header, Ptr< NS_LOG_LOGIC ("Address "<< header.GetDestination () << " is a match for local delivery"); if (header.GetDestination ().IsMulticast ()) { - Ptr packetCopy = p->Copy(); + Ptr packetCopy = p->Copy (); lcb (packetCopy, header, iif); retVal = true; // Fall through @@ -210,7 +210,7 @@ Ipv4ListRouting::NotifyInterfaceDown (uint32_t interface) void Ipv4ListRouting::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address) { - NS_LOG_FUNCTION(this << interface << address); + NS_LOG_FUNCTION (this << interface << address); for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); @@ -222,7 +222,7 @@ Ipv4ListRouting::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress addr void Ipv4ListRouting::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address) { - NS_LOG_FUNCTION(this << interface << address); + NS_LOG_FUNCTION (this << interface << address); for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin (); rprotoIter != m_routingProtocols.end (); @@ -234,7 +234,7 @@ Ipv4ListRouting::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress a void Ipv4ListRouting::SetIpv4 (Ptr ipv4) { - NS_LOG_FUNCTION(this << ipv4); + NS_LOG_FUNCTION (this << ipv4); NS_ASSERT (m_ipv4 == 0); for (Ipv4RoutingProtocolList::const_iterator rprotoIter = m_routingProtocols.begin (); diff --git a/src/internet/model/ipv4-raw-socket-impl.cc b/src/internet/model/ipv4-raw-socket-impl.cc index 955ba6290..043c39523 100644 --- a/src/internet/model/ipv4-raw-socket-impl.cc +++ b/src/internet/model/ipv4-raw-socket-impl.cc @@ -235,7 +235,7 @@ Ipv4RawSocketImpl::SendTo (Ptr p, uint32_t flags, } NotifyDataSent (p->GetSize ()); NotifySend (GetTxAvailable ()); - return p->GetSize(); + return p->GetSize (); } else { diff --git a/src/internet/model/ipv4-route.cc b/src/internet/model/ipv4-route.cc index 7a6c0c867..278b1d08c 100644 --- a/src/internet/model/ipv4-route.cc +++ b/src/internet/model/ipv4-route.cc @@ -83,7 +83,7 @@ std::ostream& operator<< (std::ostream& os, Ipv4Route const& route) Ipv4MulticastRoute::Ipv4MulticastRoute () { - m_ttls.clear(); + m_ttls.clear (); } void @@ -129,10 +129,10 @@ Ipv4MulticastRoute::SetOutputTtl (uint32_t oif, uint32_t ttl) { // This TTL value effectively disables the interface std::map::iterator iter; - iter = m_ttls.find(oif); - if (iter != m_ttls.end()) + iter = m_ttls.find (oif); + if (iter != m_ttls.end ()) { - m_ttls.erase(iter); + m_ttls.erase (iter); } } else @@ -145,14 +145,14 @@ uint32_t Ipv4MulticastRoute::GetOutputTtl (uint32_t oif) { // We keep this interface around for compatibility (for now) - std::map::const_iterator iter = m_ttls.find(oif); - if (iter == m_ttls.end()) + std::map::const_iterator iter = m_ttls.find (oif); + if (iter == m_ttls.end ()) return((uint32_t)MAX_TTL); return(iter->second); } std::map -Ipv4MulticastRoute::GetOutputTtlMap() const +Ipv4MulticastRoute::GetOutputTtlMap () const { return(m_ttls); } diff --git a/src/internet/model/ipv4-route.h b/src/internet/model/ipv4-route.h index 954040837..f87b113a0 100644 --- a/src/internet/model/ipv4-route.h +++ b/src/internet/model/ipv4-route.h @@ -151,7 +151,7 @@ public: /** * \return map of output interface Ids and TTLs for this route */ - std::map GetOutputTtlMap() const; + std::map GetOutputTtlMap () const; static const uint32_t MAX_INTERFACES = 16; // Maximum number of multicast interfaces on a router static const uint32_t MAX_TTL = 255; // Maximum time-to-live (TTL) diff --git a/src/internet/model/ipv4-routing-table-entry.cc b/src/internet/model/ipv4-routing-table-entry.cc index a2abcfde6..f74047c84 100644 --- a/src/internet/model/ipv4-routing-table-entry.cc +++ b/src/internet/model/ipv4-routing-table-entry.cc @@ -298,8 +298,8 @@ Ipv4MulticastRoutingTableEntry::GetNOutputInterfaces (void) const uint32_t Ipv4MulticastRoutingTableEntry::GetOutputInterface (uint32_t n) const { - NS_ASSERT_MSG(n < m_outputInterfaces.size (), - "Ipv4MulticastRoutingTableEntry::GetOutputInterface (): index out of bounds"); + NS_ASSERT_MSG (n < m_outputInterfaces.size (), + "Ipv4MulticastRoutingTableEntry::GetOutputInterface (): index out of bounds"); return m_outputInterfaces[n]; } diff --git a/src/internet/model/ipv4-static-routing.cc b/src/internet/model/ipv4-static-routing.cc index e71845485..ab11b7b45 100644 --- a/src/internet/model/ipv4-static-routing.cc +++ b/src/internet/model/ipv4-static-routing.cc @@ -71,7 +71,7 @@ Ipv4StaticRouting::AddNetworkRouteTo (Ipv4Address network, networkMask, nextHop, interface); - m_networkRoutes.push_back (make_pair(route,metric)); + m_networkRoutes.push_back (make_pair (route,metric)); } void @@ -117,10 +117,10 @@ Ipv4StaticRouting::SetDefaultRoute (Ipv4Address nextHop, } void -Ipv4StaticRouting::AddMulticastRoute(Ipv4Address origin, - Ipv4Address group, - uint32_t inputInterface, - std::vector outputInterfaces) +Ipv4StaticRouting::AddMulticastRoute (Ipv4Address origin, + Ipv4Address group, + uint32_t inputInterface, + std::vector outputInterfaces) { NS_LOG_FUNCTION (this << origin << " " << group << " " << inputInterface); Ipv4MulticastRoutingTableEntry *route = new Ipv4MulticastRoutingTableEntry (); @@ -133,7 +133,7 @@ Ipv4StaticRouting::AddMulticastRoute(Ipv4Address origin, // these routes are _not_ consulted in the forwarding process-- only // for originating packets void -Ipv4StaticRouting::SetDefaultMulticastRoute(uint32_t outputInterface) +Ipv4StaticRouting::SetDefaultMulticastRoute (uint32_t outputInterface) { NS_LOG_FUNCTION (this << outputInterface); Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry (); @@ -142,7 +142,7 @@ Ipv4StaticRouting::SetDefaultMulticastRoute(uint32_t outputInterface) *route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network, networkMask, outputInterface); - m_networkRoutes.push_back (make_pair(route,0)); + m_networkRoutes.push_back (make_pair (route,0)); } uint32_t @@ -156,8 +156,8 @@ Ipv4MulticastRoutingTableEntry Ipv4StaticRouting::GetMulticastRoute (uint32_t index) const { NS_LOG_FUNCTION (this << index); - NS_ASSERT_MSG(index < m_multicastRoutes.size (), - "Ipv4StaticRouting::GetMulticastRoute (): Index out of range"); + NS_ASSERT_MSG (index < m_multicastRoutes.size (), + "Ipv4StaticRouting::GetMulticastRoute (): Index out of range"); if (index < m_multicastRoutes.size ()) { @@ -177,9 +177,9 @@ Ipv4StaticRouting::GetMulticastRoute (uint32_t index) const } bool -Ipv4StaticRouting::RemoveMulticastRoute(Ipv4Address origin, - Ipv4Address group, - uint32_t inputInterface) +Ipv4StaticRouting::RemoveMulticastRoute (Ipv4Address origin, + Ipv4Address group, + uint32_t inputInterface) { NS_LOG_FUNCTION (this << origin << " " << group << " " << inputInterface); for (MulticastRoutesI i = m_multicastRoutes.begin (); @@ -200,7 +200,7 @@ Ipv4StaticRouting::RemoveMulticastRoute(Ipv4Address origin, } void -Ipv4StaticRouting::RemoveMulticastRoute(uint32_t index) +Ipv4StaticRouting::RemoveMulticastRoute (uint32_t index) { NS_LOG_FUNCTION (this << index); uint32_t tmp = 0; @@ -498,8 +498,8 @@ Ipv4StaticRouting::RouteInput (Ptr p, const Ipv4Header &ipHeader, if (ipHeader.GetDestination ().IsMulticast ()) { NS_LOG_LOGIC ("Multicast destination"); - Ptr mrtentry = LookupStatic(ipHeader.GetSource (), - ipHeader.GetDestination (), m_ipv4->GetInterfaceForDevice (idev)); + Ptr mrtentry = LookupStatic (ipHeader.GetSource (), + ipHeader.GetDestination (), m_ipv4->GetInterfaceForDevice (idev)); if (mrtentry) { @@ -611,7 +611,7 @@ Ipv4StaticRouting::NotifyInterfaceUp (uint32_t i) { if (m_ipv4->GetAddress (i,j).GetLocal () != Ipv4Address () && m_ipv4->GetAddress (i,j).GetMask () != Ipv4Mask () && - m_ipv4->GetAddress (i,j).GetMask () != Ipv4Mask::GetOnes()) + m_ipv4->GetAddress (i,j).GetMask () != Ipv4Mask::GetOnes ()) { AddNetworkRouteTo (m_ipv4->GetAddress (i,j).GetLocal ().CombineMask (m_ipv4->GetAddress (i,j).GetMask ()), m_ipv4->GetAddress (i,j).GetMask (), i); @@ -625,7 +625,7 @@ Ipv4StaticRouting::NotifyInterfaceDown (uint32_t i) NS_LOG_FUNCTION (this << i); // Remove all static routes that are going through this interface uint32_t j = 0; - while (j < GetNRoutes()) + while (j < GetNRoutes ()) { Ipv4RoutingTableEntry route = GetRoute (j); if (route.GetInterface () == i) @@ -642,7 +642,7 @@ Ipv4StaticRouting::NotifyInterfaceDown (uint32_t i) void Ipv4StaticRouting::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address) { - NS_LOG_FUNCTION (this << interface << " " << address.GetLocal()); + NS_LOG_FUNCTION (this << interface << " " << address.GetLocal ()); if (!m_ipv4->IsUp (interface)) { return; @@ -660,7 +660,7 @@ Ipv4StaticRouting::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress ad void Ipv4StaticRouting::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address) { - NS_LOG_FUNCTION (this << interface << " " << address.GetLocal()); + NS_LOG_FUNCTION (this << interface << " " << address.GetLocal ()); if (!m_ipv4->IsUp (interface)) { return; @@ -705,20 +705,20 @@ Ipv4StaticRouting::SetIpv4 (Ptr ipv4) void Ipv4StaticRouting::PrintRoutingTable (Ptr stream) const { - std::ostream* os = stream->GetStream(); + std::ostream* os = stream->GetStream (); if (GetNRoutes () > 0) { - *os << "Destination Gateway Genmask Flags Metric Ref Use Iface" << std::endl; + *os << "Destination Gateway Genmask Flags Metric Ref Use Iface" << std::endl; for (uint32_t j = 0; j < GetNRoutes (); j++) { std::ostringstream dest, gw, mask, flags; Ipv4RoutingTableEntry route = GetRoute (j); dest << route.GetDest (); - *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str(); + *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str (); gw << route.GetGateway (); - *os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str(); + *os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str (); mask << route.GetDestNetworkMask (); - *os << std::setiosflags (std::ios::left) << std::setw (16) << mask.str(); + *os << std::setiosflags (std::ios::left) << std::setw (16) << mask.str (); flags << "U"; if (route.IsHost ()) { @@ -728,7 +728,7 @@ Ipv4StaticRouting::PrintRoutingTable (Ptr stream) const { flags << "GS"; } - *os << std::setiosflags (std::ios::left) << std::setw (6) << flags.str(); + *os << std::setiosflags (std::ios::left) << std::setw (6) << flags.str (); // Metric not implemented *os << "-" << " "; // Ref ct not implemented @@ -741,7 +741,7 @@ Ipv4StaticRouting::PrintRoutingTable (Ptr stream) const } else { - *os << route.GetInterface(); + *os << route.GetInterface (); } *os << std::endl; } diff --git a/src/internet/model/ipv4.h b/src/internet/model/ipv4.h index b8fe9bcfb..7b0d39724 100644 --- a/src/internet/model/ipv4.h +++ b/src/internet/model/ipv4.h @@ -149,7 +149,7 @@ public: * Adds a protocol to an internal list of L4 protocols. * */ - virtual void Insert(Ptr protocol) = 0; + virtual void Insert (Ptr protocol) = 0; /** * \brief Determine whether address and interface corresponding to diff --git a/src/internet/model/ipv6-end-point-demux.cc b/src/internet/model/ipv6-end-point-demux.cc index f25c816b4..4bc540b52 100644 --- a/src/internet/model/ipv6-end-point-demux.cc +++ b/src/internet/model/ipv6-end-point-demux.cc @@ -255,7 +255,7 @@ Ipv6EndPoint* Ipv6EndPointDemux::SimpleLookup (Ipv6Address dst, uint16_t dport, uint32_t genericity = 3; Ipv6EndPoint *generic = 0; - for (EndPointsI i = m_endPoints.begin () ; i != m_endPoints.end () ; i++) + for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) { uint32_t tmp = 0; diff --git a/src/internet/model/ipv6-extension-header.cc b/src/internet/model/ipv6-extension-header.cc index cecb426ce..fb1cdc57c 100644 --- a/src/internet/model/ipv6-extension-header.cc +++ b/src/internet/model/ipv6-extension-header.cc @@ -558,7 +558,7 @@ void Ipv6ExtensionLooseRoutingHeader::Serialize (Buffer::Iterator start) const i.WriteU8 (GetSegmentsLeft ()); i.WriteU32 (0); - for (VectorIpv6Address_t::const_iterator it = m_routersAddress.begin (); it != m_routersAddress.end () ; it++) + for (VectorIpv6Address_t::const_iterator it = m_routersAddress.begin (); it != m_routersAddress.end (); it++) { it->Serialize (buff); i.Write (buff, 16); diff --git a/src/internet/model/ipv6-extension.cc b/src/internet/model/ipv6-extension.cc index 02b6e2bf2..7cf48e299 100644 --- a/src/internet/model/ipv6-extension.cc +++ b/src/internet/model/ipv6-extension.cc @@ -97,7 +97,7 @@ uint8_t Ipv6Extension::ProcessOptions (Ptr& packet, uint8_t offset, uint Ptr ipv6Option; uint8_t processedSize = 0; - uint32_t size = p->GetSize(); + uint32_t size = p->GetSize (); uint8_t *data = new uint8_t[size]; p->CopyData (data, size); @@ -655,7 +655,7 @@ uint8_t Ipv6ExtensionRouting::Process (Ptr& packet, uint8_t offset, Ipv6 p->RemoveAtStart (offset); uint8_t buf[4]; - packet->CopyData(buf, sizeof(buf)); + packet->CopyData (buf, sizeof(buf)); uint8_t routingNextHeader = buf[0]; uint8_t routingLength = buf[1]; diff --git a/src/internet/model/ipv6-header.cc b/src/internet/model/ipv6-header.cc index d23ffcfdf..7399b841d 100644 --- a/src/internet/model/ipv6-header.cc +++ b/src/internet/model/ipv6-header.cc @@ -152,10 +152,10 @@ void Ipv6Header::Serialize (Buffer::Iterator start) const vTcFl= (6 << 28) | (m_trafficClass << 20) | (m_flowLabel); - i.WriteHtonU32(vTcFl); - i.WriteHtonU16(m_payloadLength); - i.WriteU8(m_nextHeader); - i.WriteU8(m_hopLimit); + i.WriteHtonU32 (vTcFl); + i.WriteHtonU16 (m_payloadLength); + i.WriteU8 (m_nextHeader); + i.WriteU8 (m_hopLimit); WriteTo (i, m_sourceAddress); WriteTo (i, m_destinationAddress); @@ -166,16 +166,16 @@ uint32_t Ipv6Header::Deserialize (Buffer::Iterator start) Buffer::Iterator i = start; uint32_t vTcFl = 0; - vTcFl = i.ReadNtohU32(); + vTcFl = i.ReadNtohU32 (); m_version = vTcFl >> 28; NS_ASSERT ((m_version) == 6); m_trafficClass = (uint8_t)((vTcFl >> 20) & 0x000000ff); m_flowLabel = vTcFl & 0xfff00000; - m_payloadLength = i.ReadNtohU16(); - m_nextHeader = i.ReadU8(); - m_hopLimit = i.ReadU8(); + m_payloadLength = i.ReadNtohU16 (); + m_nextHeader = i.ReadU8 (); + m_hopLimit = i.ReadU8 (); ReadFrom (i, m_sourceAddress); ReadFrom (i, m_destinationAddress); diff --git a/src/internet/model/ipv6-interface.cc b/src/internet/model/ipv6-interface.cc index d8e726637..c79c2aa9c 100644 --- a/src/internet/model/ipv6-interface.cc +++ b/src/internet/model/ipv6-interface.cc @@ -182,7 +182,7 @@ bool Ipv6Interface::AddAddress (Ipv6InterfaceAddress iface) /* DAD handling */ if (!addr.IsAny ()) { - for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) + for (Ipv6InterfaceAddressListCI it = m_addresses.begin (); it != m_addresses.end (); ++it) { if ((*it).GetAddress () == addr) { @@ -215,7 +215,7 @@ Ipv6InterfaceAddress Ipv6Interface::GetLinkLocalAddress () const /* IPv6 interface has always at least one IPv6 link-local address */ NS_LOG_FUNCTION_NOARGS (); - for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) + for (Ipv6InterfaceAddressListCI it = m_addresses.begin (); it != m_addresses.end (); ++it) { if ((*it).GetAddress ().IsLinkLocal ()) { @@ -234,7 +234,7 @@ Ipv6InterfaceAddress Ipv6Interface::GetAddress (uint32_t index) const if (m_addresses.size () > index) { - for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) + for (Ipv6InterfaceAddressListCI it = m_addresses.begin (); it != m_addresses.end (); ++it) { if (i == index) { @@ -265,7 +265,7 @@ Ipv6InterfaceAddress Ipv6Interface::RemoveAddress (uint32_t index) NS_ASSERT_MSG (false, "Try to remove index that don't exist in Ipv6Interface::RemoveAddress"); } - for (Ipv6InterfaceAddressListI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) + for (Ipv6InterfaceAddressListI it = m_addresses.begin (); it != m_addresses.end (); ++it) { if (i == index) { @@ -286,7 +286,7 @@ Ipv6InterfaceAddress Ipv6Interface::GetAddressMatchingDestination (Ipv6Address d { NS_LOG_FUNCTION (this << dst); - for (Ipv6InterfaceAddressList::const_iterator it = m_addresses.begin () ; it != m_addresses.end () ; ++it) + for (Ipv6InterfaceAddressList::const_iterator it = m_addresses.begin (); it != m_addresses.end (); ++it) { Ipv6InterfaceAddress ifaddr = (*it); @@ -322,7 +322,7 @@ void Ipv6Interface::Send (Ptr p, Ipv6Address dest) } /* check if destination is for one of our interface */ - for (Ipv6InterfaceAddressListCI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) + for (Ipv6InterfaceAddressListCI it = m_addresses.begin (); it != m_addresses.end (); ++it) { if (dest == (*it).GetAddress ()) { @@ -424,7 +424,7 @@ void Ipv6Interface::SetState (Ipv6Address address, Ipv6InterfaceAddress::State_e { NS_LOG_FUNCTION (this << address << state); - for (Ipv6InterfaceAddressListI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) + for (Ipv6InterfaceAddressListI it = m_addresses.begin (); it != m_addresses.end (); ++it) { if ((*it).GetAddress () == address) { @@ -439,7 +439,7 @@ void Ipv6Interface::SetNsDadUid (Ipv6Address address, uint32_t uid) { NS_LOG_FUNCTION (this << address << uid); - for (Ipv6InterfaceAddressListI it = m_addresses.begin () ; it != m_addresses.end () ; ++it) + for (Ipv6InterfaceAddressListI it = m_addresses.begin (); it != m_addresses.end (); ++it) { if ((*it).GetAddress () == address) { diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc index 3b936a3c2..3db0d9284 100644 --- a/src/internet/model/ipv6-l3-protocol.cc +++ b/src/internet/model/ipv6-l3-protocol.cc @@ -90,28 +90,28 @@ void Ipv6L3Protocol::DoDispose () NS_LOG_FUNCTION_NOARGS (); /* clear protocol and interface list */ - for (L4List_t::iterator it = m_protocols.begin () ; it != m_protocols.end () ; ++it) + for (L4List_t::iterator it = m_protocols.begin (); it != m_protocols.end (); ++it) { *it = 0; } m_protocols.clear (); /* remove interfaces */ - for (Ipv6InterfaceList::iterator it = m_interfaces.begin () ; it != m_interfaces.end (); ++it) + for (Ipv6InterfaceList::iterator it = m_interfaces.begin (); it != m_interfaces.end (); ++it) { *it = 0; } m_interfaces.clear (); /* remove raw sockets */ - for (SocketList::iterator it = m_sockets.begin () ; it != m_sockets.end () ; ++it) + for (SocketList::iterator it = m_sockets.begin (); it != m_sockets.end (); ++it) { *it = 0; } m_sockets.clear (); /* remove list of prefix */ - for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin () ; it != m_prefixes.end () ; ++it) + for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin (); it != m_prefixes.end (); ++it) { (*it)->StopValidTimer (); (*it)->StopPreferredTimer (); @@ -165,7 +165,7 @@ Ptr Ipv6L3Protocol::GetInterface (uint32_t index) const NS_LOG_FUNCTION (this << index); uint32_t tmp = 0; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end () ; it++) + for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin (); it != m_interfaces.end (); it++) { if (index == tmp) { @@ -187,12 +187,12 @@ int32_t Ipv6L3Protocol::GetInterfaceForAddress (Ipv6Address address) const NS_LOG_FUNCTION (this << address); int32_t index = 0; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end () ; it++) + for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin (); it != m_interfaces.end (); it++) { uint32_t j = 0; uint32_t max = (*it)->GetNAddresses (); - for (j = 0 ; j < max ; j++) + for (j = 0; j < max; j++) { if ((*it)->GetAddress (j).GetAddress () == address) { @@ -209,10 +209,10 @@ int32_t Ipv6L3Protocol::GetInterfaceForPrefix (Ipv6Address address, Ipv6Prefix m NS_LOG_FUNCTION (this << address << mask); int32_t index = 0; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end () ; it++) + for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin (); it != m_interfaces.end (); it++) { uint32_t j = 0; - for (j = 0 ; j < (*it)->GetNAddresses () ; j++) + for (j = 0; j < (*it)->GetNAddresses (); j++) { if ((*it)->GetAddress (j).GetAddress ().CombinePrefix (mask) == address.CombinePrefix (mask)) { @@ -235,7 +235,7 @@ int32_t Ipv6L3Protocol::GetInterfaceForDevice (Ptr device) cons NS_LOG_FUNCTION (this << device); int32_t index = 0; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end () ; it++) + for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin (); it != m_interfaces.end (); it++) { if ((*it)->GetDevice () == device) { @@ -267,7 +267,7 @@ void Ipv6L3Protocol::AddAutoconfiguredAddress (uint32_t interface, Ipv6Address n } /* see if we have already the prefix */ - for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin () ; it != m_prefixes.end () ; ++it) + for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin (); it != m_prefixes.end (); ++it) { if ((*it)->GetInterface () == interface && (*it)->GetPrefix () == network && (*it)->GetMask () == mask) { @@ -303,7 +303,7 @@ void Ipv6L3Protocol::RemoveAutoconfiguredAddress (uint32_t interface, Ipv6Addres uint32_t i = 0; Ipv6Address toFound = Ipv6Address::MakeAutoconfiguredAddress (Mac48Address::ConvertFrom (addr), network); - for (i = 0 ; i < max ; i++) + for (i = 0; i < max; i++) { if (iface->GetAddress (i).GetAddress () == toFound) { @@ -313,7 +313,7 @@ void Ipv6L3Protocol::RemoveAutoconfiguredAddress (uint32_t interface, Ipv6Addres } /* remove from list of autoconfigured address */ - for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin () ; it != m_prefixes.end () ; ++it) + for (Ipv6AutoconfiguredPrefixListI it = m_prefixes.begin (); it != m_prefixes.end (); ++it) { if ((*it)->GetInterface () == interface && (*it)->GetPrefix () == network && (*it)->GetMask () == mask) { @@ -432,7 +432,7 @@ void Ipv6L3Protocol::SetupLoopback () uint32_t i = 0; /* see if we have already an loopback NetDevice */ - for (i = 0 ; i < m_node->GetNDevices () ; i++) + for (i = 0; i < m_node->GetNDevices (); i++) { if (device = DynamicCast (m_node->GetDevice (i))) { @@ -482,7 +482,7 @@ void Ipv6L3Protocol::SetIpForward (bool forward) NS_LOG_FUNCTION (this << forward); m_ipForward = forward; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end (); it++) + for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin (); it != m_interfaces.end (); it++) { (*it)->SetForwarding (forward); } @@ -535,7 +535,7 @@ Ptr Ipv6L3Protocol::GetProtocol (int protocolNumber) const { NS_LOG_FUNCTION (this << protocolNumber); - for (L4List_t::const_iterator i = m_protocols.begin () ; i != m_protocols.end () ; ++i) + for (L4List_t::const_iterator i = m_protocols.begin (); i != m_protocols.end (); ++i) { if ((*i)->GetProtocolNumber () == protocolNumber) { @@ -558,7 +558,7 @@ void Ipv6L3Protocol::DeleteRawSocket (Ptr socket) { NS_LOG_FUNCTION (this << socket); - for (SocketList::iterator it = m_sockets.begin () ; it != m_sockets.end () ; ++it) + for (SocketList::iterator it = m_sockets.begin (); it != m_sockets.end (); ++it) { if ((*it) == socket) { @@ -636,16 +636,16 @@ void Ipv6L3Protocol::Send (Ptr packet, Ipv6Address source, Ipv6Address d hdr = BuildHeader (source, destination, protocol, packet->GetSize (), ttl); //for link-local traffic, we need to determine the interface - if (source.IsLinkLocal() || - destination.IsLinkLocal() || - destination.IsAllNodesMulticast() || - destination.IsAllRoutersMulticast() || - destination.IsAllHostsMulticast() || - destination.IsSolicitedMulticast()) + if (source.IsLinkLocal () || + destination.IsLinkLocal () || + destination.IsAllNodesMulticast () || + destination.IsAllRoutersMulticast () || + destination.IsAllHostsMulticast () || + destination.IsSolicitedMulticast ()) { int32_t index = GetInterfaceForAddress (source); NS_ASSERT (index >= 0); - oif = GetNetDevice(index); + oif = GetNetDevice (index); } newRoute = m_routingProtocol->RouteOutput (packet, hdr, oif, err); @@ -657,7 +657,7 @@ void Ipv6L3Protocol::Send (Ptr packet, Ipv6Address source, Ipv6Address d else { NS_LOG_WARN ("No route to host, drop!"); - m_dropTrace (hdr, packet, DROP_NO_ROUTE, m_node->GetObject (), GetInterfaceForDevice(oif)); + m_dropTrace (hdr, packet, DROP_NO_ROUTE, m_node->GetObject (), GetInterfaceForDevice (oif)); } } @@ -669,7 +669,7 @@ void Ipv6L3Protocol::Receive (Ptr device, Ptr p, uint16 Ptr packet = p->Copy (); Ptr ipv6Interface = 0; - for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin () ; it != m_interfaces.end () ; it++) + for (Ipv6InterfaceList::const_iterator it = m_interfaces.begin (); it != m_interfaces.end (); it++) { ipv6Interface = *it; @@ -702,7 +702,7 @@ void Ipv6L3Protocol::Receive (Ptr device, Ptr p, uint16 } /* forward up to IPv6 raw sockets */ - for (SocketList::iterator it = m_sockets.begin () ; it != m_sockets.end () ; ++it) + for (SocketList::iterator it = m_sockets.begin (); it != m_sockets.end (); ++it) { Ptr socket = *it; socket->ForwardUp (packet, hdr, device); @@ -910,10 +910,10 @@ void Ipv6L3Protocol::IpMulticastForward (Ptr mrtentry, PtrGetId ()); - std::map ttlMap = mrtentry->GetOutputTtlMap(); + std::map ttlMap = mrtentry->GetOutputTtlMap (); std::map::iterator mapIter; - for (mapIter = ttlMap.begin(); mapIter != ttlMap.end(); mapIter++) + for (mapIter = ttlMap.begin (); mapIter != ttlMap.end (); mapIter++) { uint32_t interfaceId = mapIter->first; //uint32_t outputTtl = mapIter->second; // Unused for now @@ -954,7 +954,7 @@ void Ipv6L3Protocol::LocalDeliver (Ptr packet, Ipv6Header const& i if (nextHeader == Ipv6Header::IPV6_EXT_HOP_BY_HOP) { uint8_t buf[2]; - p->CopyData(buf, sizeof(buf)); + p->CopyData (buf, sizeof(buf)); nextHeader = buf[0]; nextHeaderPosition = buf[1]; } diff --git a/src/internet/model/ipv6-option-demux.h b/src/internet/model/ipv6-option-demux.h index 3349744ce..f5a90a7ab 100644 --- a/src/internet/model/ipv6-option-demux.h +++ b/src/internet/model/ipv6-option-demux.h @@ -83,7 +83,7 @@ protected: /** * \brief Dispose this object. */ - virtual void DoDispose(); + virtual void DoDispose (); private: typedef std::list > Ipv6OptionList_t; diff --git a/src/internet/model/ipv6-raw-socket-impl.cc b/src/internet/model/ipv6-raw-socket-impl.cc index fa9c4a081..b8e03ba8c 100644 --- a/src/internet/model/ipv6-raw-socket-impl.cc +++ b/src/internet/model/ipv6-raw-socket-impl.cc @@ -296,7 +296,7 @@ uint32_t Ipv6RawSocketImpl::GetRxAvailable () const NS_LOG_FUNCTION_NOARGS (); uint32_t rx = 0; - for (std::list::const_iterator it = m_data.begin () ; it != m_data.end () ; ++it) + for (std::list::const_iterator it = m_data.begin (); it != m_data.end (); ++it) { rx+= (it->packet)->GetSize (); } diff --git a/src/internet/model/ipv6-route.cc b/src/internet/model/ipv6-route.cc index b39235761..9ea3994d2 100644 --- a/src/internet/model/ipv6-route.cc +++ b/src/internet/model/ipv6-route.cc @@ -82,7 +82,7 @@ std::ostream& operator<< (std::ostream& os, Ipv6Route const& route) Ipv6MulticastRoute::Ipv6MulticastRoute () { - m_ttls.clear(); + m_ttls.clear (); } Ipv6MulticastRoute::~Ipv6MulticastRoute () @@ -125,10 +125,10 @@ void Ipv6MulticastRoute::SetOutputTtl (uint32_t oif, uint32_t ttl) { // This TTL value effectively disables the interface std::map::iterator iter; - iter = m_ttls.find(oif); - if (iter != m_ttls.end()) + iter = m_ttls.find (oif); + if (iter != m_ttls.end ()) { - m_ttls.erase(iter); + m_ttls.erase (iter); } } else @@ -140,13 +140,13 @@ void Ipv6MulticastRoute::SetOutputTtl (uint32_t oif, uint32_t ttl) uint32_t Ipv6MulticastRoute::GetOutputTtl (uint32_t oif) { // We keep this interface around for compatibility (for now) - std::map::const_iterator iter = m_ttls.find(oif); - if (iter == m_ttls.end()) + std::map::const_iterator iter = m_ttls.find (oif); + if (iter == m_ttls.end ()) return((uint32_t)MAX_TTL); return(iter->second); } -std::map Ipv6MulticastRoute::GetOutputTtlMap() const +std::map Ipv6MulticastRoute::GetOutputTtlMap () const { return(m_ttls); } diff --git a/src/internet/model/ipv6-route.h b/src/internet/model/ipv6-route.h index 24997078b..1227c36b9 100644 --- a/src/internet/model/ipv6-route.h +++ b/src/internet/model/ipv6-route.h @@ -206,7 +206,7 @@ public: /** * \return map of output interface Ids and TTLs for this route */ - std::map GetOutputTtlMap() const; + std::map GetOutputTtlMap () const; private: /** diff --git a/src/internet/model/ipv6-static-routing.cc b/src/internet/model/ipv6-static-routing.cc index 188c9c119..90533f991 100644 --- a/src/internet/model/ipv6-static-routing.cc +++ b/src/internet/model/ipv6-static-routing.cc @@ -59,7 +59,7 @@ void Ipv6StaticRouting::SetIpv6 (Ptr ipv6) uint32_t i = 0; m_ipv6 = ipv6; - for (i = 0 ; i < m_ipv6->GetNInterfaces () ; i++) + for (i = 0; i < m_ipv6->GetNInterfaces (); i++) { if (m_ipv6->IsUp (i)) { @@ -146,7 +146,7 @@ Ipv6MulticastRoutingTableEntry Ipv6StaticRouting::GetMulticastRoute (uint32_t in if (index < m_multicastRoutes.size ()) { uint32_t tmp = 0; - for (MulticastRoutesCI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i++) + for (MulticastRoutesCI i = m_multicastRoutes.begin (); i != m_multicastRoutes.end (); i++) { if (tmp == index) { @@ -181,7 +181,7 @@ void Ipv6StaticRouting::RemoveMulticastRoute (uint32_t index) NS_LOG_FUNCTION (this << index); uint32_t tmp = 0; - for (MulticastRoutesI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i++) + for (MulticastRoutesI i = m_multicastRoutes.begin (); i != m_multicastRoutes.end (); i++) { if (tmp == index) { @@ -198,7 +198,7 @@ bool Ipv6StaticRouting::HasNetworkDest (Ipv6Address network, uint32_t interfaceI NS_LOG_FUNCTION (this << network << interfaceIndex); /* in the network table */ - for (NetworkRoutesI j = m_networkRoutes.begin () ; j != m_networkRoutes.end () ; j++) + for (NetworkRoutesI j = m_networkRoutes.begin (); j != m_networkRoutes.end (); j++) { Ipv6RoutingTableEntry* rtentry = j->first; Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix (); @@ -234,7 +234,7 @@ Ptr Ipv6StaticRouting::LookupStatic (Ipv6Address dst, Ptr return rtentry; } - for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) + for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); it++) { Ipv6RoutingTableEntry* j = it->first; uint32_t metric = it->second; @@ -305,13 +305,13 @@ void Ipv6StaticRouting::DoDispose () { NS_LOG_FUNCTION_NOARGS (); - for (NetworkRoutesI j = m_networkRoutes.begin () ; j != m_networkRoutes.end () ; j = m_networkRoutes.erase (j)) + for (NetworkRoutesI j = m_networkRoutes.begin (); j != m_networkRoutes.end (); j = m_networkRoutes.erase (j)) { delete j->first; } m_networkRoutes.clear (); - for (MulticastRoutesI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i = m_multicastRoutes.erase (i)) + for (MulticastRoutesI i = m_multicastRoutes.begin (); i != m_multicastRoutes.end (); i = m_multicastRoutes.erase (i)) { delete (*i); } @@ -326,7 +326,7 @@ Ptr Ipv6StaticRouting::LookupStatic (Ipv6Address origin, Ipv NS_LOG_FUNCTION (this << origin << group << interface); Ptr mrtentry = 0; - for (MulticastRoutesI i = m_multicastRoutes.begin () ; i != m_multicastRoutes.end () ; i++) + for (MulticastRoutesI i = m_multicastRoutes.begin (); i != m_multicastRoutes.end (); i++) { Ipv6MulticastRoutingTableEntry* route = *i; @@ -355,7 +355,7 @@ Ptr Ipv6StaticRouting::LookupStatic (Ipv6Address origin, Ipv mrtentry->SetGroup (route->GetGroup ()); mrtentry->SetOrigin (route->GetOrigin ()); mrtentry->SetParent (route->GetInputInterface ()); - for (uint32_t j = 0 ; j < route->GetNOutputInterfaces () ; j++) + for (uint32_t j = 0; j < route->GetNOutputInterfaces (); j++) { if (route->GetOutputInterface (j)) { @@ -382,7 +382,7 @@ Ipv6RoutingTableEntry Ipv6StaticRouting::GetDefaultRoute () uint32_t shortestMetric = 0xffffffff; Ipv6RoutingTableEntry* result = 0; - for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) + for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); it++) { Ipv6RoutingTableEntry* j = it->first; uint32_t metric = it->second; @@ -418,7 +418,7 @@ Ipv6RoutingTableEntry Ipv6StaticRouting::GetRoute (uint32_t index) NS_LOG_FUNCTION (this << index); uint32_t tmp = 0; - for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) + for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); it++) { if (tmp == index) { @@ -436,7 +436,7 @@ uint32_t Ipv6StaticRouting::GetMetric (uint32_t index) NS_LOG_FUNCTION_NOARGS (); uint32_t tmp = 0; - for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) + for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); it++) { if (tmp == index) { @@ -454,7 +454,7 @@ void Ipv6StaticRouting::RemoveRoute (uint32_t index) NS_LOG_FUNCTION (this << index); uint32_t tmp = 0; - for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) + for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); it++) { if (tmp == index) { @@ -471,7 +471,7 @@ void Ipv6StaticRouting::RemoveRoute (Ipv6Address network, Ipv6Prefix prefix, uin { NS_LOG_FUNCTION (this << network << prefix << ifIndex); - for (NetworkRoutesI it = m_networkRoutes.begin () ; it != m_networkRoutes.end () ; it++) + for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); it++) { Ipv6RoutingTableEntry* rtentry = it->first; if (network == rtentry->GetDest () && rtentry->GetInterface () == ifIndex && @@ -597,7 +597,7 @@ bool Ipv6StaticRouting::RouteInput (Ptr p, const Ipv6Header &heade void Ipv6StaticRouting::NotifyInterfaceUp (uint32_t i) { - for (uint32_t j = 0 ; j < m_ipv6->GetNAddresses (i) ; j++) + for (uint32_t j = 0; j < m_ipv6->GetNAddresses (i); j++) { if (m_ipv6->GetAddress (i, j).GetAddress () != Ipv6Address () && m_ipv6->GetAddress (i, j).GetPrefix () != Ipv6Prefix ()) @@ -666,7 +666,7 @@ void Ipv6StaticRouting::NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAd // Remove all static routes that are going through this interface // which reference this network - for (uint32_t j = 0 ; j < GetNRoutes () ; j++) + for (uint32_t j = 0; j < GetNRoutes (); j++) { Ipv6RoutingTableEntry route = GetRoute (j); @@ -706,7 +706,7 @@ void Ipv6StaticRouting::NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv NS_LOG_FUNCTION (this << dst << mask << nextHop << interface); if (dst != Ipv6Address::GetZero ()) { - for (NetworkRoutesI j = m_networkRoutes.begin () ; j != m_networkRoutes.end () ; j++) + for (NetworkRoutesI j = m_networkRoutes.begin (); j != m_networkRoutes.end (); j++) { Ipv6RoutingTableEntry* rtentry = j->first; Ipv6Prefix prefix = rtentry->GetDestNetworkPrefix (); @@ -741,7 +741,7 @@ Ipv6Address Ipv6StaticRouting::SourceAddressSelection (uint32_t interface, Ipv6A /* useally IPv6 interfaces have one link-local address and one global address */ - for (uint32_t i = 1 ; i < m_ipv6->GetNAddresses (interface) ; i++) + for (uint32_t i = 1; i < m_ipv6->GetNAddresses (interface); i++) { Ipv6InterfaceAddress test = m_ipv6->GetAddress (interface, i); diff --git a/src/internet/model/loopback-net-device.cc b/src/internet/model/loopback-net-device.cc index b68577528..69fde8fef 100644 --- a/src/internet/model/loopback-net-device.cc +++ b/src/internet/model/loopback-net-device.cc @@ -79,13 +79,13 @@ LoopbackNetDevice::Receive (Ptr packet, uint16_t protocol, } void -LoopbackNetDevice::SetIfIndex(const uint32_t index) +LoopbackNetDevice::SetIfIndex (const uint32_t index) { m_ifIndex = index; } uint32_t -LoopbackNetDevice::GetIfIndex(void) const +LoopbackNetDevice::GetIfIndex (void) const { return m_ifIndex; } @@ -186,7 +186,7 @@ LoopbackNetDevice::Send (Ptr packet, const Address& dest, uint16_t proto } bool -LoopbackNetDevice::SendFrom(Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) +LoopbackNetDevice::SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) { NS_LOG_FUNCTION (packet << " " << source << " " << dest << " " << protocolNumber); Mac48Address to = Mac48Address::ConvertFrom (dest); diff --git a/src/internet/model/loopback-net-device.h b/src/internet/model/loopback-net-device.h index 084fa5bd0..c86f08375 100644 --- a/src/internet/model/loopback-net-device.h +++ b/src/internet/model/loopback-net-device.h @@ -42,8 +42,8 @@ public: LoopbackNetDevice (); // inherited from NetDevice base class. - virtual void SetIfIndex(const uint32_t index); - virtual uint32_t GetIfIndex(void) const; + virtual void SetIfIndex (const uint32_t index); + virtual uint32_t GetIfIndex (void) const; virtual Ptr GetChannel (void) const; virtual void SetAddress (Address address); virtual Address GetAddress (void) const; @@ -57,8 +57,8 @@ public: virtual Address GetMulticast (Ipv4Address multicastGroup) const; virtual bool IsPointToPoint (void) const; virtual bool IsBridge (void) const; - virtual bool Send(Ptr packet, const Address& dest, uint16_t protocolNumber); - virtual bool SendFrom(Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber); + virtual bool Send (Ptr packet, const Address& dest, uint16_t protocolNumber); + virtual bool SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber); virtual Ptr GetNode (void) const; virtual void SetNode (Ptr node); virtual bool NeedsArp (void) const; diff --git a/src/internet/model/ndisc-cache.cc b/src/internet/model/ndisc-cache.cc index 474e2b1de..78cc96b7d 100644 --- a/src/internet/model/ndisc-cache.cc +++ b/src/internet/model/ndisc-cache.cc @@ -113,7 +113,7 @@ void NdiscCache::Remove (NdiscCache::Entry* entry) { NS_LOG_FUNCTION_NOARGS (); - for (CacheI i = m_ndCache.begin () ; i != m_ndCache.end () ; i++) + for (CacheI i = m_ndCache.begin (); i != m_ndCache.end (); i++) { if ((*i).second == entry) { @@ -129,7 +129,7 @@ void NdiscCache::Flush () { NS_LOG_FUNCTION_NOARGS (); - for (CacheI i = m_ndCache.begin () ; i != m_ndCache.end () ; i++) + for (CacheI i = m_ndCache.begin (); i != m_ndCache.end (); i++) { delete (*i).second; /* delete the pointer NdiscCache::Entry */ } @@ -154,10 +154,10 @@ NdiscCache::Entry::Entry (NdiscCache* nd) m_waiting (), m_router (false), m_reachableTimer (Timer::CANCEL_ON_DESTROY), - m_retransTimer(Timer::CANCEL_ON_DESTROY), - m_probeTimer(Timer::CANCEL_ON_DESTROY), - m_delayTimer(Timer::CANCEL_ON_DESTROY), - m_lastReachabilityConfirmation(Seconds (0.0)), + m_retransTimer (Timer::CANCEL_ON_DESTROY), + m_probeTimer (Timer::CANCEL_ON_DESTROY), + m_delayTimer (Timer::CANCEL_ON_DESTROY), + m_lastReachabilityConfirmation (Seconds (0.0)), m_nsRetransmit (0) { NS_LOG_FUNCTION_NOARGS (); diff --git a/src/internet/model/nsc-sysctl.cc b/src/internet/model/nsc-sysctl.cc index 26ad1fac5..1a9c7636a 100644 --- a/src/internet/model/nsc-sysctl.cc +++ b/src/internet/model/nsc-sysctl.cc @@ -36,12 +36,12 @@ private: std::string m_name; }; -bool NscStackStringAccessor::HasGetter(void) const +bool NscStackStringAccessor::HasGetter (void) const { return true; } -bool NscStackStringAccessor::HasSetter(void) const +bool NscStackStringAccessor::HasSetter (void) const { return true; } @@ -106,7 +106,7 @@ Ns3NscStack::GetInstanceTypeId (void) const tid = TypeId (name.c_str ()); tid.SetParent (); char buf[256]; - for (int i=0; m_stack->sysctl_getnum(i, buf, sizeof(buf)) > 0 ; i++) + for (int i=0; m_stack->sysctl_getnum (i, buf, sizeof(buf)) > 0; i++) { char value[256]; if (m_stack->sysctl_get (buf, value, sizeof(value)) > 0) @@ -129,7 +129,7 @@ Ns3NscStack::Get (std::string name) const { // name.c_str () is not a valid sysctl name, or internal NSC error (eg. error converting value) return NULL; } - return std::string(buf); + return std::string (buf); } void diff --git a/src/internet/model/nsc-sysctl.h b/src/internet/model/nsc-sysctl.h index 854393dd5..70747e477 100644 --- a/src/internet/model/nsc-sysctl.h +++ b/src/internet/model/nsc-sysctl.h @@ -33,7 +33,7 @@ class Ns3NscStack : public Object public: static TypeId GetTypeId (void); virtual TypeId GetInstanceTypeId (void) const; - void SetStack (INetStack *stack) { m_stack = stack;} + void SetStack (INetStack *stack) { m_stack = stack; } private: friend class NscStackStringAccessor; diff --git a/src/internet/model/nsc-tcp-l4-protocol.cc b/src/internet/model/nsc-tcp-l4-protocol.cc index 7e9560365..9da58dfd0 100644 --- a/src/internet/model/nsc-tcp-l4-protocol.cc +++ b/src/internet/model/nsc-tcp-l4-protocol.cc @@ -59,9 +59,9 @@ class NscInterfaceImpl : public ISendCallback, public IInterruptCallback public: NscInterfaceImpl (Ptr prot); private: - virtual void send_callback(const void *data, int datalen); - virtual void wakeup(); - virtual void gettime(unsigned int *, unsigned int *); + virtual void send_callback (const void *data, int datalen); + virtual void wakeup (); + virtual void gettime (unsigned int *, unsigned int *); private: Ptr m_prot; }; @@ -72,17 +72,17 @@ NscInterfaceImpl::NscInterfaceImpl (Ptr prot) } void -NscInterfaceImpl::send_callback(const void *data, int datalen) +NscInterfaceImpl::send_callback (const void *data, int datalen) { m_prot->send_callback (data, datalen); } void -NscInterfaceImpl::wakeup() +NscInterfaceImpl::wakeup () { m_prot->wakeup (); } void -NscInterfaceImpl::gettime(unsigned int *sec, unsigned int *usec) +NscInterfaceImpl::gettime (unsigned int *sec, unsigned int *usec) { m_prot->gettime (sec,usec); } @@ -105,14 +105,14 @@ NscTcpL4Protocol::GetTypeId (void) .AddAttribute ("Library", "Set the linux library to be used to create the stack", TypeId::ATTR_GET|TypeId::ATTR_CONSTRUCT, - StringValue("liblinux2.6.26.so"), + StringValue ("liblinux2.6.26.so"), MakeStringAccessor (&NscTcpL4Protocol::GetNscLibrary,&NscTcpL4Protocol::SetNscLibrary), MakeStringChecker ()) ; return tid; } -int external_rand() +int external_rand () { return 1; // TODO } @@ -124,25 +124,25 @@ NscTcpL4Protocol::NscTcpL4Protocol () m_softTimer (Timer::CANCEL_ON_DESTROY) { m_dlopenHandle = NULL; - NS_LOG_LOGIC("Made a NscTcpL4Protocol "< node) return; } - NS_ASSERT(m_dlopenHandle); + NS_ASSERT (m_dlopenHandle); - FCreateStack create = (FCreateStack)dlsym(m_dlopenHandle, "nsc_create_stack"); - NS_ASSERT(create); - m_nscStack = create(m_nscInterface, m_nscInterface, external_rand); - int hzval = m_nscStack->get_hz(); + FCreateStack create = (FCreateStack)dlsym (m_dlopenHandle, "nsc_create_stack"); + NS_ASSERT (create); + m_nscStack = create (m_nscInterface, m_nscInterface, external_rand); + int hzval = m_nscStack->get_hz (); - NS_ASSERT(hzval > 0); + NS_ASSERT (hzval > 0); m_softTimer.SetFunction (&NscTcpL4Protocol::SoftInterrupt, this); m_softTimer.SetDelay (MilliSeconds (1000/hzval)); - m_nscStack->init(hzval); + m_nscStack->init (hzval); // This enables stack and NSC debug messages // m_nscStack->set_diagnostic(1000); @@ -203,7 +203,7 @@ NscTcpL4Protocol::NotifyNewAggregate () Ptr tcpFactory = CreateObject (); tcpFactory->SetTcp (this); node->AggregateObject (tcpFactory); - this->SetDownTarget (MakeCallback(&Ipv4L3Protocol::Send, ipv4)); + this->SetDownTarget (MakeCallback (&Ipv4L3Protocol::Send, ipv4)); } } } @@ -308,7 +308,7 @@ NscTcpL4Protocol::Receive (Ptr packet, { NS_LOG_FUNCTION (this << packet << header << incomingInterface); Ipv4Header ipHeader; - uint32_t packetSize = packet->GetSize(); + uint32_t packetSize = packet->GetSize (); // The way things work at the moment, the IP header has been removed // by the ns-3 IPv4 processing code. However, the NSC stack expects @@ -323,15 +323,15 @@ NscTcpL4Protocol::Receive (Ptr packet, // all NSC stacks check the IP checksum ipHeader.EnableChecksum (); - packet->AddHeader(ipHeader); - packetSize = packet->GetSize(); + packet->AddHeader (ipHeader); + packetSize = packet->GetSize (); uint8_t *buf = new uint8_t[packetSize]; packet->CopyData (buf, packetSize); const uint8_t *data = const_cast(buf); // deliver complete packet to the NSC network stack - m_nscStack->if_receive_packet(0, data, packetSize); + m_nscStack->if_receive_packet (0, data, packetSize); delete[] buf; wakeup (); @@ -345,12 +345,12 @@ void NscTcpL4Protocol::SoftInterrupt (void) m_softTimer.Schedule (); } -void NscTcpL4Protocol::send_callback(const void* data, int datalen) +void NscTcpL4Protocol::send_callback (const void* data, int datalen) { Ptr p; uint32_t ipv4Saddr, ipv4Daddr; - NS_ASSERT(datalen > 20); + NS_ASSERT (datalen > 20); // create packet, without IP header. The TCP header is not touched. @@ -366,17 +366,17 @@ void NscTcpL4Protocol::send_callback(const void* data, int datalen) ipv4Saddr = *(ipheader+3); ipv4Daddr = *(ipheader+4); - Ipv4Address saddr(ntohl(ipv4Saddr)); - Ipv4Address daddr(ntohl(ipv4Daddr)); + Ipv4Address saddr (ntohl (ipv4Saddr)); + Ipv4Address daddr (ntohl (ipv4Daddr)); Ptr ipv4 = m_node->GetObject (); NS_ASSERT_MSG (ipv4, "nsc callback invoked, but node has no ipv4 object"); m_downTarget (p, saddr, daddr, PROT_NUMBER, 0); - m_nscStack->if_send_finish(0); + m_nscStack->if_send_finish (0); } -void NscTcpL4Protocol::wakeup() +void NscTcpL4Protocol::wakeup () { // TODO // this should schedule a timer to read from all tcp sockets now... this is @@ -386,11 +386,11 @@ void NscTcpL4Protocol::wakeup() for (Ipv4EndPointDemux::EndPointsI endPoint = endPoints.begin (); endPoint != endPoints.end (); endPoint++) { // NSC HACK: (ab)use TcpSocket::ForwardUp for signalling - (*endPoint)->ForwardUp (NULL, Ipv4Header(), 0, 0); + (*endPoint)->ForwardUp (NULL, Ipv4Header (), 0, 0); } } -void NscTcpL4Protocol::gettime(unsigned int* sec, unsigned int* usec) +void NscTcpL4Protocol::gettime (unsigned int* sec, unsigned int* usec) { // Only used by the Linux network stack, e.g. during ISN generation // and in the kernel rng initialization routine. Also used in Linux @@ -402,7 +402,7 @@ void NscTcpL4Protocol::gettime(unsigned int* sec, unsigned int* usec) } -void NscTcpL4Protocol::AddInterface(void) +void NscTcpL4Protocol::AddInterface (void) { Ptr ip = m_node->GetObject (); const uint32_t nInterfaces = ip->GetNInterfaces (); @@ -421,16 +421,16 @@ void NscTcpL4Protocol::AddInterface(void) std::ostringstream addrOss, maskOss; - addr.Print(addrOss); - mask.Print(maskOss); + addr.Print (addrOss); + mask.Print (maskOss); - NS_LOG_LOGIC ("if_attach " << addrOss.str().c_str() << " " << maskOss.str().c_str() << " " << mtu); + NS_LOG_LOGIC ("if_attach " << addrOss.str ().c_str () << " " << maskOss.str ().c_str () << " " << mtu); - std::string addrStr = addrOss.str(); - std::string maskStr = maskOss.str(); - const char* addrCStr = addrStr.c_str(); - const char* maskCStr = maskStr.c_str(); - m_nscStack->if_attach(addrCStr, maskCStr, mtu); + std::string addrStr = addrOss.str (); + std::string maskStr = maskOss.str (); + const char* addrCStr = addrStr.c_str (); + const char* maskCStr = maskStr.c_str (); + m_nscStack->if_attach (addrCStr, maskCStr, mtu); if (i == 1) { @@ -438,7 +438,7 @@ void NscTcpL4Protocol::AddInterface(void) // correct really... uint8_t addrBytes[4]; - addr.Serialize(addrBytes); + addr.Serialize (addrBytes); // XXX: this is all a bit of a horrible hack // @@ -448,10 +448,10 @@ void NscTcpL4Protocol::AddInterface(void) // All we need is another address on the same network as the interface. This // will force the stack to output the packet out of the network interface. addrBytes[3]++; - addr.Deserialize(addrBytes); - addrOss.str(""); - addr.Print(addrOss); - m_nscStack->add_default_gateway(addrOss.str().c_str()); + addr.Deserialize (addrBytes); + addrOss.str (""); + addr.Print (addrOss); + m_nscStack->add_default_gateway (addrOss.str ().c_str ()); } } } diff --git a/src/internet/model/nsc-tcp-l4-protocol.h b/src/internet/model/nsc-tcp-l4-protocol.h index d6c29773f..fb83541d3 100644 --- a/src/internet/model/nsc-tcp-l4-protocol.h +++ b/src/internet/model/nsc-tcp-l4-protocol.h @@ -102,15 +102,15 @@ private: // send_callback is invoked by NSCs 'ethernet driver' to re-inject // a packet (i.e. an octet soup consisting of an IP Header, TCP Header // and user payload, if any), into ns-3. - void send_callback(const void *data, int datalen); + void send_callback (const void *data, int datalen); // This is called by the NSC stack whenever something of interest // has happened, e.g. when data arrives on a socket, a listen socket // has a new connection pending, etc. - void wakeup(); + void wakeup (); // This is called by the Linux stack RNG initialization. // Its also used by the cradle code to add a timestamp to // printk/printf/debug output. - void gettime(unsigned int *sec, unsigned int *usec); + void gettime (unsigned int *sec, unsigned int *usec); void AddInterface (void); void SoftInterrupt (void); friend class NscInterfaceImpl; diff --git a/src/internet/model/nsc-tcp-socket-impl.cc b/src/internet/model/nsc-tcp-socket-impl.cc index d982b8b00..fe4e53cf0 100644 --- a/src/internet/model/nsc-tcp-socket-impl.cc +++ b/src/internet/model/nsc-tcp-socket-impl.cc @@ -53,7 +53,7 @@ NS_OBJECT_ENSURE_REGISTERED (NscTcpSocketImpl); TypeId NscTcpSocketImpl::GetTypeId () { - static TypeId tid = TypeId("ns3::NscTcpSocketImpl") + static TypeId tid = TypeId ("ns3::NscTcpSocketImpl") .SetParent () .AddTraceSource ("CongestionWindow", "The TCP connection's congestion window", @@ -76,13 +76,13 @@ NscTcpSocketImpl::NscTcpSocketImpl () m_state (CLOSED), m_closeOnEmpty (false), m_txBufferSize (0), - m_lastMeasuredRtt (Seconds(0.0)) + m_lastMeasuredRtt (Seconds (0.0)) { NS_LOG_FUNCTION (this); } NscTcpSocketImpl::NscTcpSocketImpl(const NscTcpSocketImpl& sock) - : TcpSocket(sock), //copy the base class callbacks + : TcpSocket (sock), //copy the base class callbacks m_delAckMaxCount (sock.m_delAckMaxCount), m_delAckTimeout (sock.m_delAckTimeout), m_endPoint (0), @@ -106,7 +106,7 @@ NscTcpSocketImpl::NscTcpSocketImpl(const NscTcpSocketImpl& sock) m_cWnd (sock.m_cWnd), m_ssThresh (sock.m_ssThresh), m_initialCWnd (sock.m_initialCWnd), - m_lastMeasuredRtt (Seconds(0.0)), + m_lastMeasuredRtt (Seconds (0.0)), m_cnTimeout (sock.m_cnTimeout), m_cnCount (sock.m_cnCount), m_rxAvailable (0), @@ -114,7 +114,7 @@ NscTcpSocketImpl::NscTcpSocketImpl(const NscTcpSocketImpl& sock) m_sndBufSize (sock.m_sndBufSize) { NS_LOG_FUNCTION_NOARGS (); - NS_LOG_LOGIC("Invoked the copy constructor"); + NS_LOG_LOGIC ("Invoked the copy constructor"); //copy the pending data if necessary if(!sock.m_txBuffer.empty () ) { @@ -126,7 +126,7 @@ NscTcpSocketImpl::NscTcpSocketImpl(const NscTcpSocketImpl& sock) NscTcpSocketImpl::~NscTcpSocketImpl () { - NS_LOG_FUNCTION(this); + NS_LOG_FUNCTION (this); m_node = 0; if (m_endPoint != 0) { @@ -158,7 +158,7 @@ NscTcpSocketImpl::SetNode (Ptr node) void NscTcpSocketImpl::SetTcp (Ptr tcp) { - m_nscTcpSocket = tcp->m_nscStack->new_tcp_socket(); + m_nscTcpSocket = tcp->m_nscStack->new_tcp_socket (); m_tcp = tcp; } @@ -276,13 +276,13 @@ NscTcpSocketImpl::Close (void) if (!m_txBuffer.empty ()) { // App close with pending data must wait until all data transmitted m_closeOnEmpty = true; - NS_LOG_LOGIC("Socket " << this << - " deferring close, state " << m_state); + NS_LOG_LOGIC ("Socket " << this << + " deferring close, state " << m_state); return 0; } - NS_LOG_LOGIC("NscTcp socket " << this << " calling disconnect(); moving to CLOSED"); - m_nscTcpSocket->disconnect(); + NS_LOG_LOGIC ("NscTcp socket " << this << " calling disconnect(); moving to CLOSED"); + m_nscTcpSocket->disconnect (); m_state = CLOSED; ShutdownSend (); return 0; @@ -306,10 +306,10 @@ NscTcpSocketImpl::Connect (const Address & address) m_remotePort = transport.GetPort (); std::ostringstream ss; - m_remoteAddress.Print(ss); + m_remoteAddress.Print (ss); std::string ipstring = ss.str (); - m_nscTcpSocket->connect(ipstring.c_str (), m_remotePort); + m_nscTcpSocket->connect (ipstring.c_str (), m_remotePort); m_state = SYN_SENT; return 0; } @@ -331,13 +331,13 @@ NscTcpSocketImpl::Send (const Ptr p, uint32_t flags) uint32_t sent = p->GetSize (); if (m_state == ESTABLISHED) { - m_txBuffer.push(p); + m_txBuffer.push (p); m_txBufferSize += sent; - SendPendingData(); + SendPendingData (); } else { // SYN_SET -- Queue Data - m_txBuffer.push(p); + m_txBuffer.push (p); m_txBufferSize += sent; } return sent; @@ -383,7 +383,7 @@ int NscTcpSocketImpl::Listen (void) { NS_LOG_FUNCTION (this); - m_nscTcpSocket->listen(m_localPort); + m_nscTcpSocket->listen (m_localPort); m_state = LISTEN; return 0; } @@ -394,18 +394,18 @@ NscTcpSocketImpl::NSCWakeup () { switch (m_state) { case SYN_SENT: - if (!m_nscTcpSocket->is_connected()) + if (!m_nscTcpSocket->is_connected ()) break; m_state = ESTABLISHED; - Simulator::ScheduleNow(&NscTcpSocketImpl::ConnectionSucceeded, this); + Simulator::ScheduleNow (&NscTcpSocketImpl::ConnectionSucceeded, this); // fall through to schedule read/write events case ESTABLISHED: if (!m_txBuffer.empty ()) - Simulator::ScheduleNow(&NscTcpSocketImpl::SendPendingData, this); - Simulator::ScheduleNow(&NscTcpSocketImpl::ReadPendingData, this); + Simulator::ScheduleNow (&NscTcpSocketImpl::SendPendingData, this); + Simulator::ScheduleNow (&NscTcpSocketImpl::ReadPendingData, this); break; case LISTEN: - Simulator::ScheduleNow(&NscTcpSocketImpl::Accept, this); + Simulator::ScheduleNow (&NscTcpSocketImpl::Accept, this); break; case CLOSED: break; default: @@ -417,7 +417,7 @@ Ptr NscTcpSocketImpl::Recv (uint32_t maxSize, uint32_t flags) { NS_LOG_FUNCTION_NOARGS (); - if (m_deliveryQueue.empty() ) + if (m_deliveryQueue.empty () ) { m_errno = ERROR_AGAIN; return 0; @@ -448,6 +448,9 @@ NscTcpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, bool found; found = packet->PeekPacketTag (tag); NS_ASSERT (found); + // cast found to void, to suppress 'found' set but not used + // compiler warning in optimized builds + (void) found; fromAddress = tag.GetAddress (); } return packet; @@ -457,7 +460,7 @@ int NscTcpSocketImpl::GetSockName (Address &address) const { NS_LOG_FUNCTION_NOARGS (); - address = InetSocketAddress(m_localAddress, m_localPort); + address = InetSocketAddress (m_localAddress, m_localPort); return 0; } @@ -474,10 +477,10 @@ void NscTcpSocketImpl::ForwardUp (Ptr packet, Ipv4Header header, uint16_t port, Ptr incomingInterface) { - NSCWakeup(); + NSCWakeup (); } -void NscTcpSocketImpl::CompleteFork(void) +void NscTcpSocketImpl::CompleteFork (void) { // The address pairs (m_localAddress, m_localPort, m_remoteAddress, m_remotePort) // are bogus, but this isn't important at the moment, because @@ -487,22 +490,22 @@ void NscTcpSocketImpl::CompleteFork(void) struct sockaddr_in sin; size_t sin_len = sizeof(sin); - if (0 == m_nscTcpSocket->getpeername((struct sockaddr*) &sin, &sin_len)) { - m_remotePort = ntohs(sin.sin_port); - m_remoteAddress = m_remoteAddress.Deserialize((const uint8_t*) &sin.sin_addr); - m_peerAddress = InetSocketAddress(m_remoteAddress, m_remotePort); + if (0 == m_nscTcpSocket->getpeername ((struct sockaddr*) &sin, &sin_len)) { + m_remotePort = ntohs (sin.sin_port); + m_remoteAddress = m_remoteAddress.Deserialize ((const uint8_t*) &sin.sin_addr); + m_peerAddress = InetSocketAddress (m_remoteAddress, m_remotePort); } m_endPoint = m_tcp->Allocate (); //the cloned socket with be in listen state, so manually change state - NS_ASSERT(m_state == LISTEN); + NS_ASSERT (m_state == LISTEN); m_state = ESTABLISHED; sin_len = sizeof(sin); - if (0 == m_nscTcpSocket->getsockname((struct sockaddr *) &sin, &sin_len)) - m_localAddress = m_localAddress.Deserialize((const uint8_t*) &sin.sin_addr); + if (0 == m_nscTcpSocket->getsockname ((struct sockaddr *) &sin, &sin_len)) + m_localAddress = m_localAddress.Deserialize ((const uint8_t*) &sin.sin_addr); NS_LOG_LOGIC ("NscTcpSocketImpl " << this << " accepted connection from " << m_remoteAddress << ":" << m_remotePort @@ -514,21 +517,21 @@ void NscTcpSocketImpl::CompleteFork(void) NotifyNewConnectionCreated (this, m_peerAddress); } -void NscTcpSocketImpl::ConnectionSucceeded() +void NscTcpSocketImpl::ConnectionSucceeded () { // We would preferred to have scheduled an event directly to // NotifyConnectionSucceeded, but (sigh) these are protected // and we can get the address of it :( struct sockaddr_in sin; size_t sin_len = sizeof(sin); - if (0 == m_nscTcpSocket->getsockname((struct sockaddr *) &sin, &sin_len)) { - m_localAddress = m_localAddress.Deserialize((const uint8_t*)&sin.sin_addr); - m_localPort = ntohs(sin.sin_port); + if (0 == m_nscTcpSocket->getsockname ((struct sockaddr *) &sin, &sin_len)) { + m_localAddress = m_localAddress.Deserialize ((const uint8_t*)&sin.sin_addr); + m_localPort = ntohs (sin.sin_port); } NS_LOG_LOGIC ("NscTcpSocketImpl " << this << " connected to " << m_remoteAddress << ":" << m_remotePort << " from " << m_localAddress << ":" << m_localPort); - NotifyConnectionSucceeded(); + NotifyConnectionSucceeded (); } @@ -540,12 +543,12 @@ bool NscTcpSocketImpl::Accept (void) } NS_ASSERT (m_state == LISTEN); - if (!m_nscTcpSocket->is_listening()) + if (!m_nscTcpSocket->is_listening ()) { return false; } INetStreamSocket *newsock; - int res = m_nscTcpSocket->accept(&newsock); + int res = m_nscTcpSocket->accept (&newsock); if (res != 0) { return false; @@ -575,14 +578,14 @@ bool NscTcpSocketImpl::ReadPendingData (void) uint8_t buffer[8192]; len = sizeof(buffer); m_errno = ERROR_NOTERROR; - err = m_nscTcpSocket->read_data(buffer, &len); + err = m_nscTcpSocket->read_data (buffer, &len); if (err == 0 && len == 0) { NS_LOG_LOGIC ("ReadPendingData got EOF from socket"); m_state = CLOSE_WAIT; return false; } - m_errno = GetNativeNs3Errno(err); + m_errno = GetNativeNs3Errno (err); switch (m_errno) { case ERROR_NOTERROR: break; // some data was sent @@ -630,7 +633,7 @@ bool NscTcpSocketImpl::SendPendingData (void) uint8_t *buf = new uint8_t[size]; p->CopyData (buf, size); - ret = m_nscTcpSocket->send_data((const char *)buf, size); + ret = m_nscTcpSocket->send_data ((const char *)buf, size); delete[] buf; if (ret <= 0) @@ -644,7 +647,7 @@ bool NscTcpSocketImpl::SendPendingData (void) if ((size_t)ret < size) { - p->RemoveAtStart(ret); + p->RemoveAtStart (ret); break; } @@ -654,7 +657,7 @@ bool NscTcpSocketImpl::SendPendingData (void) { if (m_closeOnEmpty) { - m_nscTcpSocket->disconnect(); + m_nscTcpSocket->disconnect (); m_state = CLOSED; } break; @@ -663,7 +666,7 @@ bool NscTcpSocketImpl::SendPendingData (void) if (written > 0) { - Simulator::ScheduleNow(&NscTcpSocketImpl::NotifyDataSent, this, ret); + Simulator::ScheduleNow (&NscTcpSocketImpl::NotifyDataSent, this, ret); return true; } return false; @@ -807,7 +810,7 @@ NscTcpSocketImpl::GetPersistTimeout (void) const } enum Socket::SocketErrno -NscTcpSocketImpl::GetNativeNs3Errno(int error) const +NscTcpSocketImpl::GetNativeNs3Errno (int error) const { enum nsc_errno err; @@ -837,7 +840,7 @@ NscTcpSocketImpl::GetNativeNs3Errno(int error) const // but is triggered by e.g. show_config(). case NSC_EUNKNOWN: return ERROR_INVAL; // Catches stacks that 'return -1' without real mapping } - NS_ASSERT_MSG(0, "Unknown NSC error"); + NS_ASSERT_MSG (0, "Unknown NSC error"); return ERROR_INVAL; } diff --git a/src/internet/model/nsc-tcp-socket-impl.h b/src/internet/model/nsc-tcp-socket-impl.h index 64a08dee3..45de1c6d5 100644 --- a/src/internet/model/nsc-tcp-socket-impl.h +++ b/src/internet/model/nsc-tcp-socket-impl.h @@ -72,11 +72,11 @@ public: virtual int Close (void); virtual int ShutdownSend (void); virtual int ShutdownRecv (void); - virtual int Connect(const Address &address); - virtual int Listen(void); + virtual int Connect (const Address &address); + virtual int Listen (void); virtual uint32_t GetTxAvailable (void) const; virtual int Send (Ptr p, uint32_t flags); - virtual int SendTo(Ptr p, uint32_t flags, const Address &toAddress); + virtual int SendTo (Ptr p, uint32_t flags, const Address &toAddress); virtual uint32_t GetRxAvailable (void) const; virtual Ptr Recv (uint32_t maxSize, uint32_t flags); virtual Ptr RecvFrom (uint32_t maxSize, uint32_t flags, @@ -86,7 +86,7 @@ public: virtual bool GetAllowBroadcast () const; private: - void NSCWakeup(void); + void NSCWakeup (void); friend class Tcp; // invoked by Tcp class int FinishBind (void); @@ -94,11 +94,11 @@ private: Ptr incomingInterface); void Destroy (void); //methods for state - bool SendPendingData(void); - bool ReadPendingData(void); - bool Accept(void); - void CompleteFork(void); - void ConnectionSucceeded(); + bool SendPendingData (void); + bool ReadPendingData (void); + bool Accept (void); + void CompleteFork (void); + void ConnectionSucceeded (); // Manage data tx/rx // XXX This should be virtual and overridden @@ -128,7 +128,7 @@ private: virtual void SetPersistTimeout (Time timeout); virtual Time GetPersistTimeout (void) const; - enum Socket::SocketErrno GetNativeNs3Errno(int err) const; + enum Socket::SocketErrno GetNativeNs3Errno (int err) const; uint32_t m_delAckMaxCount; Time m_delAckTimeout; diff --git a/src/internet/model/pending-data.cc b/src/internet/model/pending-data.cc index 429f16621..2dd4af31f 100644 --- a/src/internet/model/pending-data.cc +++ b/src/internet/model/pending-data.cc @@ -57,8 +57,8 @@ PendingData::PendingData(const std::string& s) : size (s.length () + 1), data (0), msgSize (0), responseSize (0) { - NS_LOG_FUNCTION (this << s.length() + 1); - data.push_back (Create ((uint8_t*)s.c_str(), size)); + NS_LOG_FUNCTION (this << s.length () + 1); + data.push_back (Create ((uint8_t*)s.c_str (), size)); } PendingData::PendingData(const PendingData& c) @@ -94,7 +94,7 @@ PendingData* PendingData::CopySD (uint32_t s, uint8_t* d) void PendingData::Clear () { // Remove all pending data NS_LOG_FUNCTION (this); - data.clear(); + data.clear (); size = 0; } @@ -103,11 +103,11 @@ void PendingData::Add (uint32_t s, const uint8_t* d) NS_LOG_FUNCTION (this << s); if (d == 0) { - data.push_back(Create (d,s)); + data.push_back (Create (d,s)); } else { - data.push_back(Create (s)); + data.push_back (Create (s)); } size += s; } @@ -115,8 +115,8 @@ void PendingData::Add (uint32_t s, const uint8_t* d) void PendingData::Add (Ptr p) { NS_LOG_FUNCTION (this); - data.push_back(p); - size += p->GetSize(); + data.push_back (p); + size += p->GetSize (); } uint32_t PendingData::SizeFromSeq (const SequenceNumber32& seqFront, const SequenceNumber32& seqOffset) @@ -153,7 +153,7 @@ Ptr PendingData::CopyFromOffset (uint32_t s, uint32_t o) { return Create (); // No data requested } - if (data.size() != 0) + if (data.size () != 0) { // Actual data exists, make copy and return it uint32_t count = 0; std::vector >::size_type begin = 0; @@ -161,9 +161,9 @@ Ptr PendingData::CopyFromOffset (uint32_t s, uint32_t o) std::vector >::size_type end = 0; Ptr outPacket; Ptr endFragment; - for (std::vector >::size_type i=0; i >::size_type i=0; iGetSize(); + count+=data[i]->GetSize (); if (!beginFound) { if (count > o) @@ -171,7 +171,7 @@ Ptr PendingData::CopyFromOffset (uint32_t s, uint32_t o) if (count >= o + s1) //then just copy within this packet { Ptr toFragment = data[i]; - uint32_t packetStart = count - toFragment->GetSize(); + uint32_t packetStart = count - toFragment->GetSize (); uint32_t packetOffset = o - packetStart; outPacket = toFragment->CreateFragment (packetOffset, s1); return outPacket; @@ -179,7 +179,7 @@ Ptr PendingData::CopyFromOffset (uint32_t s, uint32_t o) begin = i; beginFound = true; Ptr toFragment = data[begin]; - uint32_t packetStart = count - toFragment->GetSize(); + uint32_t packetStart = count - toFragment->GetSize (); uint32_t packetOffset = o - packetStart; uint32_t fragmentLength = count - o; outPacket = toFragment->CreateFragment (packetOffset, fragmentLength); @@ -191,9 +191,9 @@ Ptr PendingData::CopyFromOffset (uint32_t s, uint32_t o) { end = i; Ptr toFragment = data[end]; - uint32_t packetStart = count - toFragment->GetSize(); + uint32_t packetStart = count - toFragment->GetSize (); uint32_t fragmentLength = o + s1 - packetStart; - endFragment = toFragment->CreateFragment(0, fragmentLength); + endFragment = toFragment->CreateFragment (0, fragmentLength); break; } } @@ -204,9 +204,9 @@ Ptr PendingData::CopyFromOffset (uint32_t s, uint32_t o) } if (endFragment) { - outPacket->AddAtEnd(endFragment); + outPacket->AddAtEnd (endFragment); } - NS_ASSERT(outPacket->GetSize() == s1); + NS_ASSERT (outPacket->GetSize () == s1); return outPacket; } else @@ -218,7 +218,7 @@ Ptr PendingData::CopyFromOffset (uint32_t s, uint32_t o) Ptr PendingData::CopyFromSeq (uint32_t s, const SequenceNumber32& f, const SequenceNumber32& o) { NS_LOG_FUNCTION (this << s << f << o); - return CopyFromOffset (s, OffsetFromSeq(f,o)); + return CopyFromOffset (s, OffsetFromSeq (f,o)); } uint32_t diff --git a/src/internet/model/pending-data.h b/src/internet/model/pending-data.h index e1cac260e..50ced4e30 100644 --- a/src/internet/model/pending-data.h +++ b/src/internet/model/pending-data.h @@ -46,7 +46,7 @@ public: PendingData (uint8_t*, uint32_t&, Packet*); // Construct from serialized buffer PendingData (const PendingData&); // Copy constructor virtual ~PendingData (); // Destructor - uint32_t Size () const { return size;} + uint32_t Size () const { return size; } // Serialization uint8_t* Serialize (uint8_t*, uint32_t&); // Serialize to a buffer uint8_t* Construct (uint8_t*, uint32_t&); // Construct from buffer diff --git a/src/internet/model/rtt-estimator.cc b/src/internet/model/rtt-estimator.cc index f2bbc7cd9..542451c06 100644 --- a/src/internet/model/rtt-estimator.cc +++ b/src/internet/model/rtt-estimator.cc @@ -104,10 +104,10 @@ RttEstimator::RttEstimator () : next (1), history (), } RttEstimator::RttEstimator(const RttEstimator& c) - : Object (c), next(c.next), history(c.history), - m_maxMultiplier (c.m_maxMultiplier), est(c.est), - minrto(c.minrto), nSamples(c.nSamples), - multiplier(c.multiplier) + : Object (c), next (c.next), history (c.history), + m_maxMultiplier (c.m_maxMultiplier), est (c.est), + minrto (c.minrto), nSamples (c.nSamples), + multiplier (c.multiplier) { } @@ -151,14 +151,14 @@ Time RttEstimator::AckSeq (SequenceNumber32 a) if (!h.retx && a >= (h.seq + SequenceNumber32 (h.count))) { // Ok to use this sample m = Simulator::Now () - h.time; // Elapsed time - Measurement(m); // Log the measurement - ResetMultiplier(); // Reset multiplier on valid measurement + Measurement (m); // Log the measurement + ResetMultiplier (); // Reset multiplier on valid measurement } // Now delete all ack history with seq <= ack - while(history.size() > 0) + while(history.size () > 0) { RttHistory& h = history.front (); - if ((h.seq + SequenceNumber32(h.count)) > a) break; // Done removing + if ((h.seq + SequenceNumber32 (h.count)) > a) break; // Done removing history.pop_front (); // Remove } return m; diff --git a/src/internet/model/rtt-estimator.h b/src/internet/model/rtt-estimator.h index 858767310..24dac25a3 100644 --- a/src/internet/model/rtt-estimator.h +++ b/src/internet/model/rtt-estimator.h @@ -58,16 +58,16 @@ public: RttEstimator(const RttEstimator&); // Copy constructor virtual ~RttEstimator(); - virtual void SentSeq(SequenceNumber32, uint32_t); - virtual Time AckSeq(SequenceNumber32); - virtual void ClearSent(); - virtual void Measurement(Time t) = 0; - virtual Time RetransmitTimeout() = 0; - void Init(SequenceNumber32 s) { next = s;} - virtual Ptr Copy() const = 0; - virtual void IncreaseMultiplier(); - virtual void ResetMultiplier(); - virtual void Reset(); + virtual void SentSeq (SequenceNumber32, uint32_t); + virtual Time AckSeq (SequenceNumber32); + virtual void ClearSent (); + virtual void Measurement (Time t) = 0; + virtual Time RetransmitTimeout () = 0; + void Init (SequenceNumber32 s) { next = s; } + virtual Ptr Copy () const = 0; + virtual void IncreaseMultiplier (); + virtual void ResetMultiplier (); + virtual void Reset (); void SetMinRto (Time minRto); Time GetMinRto (void) const; @@ -107,7 +107,7 @@ public: Time RetransmitTimeout (); Ptr Copy () const; void Reset (); - void Gain (double g) { gain = g;} + void Gain (double g) { gain = g; } public: double gain; // Filter gain diff --git a/src/internet/model/sim_interface.h b/src/internet/model/sim_interface.h index 75d41dd88..271360bb5 100644 --- a/src/internet/model/sim_interface.h +++ b/src/internet/model/sim_interface.h @@ -26,25 +26,25 @@ struct INetStack { virtual ~INetStack() {} - virtual void init(int hz) = 0; + virtual void init (int hz) = 0; - virtual void if_receive_packet(int if_id, const void *data, int datalen) = 0; + virtual void if_receive_packet (int if_id, const void *data, int datalen) = 0; - virtual void if_send_packet(const void *data, int datalen) = 0; - virtual void if_send_finish(int if_id) = 0; + virtual void if_send_packet (const void *data, int datalen) = 0; + virtual void if_send_finish (int if_id) = 0; - virtual void if_attach(const char *addr, const char *mask, int mtu) = 0; - virtual void add_default_gateway(const char *addr) = 0; + virtual void if_attach (const char *addr, const char *mask, int mtu) = 0; + virtual void add_default_gateway (const char *addr) = 0; /** Purely for debugging/diagnostic purposes. This returns the internal id * of the stack instance. */ - virtual int get_id() = 0; + virtual int get_id () = 0; /** Should return a short one-word name of the stack. Eg. Linux 2.4.x -> * linux24, FreeBSD 5.x -> freebsd5. This can be used to identify output * from a stack, for example a packet trace file. */ - virtual const char *get_name() = 0; + virtual const char *get_name () = 0; /** This is used so the simulator can call the stack timer_interrupt function * the correct amount of times per second. For example, lwip has a hz of 10, @@ -52,21 +52,21 @@ struct INetStack * 10 times a second. FreeBSD uses 100, as does Linux 2.4, while Linux 2.6 * uses 1000. (This is often configurable in the kernel in question, also.) */ - virtual int get_hz() = 0; + virtual int get_hz () = 0; - virtual void timer_interrupt() = 0; - virtual void increment_ticks() = 0; + virtual void timer_interrupt () = 0; + virtual void increment_ticks () = 0; - virtual void buffer_size(int size) = 0; + virtual void buffer_size (int size) = 0; - virtual struct INetDatagramSocket *new_udp_socket() { return NULL; } - virtual struct INetStreamSocket *new_tcp_socket() { return NULL; } - virtual struct INetStreamSocket *new_sctp_socket() { return NULL; } + virtual struct INetDatagramSocket *new_udp_socket () { return NULL; } + virtual struct INetStreamSocket *new_tcp_socket () { return NULL; } + virtual struct INetStreamSocket *new_sctp_socket () { return NULL; } // The following I've made optional to implement for now. Eases // integration of new features. - virtual int sysctl(const char *sysctl_name, void *oldval, size_t *oldlenp, - void *newval, size_t newlen) + virtual int sysctl (const char *sysctl_name, void *oldval, size_t *oldlenp, + void *newval, size_t newlen) { return -1; } @@ -75,7 +75,7 @@ struct INetStack // to convert the string-value to something that the stack can handle. // The idea here is that this is a front-end to the sysctl(2) call, // much like the sysctl(8) program. - virtual int sysctl_set(const char *name, const char *value) + virtual int sysctl_set (const char *name, const char *value) { return -1; } @@ -83,7 +83,7 @@ struct INetStack // same as above, cradle code is expected to convert the sysctl value // into a string. // returns length of the string in value, i.e. retval > len: 'output truncated'. - virtual int sysctl_get(const char *name, char *value, size_t len) + virtual int sysctl_get (const char *name, char *value, size_t len) { return -1; } @@ -95,23 +95,23 @@ struct INetStack // for (i=0; sysctl_getnum(i, buf, sizeof(buf)) > 0 ;i++) // puts(buf); // returns -1 if idx is out of range and the length of the sysctl name otherwise. - virtual int sysctl_getnum(size_t idx, char *name, size_t len) + virtual int sysctl_getnum (size_t idx, char *name, size_t len) { return -1; } - virtual void show_config() + virtual void show_config () { ; } /* Optional functions used to get and set variables for this stack */ - virtual bool get_var(const char *var, char *result, int result_len) + virtual bool get_var (const char *var, char *result, int result_len) { return false; } - virtual bool set_var(const char *var, const char *val) + virtual bool set_var (const char *var, const char *val) { return false; } @@ -119,13 +119,13 @@ struct INetStack /** The level of debugging or diagnostic information to print out. This * normally means kernel messages printed out during initialisation but * may also include extra debugging messages that are part of NSC. */ - virtual void set_diagnostic(int level) {} + virtual void set_diagnostic (int level) {} /** Simple interface to support sending any textual command to a stack * * @returns 0 on success */ - virtual int cmd(const char *) + virtual int cmd (const char *) { return 1; } @@ -135,34 +135,34 @@ struct INetStreamSocket { virtual ~INetStreamSocket() {} - virtual void connect(const char *, int) = 0; - virtual void disconnect() = 0; - virtual void listen(int) = 0; - virtual int accept(INetStreamSocket **) = 0; - virtual int send_data(const void *data, int datalen) = 0; - virtual int read_data(void *buf, int *buflen) = 0; + virtual void connect (const char *, int) = 0; + virtual void disconnect () = 0; + virtual void listen (int) = 0; + virtual int accept (INetStreamSocket **) = 0; + virtual int send_data (const void *data, int datalen) = 0; + virtual int read_data (void *buf, int *buflen) = 0; /* We need to pass the option name in as a string here. The reason for * this is that different operating systems you compile on will have * different numbers defined for the constants SO_SNDBUF and so on. */ - virtual int setsockopt(char *optname, void *val, size_t valsize) = 0; - virtual void print_state(FILE *) = 0; - virtual bool is_connected() = 0; - virtual bool is_listening() = 0; + virtual int setsockopt (char *optname, void *val, size_t valsize) = 0; + virtual void print_state (FILE *) = 0; + virtual bool is_connected () = 0; + virtual bool is_listening () = 0; - virtual int getpeername(struct sockaddr *sa, size_t *salen) { + virtual int getpeername (struct sockaddr *sa, size_t *salen) { return -1; } - virtual int getsockname(struct sockaddr *sa, size_t *salen) { + virtual int getsockname (struct sockaddr *sa, size_t *salen) { return -1; } /* Optional functions used to get and set variables for this TCP * connection. */ - virtual bool get_var(const char *var, char *result, int result_len) + virtual bool get_var (const char *var, char *result, int result_len) { return false; } - virtual bool set_var(const char *var, const char *val) + virtual bool set_var (const char *var, const char *val) { return false; } @@ -172,29 +172,29 @@ struct INetDatagramSocket { virtual ~INetDatagramSocket() {} - virtual void set_destination(const char *, int) = 0; - virtual void send_data(const void *data, int datalen) = 0; + virtual void set_destination (const char *, int) = 0; + virtual void send_data (const void *data, int datalen) = 0; }; struct ISendCallback { virtual ~ISendCallback() {} - virtual void send_callback(const void *data, int datalen) = 0; + virtual void send_callback (const void *data, int datalen) = 0; }; struct IInterruptCallback { virtual ~IInterruptCallback() {} - virtual void wakeup() = 0; - virtual void gettime(unsigned int *, unsigned int *) = 0; + virtual void wakeup () = 0; + virtual void gettime (unsigned int *, unsigned int *) = 0; }; typedef int (*FRandom)(); typedef INetStack *(*FCreateStack)(ISendCallback *, IInterruptCallback *, FRandom); -#define CREATE_STACK_FUNC(a,b,c) extern "C" INetStack *nsc_create_stack( \ +#define CREATE_STACK_FUNC(a,b,c) extern "C" INetStack *nsc_create_stack ( \ ISendCallback *a, IInterruptCallback *b, FRandom c) #endif diff --git a/src/internet/model/tcp-header.cc b/src/internet/model/tcp-header.cc index e2670f0b0..0875399ec 100644 --- a/src/internet/model/tcp-header.cc +++ b/src/internet/model/tcp-header.cc @@ -37,8 +37,8 @@ TcpHeader::TcpHeader () m_flags (0), m_windowSize (0xffff), m_urgentPointer (0), - m_calcChecksum(false), - m_goodChecksum(true) + m_calcChecksum (false), + m_goodChecksum (true) { } @@ -221,11 +221,11 @@ void TcpHeader::Serialize (Buffer::Iterator start) const { uint16_t headerChecksum = CalculateHeaderChecksum (start.GetSize ()); i = start; - uint16_t checksum = i.CalculateIpChecksum(start.GetSize (), headerChecksum); + uint16_t checksum = i.CalculateIpChecksum (start.GetSize (), headerChecksum); i = start; - i.Next(16); - i.WriteU16(checksum); + i.Next (16); + i.WriteU16 (checksum); } } uint32_t TcpHeader::Deserialize (Buffer::Iterator start) @@ -246,7 +246,7 @@ uint32_t TcpHeader::Deserialize (Buffer::Iterator start) { uint16_t headerChecksum = CalculateHeaderChecksum (start.GetSize ()); i = start; - uint16_t checksum = i.CalculateIpChecksum(start.GetSize (), headerChecksum); + uint16_t checksum = i.CalculateIpChecksum (start.GetSize (), headerChecksum); m_goodChecksum = (checksum == 0); } diff --git a/src/internet/model/tcp-l4-protocol.cc b/src/internet/model/tcp-l4-protocol.cc index 1ef85dda5..e275a5376 100644 --- a/src/internet/model/tcp-l4-protocol.cc +++ b/src/internet/model/tcp-l4-protocol.cc @@ -65,12 +65,12 @@ TcpL4Protocol::GetTypeId (void) .AddConstructor () .AddAttribute ("RttEstimatorType", "Type of RttEstimator objects.", - TypeIdValue (RttMeanDeviation::GetTypeId()), + TypeIdValue (RttMeanDeviation::GetTypeId ()), MakeTypeIdAccessor (&TcpL4Protocol::m_rttTypeId), MakeTypeIdChecker ()) .AddAttribute ("SocketType", "Socket type of TCP objects.", - TypeIdValue (TcpNewReno::GetTypeId()), + TypeIdValue (TcpNewReno::GetTypeId ()), MakeTypeIdAccessor (&TcpL4Protocol::m_socketTypeId), MakeTypeIdChecker ()) .AddAttribute ("SocketList", "The list of sockets associated to this protocol.", @@ -85,7 +85,7 @@ TcpL4Protocol::TcpL4Protocol () : m_endPoints (new Ipv4EndPointDemux ()) { NS_LOG_FUNCTION_NOARGS (); - NS_LOG_LOGIC("Made a TcpL4Protocol "< tcpFactory = CreateObject (); tcpFactory->SetTcp (this); node->AggregateObject (tcpFactory); - this->SetDownTarget (MakeCallback(&Ipv4::Send, ipv4)); + this->SetDownTarget (MakeCallback (&Ipv4::Send, ipv4)); } } } @@ -160,8 +160,8 @@ TcpL4Protocol::CreateSocket (TypeId socketTypeId) NS_LOG_FUNCTION_NOARGS (); ObjectFactory rttFactory; ObjectFactory socketFactory; - rttFactory.SetTypeId(m_rttTypeId); - socketFactory.SetTypeId(socketTypeId); + rttFactory.SetTypeId (m_rttTypeId); + socketFactory.SetTypeId (socketTypeId); Ptr rtt = rttFactory.Create (); Ptr socket = socketFactory.Create (); socket->SetNode (m_node); @@ -231,21 +231,21 @@ TcpL4Protocol::Receive (Ptr packet, TcpHeader tcpHeader; if(Node::ChecksumEnabled ()) { - tcpHeader.EnableChecksums(); + tcpHeader.EnableChecksums (); tcpHeader.InitializeChecksum (ipHeader.GetSource (), ipHeader.GetDestination (), PROT_NUMBER); } packet->PeekHeader (tcpHeader); - NS_LOG_LOGIC("TcpL4Protocol " << this - << " receiving seq " << tcpHeader.GetSequenceNumber() - << " ack " << tcpHeader.GetAckNumber() - << " flags "<< std::hex << (int)tcpHeader.GetFlags() << std::dec - << " data size " << packet->GetSize()); + NS_LOG_LOGIC ("TcpL4Protocol " << this + << " receiving seq " << tcpHeader.GetSequenceNumber () + << " ack " << tcpHeader.GetAckNumber () + << " flags "<< std::hex << (int)tcpHeader.GetFlags () << std::dec + << " data size " << packet->GetSize ()); if(!tcpHeader.IsChecksumOk ()) { - NS_LOG_INFO("Bad checksum, dropping packet!"); + NS_LOG_INFO ("Bad checksum, dropping packet!"); return Ipv4L4Protocol::RX_CSUM_FAILED; } @@ -291,7 +291,7 @@ TcpL4Protocol::Receive (Ptr packet, return Ipv4L4Protocol::RX_ENDPOINT_CLOSED; } } - NS_ASSERT_MSG (endPoints.size() == 1, "Demux returned more than one endpoint"); + NS_ASSERT_MSG (endPoints.size () == 1, "Demux returned more than one endpoint"); NS_LOG_LOGIC ("TcpL4Protocol "<ForwardUp (packet, ipHeader, tcpHeader.GetSourcePort (), incomingInterface); @@ -310,7 +310,7 @@ TcpL4Protocol::Send (Ptr packet, tcpHeader.SetSourcePort (sport); if(Node::ChecksumEnabled ()) { - tcpHeader.EnableChecksums(); + tcpHeader.EnableChecksums (); } tcpHeader.InitializeChecksum (saddr, daddr, @@ -346,11 +346,11 @@ void TcpL4Protocol::SendPacket (Ptr packet, const TcpHeader &outgoing, Ipv4Address saddr, Ipv4Address daddr, Ptr oif) { - NS_LOG_LOGIC("TcpL4Protocol " << this - << " sending seq " << outgoing.GetSequenceNumber() - << " ack " << outgoing.GetAckNumber() - << " flags " << std::hex << (int)outgoing.GetFlags() << std::dec - << " data size " << packet->GetSize()); + NS_LOG_LOGIC ("TcpL4Protocol " << this + << " sending seq " << outgoing.GetSequenceNumber () + << " ack " << outgoing.GetAckNumber () + << " flags " << std::hex << (int)outgoing.GetFlags () << std::dec + << " data size " << packet->GetSize ()); NS_LOG_FUNCTION (this << packet << saddr << daddr << oif); // XXX outgoingHeader cannot be logged @@ -359,9 +359,9 @@ TcpL4Protocol::SendPacket (Ptr packet, const TcpHeader &outgoing, /* outgoingHeader.SetUrgentPointer (0); //XXX */ if(Node::ChecksumEnabled ()) { - outgoingHeader.EnableChecksums(); + outgoingHeader.EnableChecksums (); } - outgoingHeader.InitializeChecksum(saddr, daddr, PROT_NUMBER); + outgoingHeader.InitializeChecksum (saddr, daddr, PROT_NUMBER); packet->AddHeader (outgoingHeader); @@ -386,7 +386,7 @@ TcpL4Protocol::SendPacket (Ptr packet, const TcpHeader &outgoing, m_downTarget (packet, saddr, daddr, PROT_NUMBER, route); } else - NS_FATAL_ERROR("Trying to use Tcp on a node without an Ipv4 interface"); + NS_FATAL_ERROR ("Trying to use Tcp on a node without an Ipv4 interface"); } void diff --git a/src/internet/model/tcp-newreno.cc b/src/internet/model/tcp-newreno.cc index ebd38cadb..fd7d14b0f 100644 --- a/src/internet/model/tcp-newreno.cc +++ b/src/internet/model/tcp-newreno.cc @@ -113,7 +113,7 @@ TcpNewReno::NewAck (const SequenceNumber32& seq) { // Partial ACK, partial window deflation (RFC2582 sec.3 bullet #5 paragraph 3) m_cWnd += m_segmentSize; // increase cwnd NS_LOG_INFO ("Partial ACK in fast recovery: cwnd set to " << m_cWnd); - TcpSocketBase::NewAck(seq); // update m_nextTxSequence and send new data if allowed by window + TcpSocketBase::NewAck (seq); // update m_nextTxSequence and send new data if allowed by window DoRetransmit (); // Assume the next seq is lost. Retransmit lost packet return; } diff --git a/src/internet/model/tcp-rfc793.cc b/src/internet/model/tcp-rfc793.cc index 4c725f644..fcde5e315 100644 --- a/src/internet/model/tcp-rfc793.cc +++ b/src/internet/model/tcp-rfc793.cc @@ -40,7 +40,7 @@ TcpRfc793::GetTypeId (void) TcpRfc793::TcpRfc793 (void) { NS_LOG_FUNCTION (this); - SetDelAckMaxCount(0); // Delayed ACK is not in RFC793 + SetDelAckMaxCount (0); // Delayed ACK is not in RFC793 } TcpRfc793::TcpRfc793 (const TcpRfc793& sock) : TcpSocketBase (sock) diff --git a/src/internet/model/tcp-rx-buffer.cc b/src/internet/model/tcp-rx-buffer.cc index 8a2a5e350..fae478220 100644 --- a/src/internet/model/tcp-rx-buffer.cc +++ b/src/internet/model/tcp-rx-buffer.cc @@ -48,7 +48,7 @@ TcpRxBuffer::GetTypeId (void) * initialized below is insignificant. */ TcpRxBuffer::TcpRxBuffer (uint32_t n) - : m_nextRxSeq(n), m_gotFin(false), m_size(0), m_maxBuffer(32768), m_availBytes(0) + : m_nextRxSeq (n), m_gotFin (false), m_size (0), m_maxBuffer (32768), m_availBytes (0) { } @@ -112,7 +112,7 @@ TcpRxBuffer::MaxRxSequence (void) const } else if (m_data.size ()) { // No data allowed beyond Rx window allowed - return m_data.begin()->first + SequenceNumber32 (m_maxBuffer); + return m_data.begin ()->first + SequenceNumber32 (m_maxBuffer); } return m_nextRxSeq + SequenceNumber32 (m_maxBuffer); } @@ -161,7 +161,7 @@ TcpRxBuffer::Add (Ptr p, TcpHeader const& tcph) { if (i->first > headSeq && lastByteSeq < tailSeq) { // Rare case: Existing packet is embedded fully in the new packet - m_size -= i->second->GetSize(); + m_size -= i->second->GetSize (); m_data.erase (i++); continue; } @@ -256,7 +256,7 @@ TcpRxBuffer::Extract (uint32_t maxSize) NS_LOG_LOGIC ("Nothing extracted."); return 0; } - NS_LOG_LOGIC ("Extracted " << outPkt->GetSize( ) << " bytes, bufsize=" << m_size + NS_LOG_LOGIC ("Extracted " << outPkt->GetSize ( ) << " bytes, bufsize=" << m_size << ", num pkts in buffer=" << m_data.size ()); return outPkt; } diff --git a/src/internet/model/tcp-socket-base.cc b/src/internet/model/tcp-socket-base.cc index 351558c0c..0fa2e1f82 100644 --- a/src/internet/model/tcp-socket-base.cc +++ b/src/internet/model/tcp-socket-base.cc @@ -1099,7 +1099,7 @@ TcpSocketBase::DoPeerClose (void) } if (m_shutdownSend) { // The application declares that it would not sent any more, close this socket - Close(); + Close (); } else { // Need to ack, the application will close later @@ -1270,7 +1270,7 @@ bool TcpSocketBase::SendPendingData (bool withAck) { NS_LOG_FUNCTION (this << withAck); - if (m_txBuffer.Size () == 0) return false; // Nothing to send + if (m_txBuffer.Size () == 0) return false; // Nothing to send if (m_endPoint == 0) { NS_LOG_INFO ("TcpSocketBase::SendPendingData: No endpoint; m_shutdownSend=" << m_shutdownSend); @@ -1439,7 +1439,7 @@ TcpSocketBase::ReceivedData (Ptr p, const TcpHeader& tcpHeader) } // If we received FIN before and now completed all "holes" in rx buffer, // invoke peer close procedure - if (m_rxBuffer.Finished () && (tcpHeader.GetFlags() & TcpHeader::FIN) == 0) + if (m_rxBuffer.Finished () && (tcpHeader.GetFlags () & TcpHeader::FIN) == 0) { DoPeerClose (); } diff --git a/src/internet/model/tcp-tx-buffer.cc b/src/internet/model/tcp-tx-buffer.cc index e56405116..997fa4c7f 100644 --- a/src/internet/model/tcp-tx-buffer.cc +++ b/src/internet/model/tcp-tx-buffer.cc @@ -51,7 +51,7 @@ TcpTxBuffer::GetTypeId (void) * initialized below is insignificant. */ TcpTxBuffer::TcpTxBuffer (uint32_t n) - : m_firstByteSeq(n), m_size (0), m_maxBuffer(32768), m_data (0) + : m_firstByteSeq (n), m_size (0), m_maxBuffer (32768), m_data (0) { } diff --git a/src/internet/model/udp-header.cc b/src/internet/model/udp-header.cc index 95176dc71..999eae0e3 100644 --- a/src/internet/model/udp-header.cc +++ b/src/internet/model/udp-header.cc @@ -33,8 +33,8 @@ UdpHeader::UdpHeader () : m_sourcePort (0xfffd), m_destinationPort (0xfffd), m_payloadSize (0xfffd), - m_calcChecksum(false), - m_goodChecksum(true) + m_calcChecksum (false), + m_goodChecksum (true) { } UdpHeader::~UdpHeader () @@ -151,8 +151,8 @@ UdpHeader::Serialize (Buffer::Iterator start) const uint16_t checksum = i.CalculateIpChecksum (start.GetSize (), headerChecksum); i = start; - i.Next(6); - i.WriteU16(checksum); + i.Next (6); + i.WriteU16 (checksum); } } uint32_t diff --git a/src/internet/model/udp-l4-protocol.cc b/src/internet/model/udp-l4-protocol.cc index f971e5572..c7db24749 100644 --- a/src/internet/model/udp-l4-protocol.cc +++ b/src/internet/model/udp-l4-protocol.cc @@ -95,7 +95,7 @@ UdpL4Protocol::NotifyNewAggregate () Ptr udpFactory = CreateObject (); udpFactory->SetUdp (this); node->AggregateObject (udpFactory); - this->SetDownTarget (MakeCallback(&Ipv4::Send, ipv4)); + this->SetDownTarget (MakeCallback (&Ipv4::Send, ipv4)); } } } @@ -214,15 +214,15 @@ UdpL4Protocol::ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, } enum Ipv4L4Protocol::RxStatus -UdpL4Protocol::Receive(Ptr packet, - Ipv4Header const &header, - Ptr interface) +UdpL4Protocol::Receive (Ptr packet, + Ipv4Header const &header, + Ptr interface) { NS_LOG_FUNCTION (this << packet << header); UdpHeader udpHeader; if(Node::ChecksumEnabled ()) { - udpHeader.EnableChecksums(); + udpHeader.EnableChecksums (); } udpHeader.InitializeChecksum (header.GetSource (), header.GetDestination (), PROT_NUMBER); @@ -231,7 +231,7 @@ UdpL4Protocol::Receive(Ptr packet, if(!udpHeader.IsChecksumOk ()) { - NS_LOG_INFO("Bad checksum : dropping packet!"); + NS_LOG_INFO ("Bad checksum : dropping packet!"); return Ipv4L4Protocol::RX_CSUM_FAILED; } @@ -263,7 +263,7 @@ UdpL4Protocol::Send (Ptr packet, UdpHeader udpHeader; if(Node::ChecksumEnabled ()) { - udpHeader.EnableChecksums(); + udpHeader.EnableChecksums (); udpHeader.InitializeChecksum (saddr, daddr, PROT_NUMBER); @@ -286,7 +286,7 @@ UdpL4Protocol::Send (Ptr packet, UdpHeader udpHeader; if(Node::ChecksumEnabled ()) { - udpHeader.EnableChecksums(); + udpHeader.EnableChecksums (); udpHeader.InitializeChecksum (saddr, daddr, PROT_NUMBER); diff --git a/src/internet/model/udp-l4-protocol.h b/src/internet/model/udp-l4-protocol.h index ec665a453..8f5dc6cbd 100644 --- a/src/internet/model/udp-l4-protocol.h +++ b/src/internet/model/udp-l4-protocol.h @@ -89,9 +89,9 @@ public: * \param interface the interface from which the packet is coming. */ // inherited from Ipv4L4Protocol - virtual enum Ipv4L4Protocol::RxStatus Receive(Ptr p, - Ipv4Header const &header, - Ptr interface); + virtual enum Ipv4L4Protocol::RxStatus Receive (Ptr p, + Ipv4Header const &header, + Ptr interface); /** * \brief Receive an ICMP packet diff --git a/src/internet/model/udp-socket-impl.cc b/src/internet/model/udp-socket-impl.cc index 8a5eb225a..14571ef4a 100644 --- a/src/internet/model/udp-socket-impl.cc +++ b/src/internet/model/udp-socket-impl.cc @@ -225,7 +225,7 @@ UdpSocketImpl::Close (void) } int -UdpSocketImpl::Connect(const Address & address) +UdpSocketImpl::Connect (const Address & address) { NS_LOG_FUNCTION (this << address); InetSocketAddress transport = InetSocketAddress::ConvertFrom (address); @@ -306,7 +306,7 @@ UdpSocketImpl::DoSendTo (Ptr p, Ipv4Address dest, uint16_t port) NS_LOG_FUNCTION (this << p << dest << port); if (m_boundnetdevice) { - NS_LOG_LOGIC("Bound interface number " << m_boundnetdevice->GetIfIndex()); + NS_LOG_LOGIC ("Bound interface number " << m_boundnetdevice->GetIfIndex ()); } if (m_endPoint == 0) { @@ -394,7 +394,7 @@ UdpSocketImpl::DoSendTo (Ptr p, Ipv4Address dest, uint16_t port) // Check if interface-bound socket if (m_boundnetdevice) { - if (ipv4->GetNetDevice(i) != m_boundnetdevice) + if (ipv4->GetNetDevice (i) != m_boundnetdevice) continue; } Ipv4Mask maski = iaddr.GetMask (); @@ -421,15 +421,15 @@ UdpSocketImpl::DoSendTo (Ptr p, Ipv4Address dest, uint16_t port) } } NS_LOG_LOGIC ("Limited broadcast end."); - return p->GetSize(); + return p->GetSize (); } - else if (m_endPoint->GetLocalAddress() != Ipv4Address::GetAny()) + else if (m_endPoint->GetLocalAddress () != Ipv4Address::GetAny ()) { - m_udp->Send(p->Copy (), m_endPoint->GetLocalAddress(), dest, - m_endPoint->GetLocalPort(), port, 0); + m_udp->Send (p->Copy (), m_endPoint->GetLocalAddress (), dest, + m_endPoint->GetLocalPort (), port, 0); NotifyDataSent (p->GetSize ()); NotifySend (GetTxAvailable ()); - return p->GetSize(); + return p->GetSize (); } else if (ipv4->GetRoutingProtocol () != 0) { @@ -463,7 +463,7 @@ UdpSocketImpl::DoSendTo (Ptr p, Ipv4Address dest, uint16_t port) m_udp->Send (p->Copy (), header.GetSource (), header.GetDestination (), m_endPoint->GetLocalPort (), port, route); NotifyDataSent (p->GetSize ()); - return p->GetSize(); + return p->GetSize (); } else { @@ -517,7 +517,7 @@ Ptr UdpSocketImpl::Recv (uint32_t maxSize, uint32_t flags) { NS_LOG_FUNCTION (this << maxSize << flags); - if (m_deliveryQueue.empty() ) + if (m_deliveryQueue.empty () ) { m_errno = ERROR_AGAIN; return 0; @@ -561,13 +561,13 @@ UdpSocketImpl::GetSockName (Address &address) const NS_LOG_FUNCTION_NOARGS (); if (m_endPoint != 0) { - address = InetSocketAddress (m_endPoint->GetLocalAddress (), m_endPoint->GetLocalPort()); + address = InetSocketAddress (m_endPoint->GetLocalAddress (), m_endPoint->GetLocalPort ()); } else { // It is possible to call this method on a socket without a name // in which case, behavior is unspecified - address = InetSocketAddress(Ipv4Address::GetZero(), 0); + address = InetSocketAddress (Ipv4Address::GetZero (), 0); } return 0; } diff --git a/src/internet/model/udp-socket-impl.h b/src/internet/model/udp-socket-impl.h index 703b05bcb..c1709443a 100644 --- a/src/internet/model/udp-socket-impl.h +++ b/src/internet/model/udp-socket-impl.h @@ -67,7 +67,7 @@ public: virtual int Close (void); virtual int ShutdownSend (void); virtual int ShutdownRecv (void); - virtual int Connect(const Address &address); + virtual int Connect (const Address &address); virtual int Listen (void); virtual uint32_t GetTxAvailable (void) const; virtual int Send (Ptr p, uint32_t flags); diff --git a/src/internet/test/global-route-manager-impl-test-suite.cc b/src/internet/test/global-route-manager-impl-test-suite.cc index 6b7343365..450ceef6b 100644 --- a/src/internet/test/global-route-manager-impl-test-suite.cc +++ b/src/internet/test/global-route-manager-impl-test-suite.cc @@ -34,15 +34,15 @@ class GlobalRouteManagerImplTestCase : public TestCase { public: GlobalRouteManagerImplTestCase(); - virtual void DoRun(void); + virtual void DoRun (void); }; GlobalRouteManagerImplTestCase::GlobalRouteManagerImplTestCase() - : TestCase("GlobalRouteManagerImplTestCase") + : TestCase ("GlobalRouteManagerImplTestCase") { } void -GlobalRouteManagerImplTestCase::DoRun(void) +GlobalRouteManagerImplTestCase::DoRun (void) { CandidateQueue candidate; @@ -218,9 +218,9 @@ static class GlobalRouteManagerImplTestSuite : public TestSuite { public: GlobalRouteManagerImplTestSuite() - : TestSuite("global-route-manager-impl", UNIT) + : TestSuite ("global-route-manager-impl", UNIT) { - AddTestCase(new GlobalRouteManagerImplTestCase()); + AddTestCase (new GlobalRouteManagerImplTestCase ()); } } g_globalRoutingManagerImplTestSuite; diff --git a/src/internet/test/ipv4-address-helper-test-suite.cc b/src/internet/test/ipv4-address-helper-test-suite.cc index 55f370e3e..10f50a346 100644 --- a/src/internet/test/ipv4-address-helper-test-suite.cc +++ b/src/internet/test/ipv4-address-helper-test-suite.cc @@ -51,21 +51,21 @@ NetworkAllocatorHelperTestCase::DoRun (void) Ipv4AddressHelper h; h.SetBase ("1.0.0.0", "255.0.0.0"); - network = h.NewNetwork(); + network = h.NewNetwork (); NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("2.0.0.0"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("2.0.0.1"), "XXX"); h.SetBase ("0.1.0.0", "255.255.0.0"); - network = h.NewNetwork(); + network = h.NewNetwork (); NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.2.0.0"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.2.0.1"), "XXX"); h.SetBase ("0.0.1.0", "255.255.255.0"); - network = h.NewNetwork(); + network = h.NewNetwork (); NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.0.2.0"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.2.1"), "XXX"); } @@ -98,21 +98,21 @@ AddressAllocatorHelperTestCase::DoRun (void) Ipv4AddressHelper h; h.SetBase ("1.0.0.0", "255.0.0.0", "0.0.0.3"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("1.0.0.3"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("1.0.0.4"), "XXX"); h.SetBase ("0.1.0.0", "255.255.0.0", "0.0.0.3"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.1.0.3"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.1.0.4"), "XXX"); h.SetBase ("0.0.1.0", "255.255.255.0", "0.0.0.3"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.1.3"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.1.4"), "XXX"); } @@ -142,33 +142,33 @@ ResetAllocatorHelperTestCase::DoRun (void) // h.SetBase ("1.0.0.0", "255.0.0.0", "0.0.0.3"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("1.0.0.3"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("1.0.0.4"), "XXX"); - network = h.NewNetwork(); + network = h.NewNetwork (); NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("2.0.0.0"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("2.0.0.3"), "XXX"); h.SetBase ("0.1.0.0", "255.255.0.0", "0.0.0.3"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.1.0.3"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.1.0.4"), "XXX"); - network = h.NewNetwork(); + network = h.NewNetwork (); NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.2.0.0"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.2.0.3"), "XXX"); h.SetBase ("0.0.1.0", "255.255.255.0", "0.0.0.3"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.1.3"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.1.4"), "XXX"); - network = h.NewNetwork(); + network = h.NewNetwork (); NS_TEST_EXPECT_MSG_EQ (network, Ipv4Address ("0.0.2.0"), "XXX"); - address = h.NewAddress(); + address = h.NewAddress (); NS_TEST_EXPECT_MSG_EQ (address, Ipv4Address ("0.0.2.3"), "XXX"); } diff --git a/src/internet/test/ipv4-list-routing-test-suite.cc b/src/internet/test/ipv4-list-routing-test-suite.cc index 526780597..b0627124a 100644 --- a/src/internet/test/ipv4-list-routing-test-suite.cc +++ b/src/internet/test/ipv4-list-routing-test-suite.cc @@ -25,10 +25,10 @@ namespace ns3 { class Ipv4ARouting : public Ipv4RoutingProtocol { public: - Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} + Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0; } bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, - LocalDeliverCallback lcb, ErrorCallback ecb) { return false;} + LocalDeliverCallback lcb, ErrorCallback ecb) { return false; } void NotifyInterfaceUp (uint32_t interface) {} void NotifyInterfaceDown (uint32_t interface) {} void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address) {} @@ -39,10 +39,10 @@ public: class Ipv4BRouting : public Ipv4RoutingProtocol { public: - Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} + Ptr RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0; } bool RouteInput (Ptr p, const Ipv4Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, - LocalDeliverCallback lcb, ErrorCallback ecb) { return false;} + LocalDeliverCallback lcb, ErrorCallback ecb) { return false; } void NotifyInterfaceUp (uint32_t interface) {} void NotifyInterfaceDown (uint32_t interface) {} void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address) {} @@ -59,7 +59,7 @@ public: }; Ipv4ListRoutingNegativeTestCase::Ipv4ListRoutingNegativeTestCase() - : TestCase("Check negative priorities") + : TestCase ("Check negative priorities") { } void @@ -87,7 +87,7 @@ public: }; Ipv4ListRoutingPositiveTestCase::Ipv4ListRoutingPositiveTestCase() - : TestCase("Check positive priorities") + : TestCase ("Check positive priorities") { } void @@ -116,10 +116,10 @@ static class Ipv4ListRoutingTestSuite : public TestSuite { public: Ipv4ListRoutingTestSuite() - : TestSuite("ipv4-list-routing", UNIT) + : TestSuite ("ipv4-list-routing", UNIT) { - AddTestCase(new Ipv4ListRoutingPositiveTestCase()); - AddTestCase(new Ipv4ListRoutingNegativeTestCase()); + AddTestCase (new Ipv4ListRoutingPositiveTestCase ()); + AddTestCase (new Ipv4ListRoutingNegativeTestCase ()); } } g_ipv4ListRoutingTestSuite; diff --git a/src/internet/test/ipv4-packet-info-tag-test-suite.cc b/src/internet/test/ipv4-packet-info-tag-test-suite.cc index 19e3164fb..ca7808f74 100644 --- a/src/internet/test/ipv4-packet-info-tag-test-suite.cc +++ b/src/internet/test/ipv4-packet-info-tag-test-suite.cc @@ -55,7 +55,7 @@ AddInternetStack (Ptr node) { //ARP Ptr arp = CreateObject (); - node->AggregateObject(arp); + node->AggregateObject (arp); //IPV4 Ptr ipv4 = CreateObject (); //Routing for Ipv4 @@ -63,13 +63,13 @@ AddInternetStack (Ptr node) ipv4->SetRoutingProtocol (ipv4Routing); Ptr ipv4staticRouting = CreateObject (); ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0); - node->AggregateObject(ipv4); + node->AggregateObject (ipv4); //ICMP Ptr icmp = CreateObject (); - node->AggregateObject(icmp); + node->AggregateObject (icmp); //UDP Ptr udp = CreateObject (); - node->AggregateObject(udp); + node->AggregateObject (udp); } class Ipv4PacketInfoTagTest : public TestCase @@ -94,7 +94,7 @@ Ipv4PacketInfoTagTest::RxCb (Ptr socket) Ptr m_receivedPacket; availableData = socket->GetRxAvailable (); - m_receivedPacket = socket->Recv (std::numeric_limits::max(), 0); + m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); NS_TEST_ASSERT_MSG_EQ (availableData, m_receivedPacket->GetSize (), "Did not read expected data"); Ipv4PacketInfoTag tag; @@ -106,7 +106,7 @@ Ipv4PacketInfoTagTest::RxCb (Ptr socket) void Ipv4PacketInfoTagTest::DoSendData (Ptr socket, std::string to) { - Address realTo = InetSocketAddress (Ipv4Address (to.c_str()), 200); + Address realTo = InetSocketAddress (Ipv4Address (to.c_str ()), 200); if (DynamicCast (socket) != 0) { NS_TEST_EXPECT_MSG_EQ (socket->SendTo (Create (123), 0, realTo), diff --git a/src/internet/test/ipv4-raw-test.cc b/src/internet/test/ipv4-raw-test.cc index e6ca8dda0..39a6f539a 100644 --- a/src/internet/test/ipv4-raw-test.cc +++ b/src/internet/test/ipv4-raw-test.cc @@ -51,7 +51,7 @@ AddInternetStack (Ptr node) { //ARP Ptr arp = CreateObject (); - node->AggregateObject(arp); + node->AggregateObject (arp); //IPV4 Ptr ipv4 = CreateObject (); //Routing for Ipv4 @@ -59,10 +59,10 @@ AddInternetStack (Ptr node) ipv4->SetRoutingProtocol (ipv4Routing); Ptr ipv4staticRouting = CreateObject (); ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0); - node->AggregateObject(ipv4); + node->AggregateObject (ipv4); //ICMP Ptr icmp = CreateObject (); - node->AggregateObject(icmp); + node->AggregateObject (icmp); // //Ipv4Raw // Ptr udp = CreateObject (); // node->AggregateObject(udp); @@ -110,7 +110,7 @@ void Ipv4RawSocketImplTest::ReceivePkt (Ptr socket) availableData = socket->GetRxAvailable (); m_receivedPacket = socket->Recv (2, MSG_PEEK); NS_ASSERT (m_receivedPacket->GetSize () == 2); - m_receivedPacket = socket->Recv (std::numeric_limits::max(), 0); + m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); NS_ASSERT (availableData == m_receivedPacket->GetSize ()); //cast availableData to void, to suppress 'availableData' set but not used //compiler warning @@ -123,7 +123,7 @@ void Ipv4RawSocketImplTest::ReceivePkt2 (Ptr socket) availableData = socket->GetRxAvailable (); m_receivedPacket2 = socket->Recv (2, MSG_PEEK); NS_ASSERT (m_receivedPacket2->GetSize () == 2); - m_receivedPacket2 = socket->Recv (std::numeric_limits::max(), 0); + m_receivedPacket2 = socket->Recv (std::numeric_limits::max (), 0); NS_ASSERT (availableData == m_receivedPacket2->GetSize ()); //cast availableData to void, to suppress 'availableData' set but not used //compiler warning @@ -133,7 +133,7 @@ void Ipv4RawSocketImplTest::ReceivePkt2 (Ptr socket) void Ipv4RawSocketImplTest::DoSendData (Ptr socket, std::string to) { - Address realTo = InetSocketAddress (Ipv4Address(to.c_str()), 0); + Address realTo = InetSocketAddress (Ipv4Address (to.c_str ()), 0); NS_TEST_EXPECT_MSG_EQ (socket->SendTo (Create (123), 0, realTo), 123, to); } @@ -151,7 +151,7 @@ Ipv4RawSocketImplTest::SendData (Ptr socket, std::string to) void Ipv4RawSocketImplTest::DoSendData_IpHdr (Ptr socket, std::string to) { - Address realTo = InetSocketAddress (Ipv4Address(to.c_str()), 0); + Address realTo = InetSocketAddress (Ipv4Address (to.c_str ()), 0); socket->SetAttribute ("IpHeaderInclude", BooleanValue (true)); Ptr p = Create (123); Ipv4Header ipHeader; diff --git a/src/internet/test/ipv6-extension-header-test-suite.cc b/src/internet/test/ipv6-extension-header-test-suite.cc index 01c107670..b7105f736 100644 --- a/src/internet/test/ipv6-extension-header-test-suite.cc +++ b/src/internet/test/ipv6-extension-header-test-suite.cc @@ -36,19 +36,19 @@ using namespace ns3; class TestEmptyOptionField : public TestCase { public: - TestEmptyOptionField () : TestCase("TestEmptyOptionField") {} + TestEmptyOptionField () : TestCase ("TestEmptyOptionField") {} - virtual void DoRun() + virtual void DoRun () { Ipv6ExtensionDestinationHeader header; - NS_TEST_EXPECT_MSG_EQ(header.GetSerializedSize() % 8, 0, "length of extension header is not a multiple of 8"); + NS_TEST_EXPECT_MSG_EQ (header.GetSerializedSize () % 8, 0, "length of extension header is not a multiple of 8"); Buffer buf; - buf.AddAtStart(header.GetSerializedSize()); - header.Serialize(buf.Begin()); + buf.AddAtStart (header.GetSerializedSize ()); + header.Serialize (buf.Begin ()); - const uint8_t* data = buf.PeekData(); - NS_TEST_EXPECT_MSG_EQ(*(data+2), 1, "padding is missing"); //expecting a padN header + const uint8_t* data = buf.PeekData (); + NS_TEST_EXPECT_MSG_EQ (*(data+2), 1, "padding is missing"); //expecting a padN header } }; @@ -73,9 +73,9 @@ public: virtual void Serialize (Buffer::Iterator start) const { - start.WriteU8(TYPE); - start.WriteU8(GetSerializedSize()-2); - start.WriteU16(0); + start.WriteU8 (TYPE); + start.WriteU8 (GetSerializedSize ()-2); + start.WriteU16 (0); } }; @@ -83,23 +83,23 @@ public: class TestOptionWithoutAlignment : public TestCase { public: - TestOptionWithoutAlignment () : TestCase("TestOptionWithoutAlignment") {} + TestOptionWithoutAlignment () : TestCase ("TestOptionWithoutAlignment") {} - virtual void DoRun() + virtual void DoRun () { Ipv6ExtensionDestinationHeader header; OptionWithoutAlignmentHeader optionHeader; - header.AddOption(optionHeader); + header.AddOption (optionHeader); - NS_TEST_EXPECT_MSG_EQ(header.GetSerializedSize() % 8, 0, "length of extension header is not a multiple of 8"); + NS_TEST_EXPECT_MSG_EQ (header.GetSerializedSize () % 8, 0, "length of extension header is not a multiple of 8"); Buffer buf; - buf.AddAtStart(header.GetSerializedSize()); - header.Serialize(buf.Begin()); + buf.AddAtStart (header.GetSerializedSize ()); + header.Serialize (buf.Begin ()); - const uint8_t* data = buf.PeekData(); - NS_TEST_EXPECT_MSG_EQ(*(data+2), OptionWithoutAlignmentHeader::TYPE, "option without alignment is not first in header field"); + const uint8_t* data = buf.PeekData (); + NS_TEST_EXPECT_MSG_EQ (*(data+2), OptionWithoutAlignmentHeader::TYPE, "option without alignment is not first in header field"); } }; @@ -129,12 +129,12 @@ public: virtual void Serialize (Buffer::Iterator start) const { - start.WriteU8(TYPE); - start.WriteU8(GetSerializedSize()-2); - start.WriteU16(0); + start.WriteU8 (TYPE); + start.WriteU8 (GetSerializedSize ()-2); + start.WriteU16 (0); } - virtual Alignment GetAlignment() const + virtual Alignment GetAlignment () const { return (Alignment){ 4,0}; } @@ -144,27 +144,27 @@ public: class TestOptionWithAlignment : public TestCase { public: - TestOptionWithAlignment () : TestCase("TestOptionWithAlignment") {} + TestOptionWithAlignment () : TestCase ("TestOptionWithAlignment") {} - virtual void DoRun() + virtual void DoRun () { Ipv6ExtensionDestinationHeader header; OptionWithAlignmentHeader optionHeader; - header.AddOption(optionHeader); + header.AddOption (optionHeader); Ipv6OptionJumbogramHeader jumboHeader; //has an alignment of 4n+2 - header.AddOption(jumboHeader); + header.AddOption (jumboHeader); - NS_TEST_EXPECT_MSG_EQ(header.GetSerializedSize() % 8, 0, "length of extension header is not a multiple of 8"); + NS_TEST_EXPECT_MSG_EQ (header.GetSerializedSize () % 8, 0, "length of extension header is not a multiple of 8"); Buffer buf; - buf.AddAtStart(header.GetSerializedSize()); - header.Serialize(buf.Begin()); + buf.AddAtStart (header.GetSerializedSize ()); + header.Serialize (buf.Begin ()); - const uint8_t* data = buf.PeekData(); - NS_TEST_EXPECT_MSG_EQ(*(data+2), 1, "padding is missing"); //expecting a padN header - NS_TEST_EXPECT_MSG_EQ(*(data+4), OptionWithAlignmentHeader::TYPE, "option with alignment is not padded correctly"); - NS_TEST_EXPECT_MSG_EQ(*(data+8), 1, "padding is missing"); //expecting a padN header - NS_TEST_EXPECT_MSG_EQ(*(data+10), jumboHeader.GetType(), "option with alignment is not padded correctly"); + const uint8_t* data = buf.PeekData (); + NS_TEST_EXPECT_MSG_EQ (*(data+2), 1, "padding is missing"); //expecting a padN header + NS_TEST_EXPECT_MSG_EQ (*(data+4), OptionWithAlignmentHeader::TYPE, "option with alignment is not padded correctly"); + NS_TEST_EXPECT_MSG_EQ (*(data+8), 1, "padding is missing"); //expecting a padN header + NS_TEST_EXPECT_MSG_EQ (*(data+10), jumboHeader.GetType (), "option with alignment is not padded correctly"); } }; @@ -187,25 +187,25 @@ public: class TestFulfilledAlignment : public TestCase { public: - TestFulfilledAlignment () : TestCase("TestCorrectAlignment") {} + TestFulfilledAlignment () : TestCase ("TestCorrectAlignment") {} - virtual void DoRun() + virtual void DoRun () { Ipv6ExtensionDestinationHeader header; Ipv6OptionJumbogramHeader jumboHeader; //has an alignment of 4n+2 - header.AddOption(jumboHeader); + header.AddOption (jumboHeader); OptionWithAlignmentHeader optionHeader; - header.AddOption(optionHeader); + header.AddOption (optionHeader); - NS_TEST_EXPECT_MSG_EQ(header.GetSerializedSize() % 8, 0, "length of extension header is not a multiple of 8"); + NS_TEST_EXPECT_MSG_EQ (header.GetSerializedSize () % 8, 0, "length of extension header is not a multiple of 8"); Buffer buf; - buf.AddAtStart(header.GetSerializedSize()); - header.Serialize(buf.Begin()); + buf.AddAtStart (header.GetSerializedSize ()); + header.Serialize (buf.Begin ()); - const uint8_t* data = buf.PeekData(); - NS_TEST_EXPECT_MSG_EQ(*(data+2), jumboHeader.GetType(), "option with fulfilled alignment is padded anyway"); - NS_TEST_EXPECT_MSG_EQ(*(data+8), OptionWithAlignmentHeader::TYPE, "option with fulfilled alignment is padded anyway"); + const uint8_t* data = buf.PeekData (); + NS_TEST_EXPECT_MSG_EQ (*(data+2), jumboHeader.GetType (), "option with fulfilled alignment is padded anyway"); + NS_TEST_EXPECT_MSG_EQ (*(data+8), OptionWithAlignmentHeader::TYPE, "option with fulfilled alignment is padded anyway"); } }; diff --git a/src/internet/test/ipv6-list-routing-test-suite.cc b/src/internet/test/ipv6-list-routing-test-suite.cc index 37f0c7288..38467988b 100644 --- a/src/internet/test/ipv6-list-routing-test-suite.cc +++ b/src/internet/test/ipv6-list-routing-test-suite.cc @@ -26,10 +26,10 @@ namespace ns3 { class Ipv6ARouting : public Ipv6RoutingProtocol { public: - Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} + Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0; } bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, - LocalDeliverCallback lcb, ErrorCallback ecb) { return false;} + LocalDeliverCallback lcb, ErrorCallback ecb) { return false; } void NotifyInterfaceUp (uint32_t interface) {} void NotifyInterfaceDown (uint32_t interface) {} void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) {} @@ -42,10 +42,10 @@ public: class Ipv6BRouting : public Ipv6RoutingProtocol { public: - Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0;} + Ptr RouteOutput (Ptr p, const Ipv6Header &header, Ptr oif, Socket::SocketErrno &sockerr) { return 0; } bool RouteInput (Ptr p, const Ipv6Header &header, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, - LocalDeliverCallback lcb, ErrorCallback ecb) { return false;} + LocalDeliverCallback lcb, ErrorCallback ecb) { return false; } void NotifyInterfaceUp (uint32_t interface) {} void NotifyInterfaceDown (uint32_t interface) {} void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) {} @@ -64,7 +64,7 @@ public: }; Ipv6ListRoutingNegativeTestCase::Ipv6ListRoutingNegativeTestCase() - : TestCase("Check negative priorities") + : TestCase ("Check negative priorities") { } void @@ -92,7 +92,7 @@ public: }; Ipv6ListRoutingPositiveTestCase::Ipv6ListRoutingPositiveTestCase() - : TestCase("Check positive priorities") + : TestCase ("Check positive priorities") { } void @@ -121,10 +121,10 @@ static class Ipv6ListRoutingTestSuite : public TestSuite { public: Ipv6ListRoutingTestSuite() - : TestSuite("ipv6-list-routing", UNIT) + : TestSuite ("ipv6-list-routing", UNIT) { - AddTestCase(new Ipv6ListRoutingPositiveTestCase()); - AddTestCase(new Ipv6ListRoutingNegativeTestCase()); + AddTestCase (new Ipv6ListRoutingPositiveTestCase ()); + AddTestCase (new Ipv6ListRoutingNegativeTestCase ()); } } g_ipv6ListRoutingTestSuite; diff --git a/src/internet/test/ipv6-packet-info-tag-test-suite.cc b/src/internet/test/ipv6-packet-info-tag-test-suite.cc index 48e4ea4f6..e52985e1b 100644 --- a/src/internet/test/ipv6-packet-info-tag-test-suite.cc +++ b/src/internet/test/ipv6-packet-info-tag-test-suite.cc @@ -90,7 +90,7 @@ Ipv6PacketInfoTagTest::RxCb (Ptr socket) Ptr m_receivedPacket; availableData = socket->GetRxAvailable (); - m_receivedPacket = socket->Recv (std::numeric_limits::max(), 0); + m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); NS_TEST_ASSERT_MSG_EQ (availableData, m_receivedPacket->GetSize (), "Did not read expected data"); Ipv6PacketInfoTag tag; @@ -102,7 +102,7 @@ Ipv6PacketInfoTagTest::RxCb (Ptr socket) void Ipv6PacketInfoTagTest::DoSendData (Ptr socket, std::string to) { - Address realTo = Inet6SocketAddress (Ipv6Address (to.c_str()), 200); + Address realTo = Inet6SocketAddress (Ipv6Address (to.c_str ()), 200); if (DynamicCast (socket) != 0) { NS_TEST_EXPECT_MSG_EQ (socket->SendTo (Create (123), 0, realTo), @@ -130,8 +130,8 @@ Ipv6PacketInfoTagTest::DoRun (void) Ptr ipv6 = node0->GetObject (); uint32_t index = ipv6->AddInterface (device); - Ipv6InterfaceAddress ifaceAddr1 = Ipv6InterfaceAddress (Ipv6Address("2000:1000:0:2000::1"), - Ipv6Prefix(64)); + Ipv6InterfaceAddress ifaceAddr1 = Ipv6InterfaceAddress (Ipv6Address ("2000:1000:0:2000::1"), + Ipv6Prefix (64)); ipv6->AddAddress (index, ifaceAddr1); ipv6->SetMetric (index, 1); ipv6->SetUp (index); @@ -142,8 +142,8 @@ Ipv6PacketInfoTagTest::DoRun (void) ipv6 = node1->GetObject (); index = ipv6->AddInterface (device2); - Ipv6InterfaceAddress ifaceAddr2 = Ipv6InterfaceAddress (Ipv6Address("2000:1000:0:2000::2"), - Ipv6Prefix(64)); + Ipv6InterfaceAddress ifaceAddr2 = Ipv6InterfaceAddress (Ipv6Address ("2000:1000:0:2000::2"), + Ipv6Prefix (64)); ipv6->AddAddress (index, ifaceAddr2); ipv6->SetMetric (index, 1); ipv6->SetUp (index); diff --git a/src/internet/test/tcp-test.cc b/src/internet/test/tcp-test.cc index 818c771d4..6fe72989b 100644 --- a/src/internet/test/tcp-test.cc +++ b/src/internet/test/tcp-test.cc @@ -44,7 +44,7 @@ #include -NS_LOG_COMPONENT_DEFINE("TcpTestSuite"); +NS_LOG_COMPONENT_DEFINE ("TcpTestSuite"); namespace ns3 { @@ -255,7 +255,7 @@ TcpTestCase::CreateInternetNode () Ptr node = CreateObject (); //ARP Ptr arp = CreateObject (); - node->AggregateObject(arp); + node->AggregateObject (arp); //IPV4 Ptr ipv4 = CreateObject (); //Routing for Ipv4 @@ -263,16 +263,16 @@ TcpTestCase::CreateInternetNode () ipv4->SetRoutingProtocol (ipv4Routing); Ptr ipv4staticRouting = CreateObject (); ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0); - node->AggregateObject(ipv4); + node->AggregateObject (ipv4); //ICMP Ptr icmp = CreateObject (); - node->AggregateObject(icmp); + node->AggregateObject (icmp); //UDP Ptr udp = CreateObject (); - node->AggregateObject(udp); + node->AggregateObject (udp); //TCP Ptr tcp = CreateObject (); - node->AggregateObject(tcp); + node->AggregateObject (tcp); return node; } @@ -308,22 +308,22 @@ TcpTestCase::SetupDefaultSim (void) Ptr sockFactory0 = node0->GetObject (); Ptr sockFactory1 = node1->GetObject (); - Ptr server = sockFactory0->CreateSocket(); - Ptr source = sockFactory1->CreateSocket(); + Ptr server = sockFactory0->CreateSocket (); + Ptr source = sockFactory1->CreateSocket (); uint16_t port = 50000; - InetSocketAddress serverlocaladdr (Ipv4Address::GetAny(), port); - InetSocketAddress serverremoteaddr (Ipv4Address(ipaddr0), port); + InetSocketAddress serverlocaladdr (Ipv4Address::GetAny (), port); + InetSocketAddress serverremoteaddr (Ipv4Address (ipaddr0), port); - server->Bind(serverlocaladdr); + server->Bind (serverlocaladdr); server->Listen (); server->SetAcceptCallback (MakeNullCallback, const Address &> (), - MakeCallback(&TcpTestCase::ServerHandleConnectionCreated,this)); + MakeCallback (&TcpTestCase::ServerHandleConnectionCreated,this)); - source->SetRecvCallback (MakeCallback(&TcpTestCase::SourceHandleRecv, this)); + source->SetRecvCallback (MakeCallback (&TcpTestCase::SourceHandleRecv, this)); source->SetSendCallback (MakeCallback (&TcpTestCase::SourceHandleSend, this)); - source->Connect(serverremoteaddr); + source->Connect (serverremoteaddr); } static class TcpTestSuite : public TestSuite diff --git a/src/internet/test/udp-test.cc b/src/internet/test/udp-test.cc index 107053af7..a00fa9267 100644 --- a/src/internet/test/udp-test.cc +++ b/src/internet/test/udp-test.cc @@ -52,7 +52,7 @@ AddInternetStack (Ptr node) { //ARP Ptr arp = CreateObject (); - node->AggregateObject(arp); + node->AggregateObject (arp); //IPV4 Ptr ipv4 = CreateObject (); //Routing for Ipv4 @@ -60,16 +60,16 @@ AddInternetStack (Ptr node) ipv4->SetRoutingProtocol (ipv4Routing); Ptr ipv4staticRouting = CreateObject (); ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0); - node->AggregateObject(ipv4); + node->AggregateObject (ipv4); //ICMP Ptr icmp = CreateObject (); - node->AggregateObject(icmp); + node->AggregateObject (icmp); //UDP Ptr udp = CreateObject (); - node->AggregateObject(udp); + node->AggregateObject (udp); //TCP Ptr tcp = CreateObject (); - node->AggregateObject(tcp); + node->AggregateObject (tcp); } @@ -92,7 +92,7 @@ void UdpSocketLoopbackTest::ReceivePkt (Ptr socket) { uint32_t availableData; availableData = socket->GetRxAvailable (); - m_receivedPacket = socket->Recv (std::numeric_limits::max(), 0); + m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); NS_ASSERT (availableData == m_receivedPacket->GetSize ()); //cast availableData to void, to suppress 'availableData' set but not used //compiler warning @@ -107,7 +107,7 @@ UdpSocketLoopbackTest::DoRun () Ptr rxSocketFactory = rxNode->GetObject (); Ptr rxSocket = rxSocketFactory->CreateSocket (); - rxSocket->Bind (InetSocketAddress (Ipv4Address::GetAny(), 80)); + rxSocket->Bind (InetSocketAddress (Ipv4Address::GetAny (), 80)); rxSocket->SetRecvCallback (MakeCallback (&UdpSocketLoopbackTest::ReceivePkt, this)); Ptr txSocket = rxSocketFactory->CreateSocket (); @@ -153,7 +153,7 @@ void UdpSocketImplTest::ReceivePkt (Ptr socket) { uint32_t availableData; availableData = socket->GetRxAvailable (); - m_receivedPacket = socket->Recv (std::numeric_limits::max(), 0); + m_receivedPacket = socket->Recv (std::numeric_limits::max (), 0); NS_ASSERT (availableData == m_receivedPacket->GetSize ()); //cast availableData to void, to suppress 'availableData' set but not used //compiler warning @@ -164,7 +164,7 @@ void UdpSocketImplTest::ReceivePkt2 (Ptr socket) { uint32_t availableData; availableData = socket->GetRxAvailable (); - m_receivedPacket2 = socket->Recv (std::numeric_limits::max(), 0); + m_receivedPacket2 = socket->Recv (std::numeric_limits::max (), 0); NS_ASSERT (availableData == m_receivedPacket2->GetSize ()); //cast availableData to void, to suppress 'availableData' set but not used //compiler warning @@ -174,7 +174,7 @@ void UdpSocketImplTest::ReceivePkt2 (Ptr socket) void UdpSocketImplTest::DoSendData (Ptr socket, std::string to) { - Address realTo = InetSocketAddress (Ipv4Address(to.c_str()), 1234); + Address realTo = InetSocketAddress (Ipv4Address (to.c_str ()), 1234); NS_TEST_EXPECT_MSG_EQ (socket->SendTo (Create (123), 0, realTo), 123, "XXX"); } diff --git a/src/lte/model/discrete-time-loss-model.cc b/src/lte/model/discrete-time-loss-model.cc index 9a3feda92..bffbbe5da 100644 --- a/src/lte/model/discrete-time-loss-model.cc +++ b/src/lte/model/discrete-time-loss-model.cc @@ -55,7 +55,7 @@ void DiscreteTimeLossModel::SetLastUpdate (void) { NS_LOG_FUNCTION (this); - m_lastUpdate = Simulator::Now () ; + m_lastUpdate = Simulator::Now (); } diff --git a/src/lte/model/lte-enb-net-device.cc b/src/lte/model/lte-enb-net-device.cc index a4b942efa..4988bd3e4 100644 --- a/src/lte/model/lte-enb-net-device.cc +++ b/src/lte/model/lte-enb-net-device.cc @@ -51,7 +51,7 @@ uint16_t LteEnbNetDevice::m_cellIdCounter = 0; TypeId LteEnbNetDevice::GetTypeId (void) { static TypeId - tid = + tid = TypeId ("ns3::LteEnbNetDevice") .SetParent () .AddConstructor () diff --git a/src/lte/model/lte-net-device.cc b/src/lte/model/lte-net-device.cc index 5ffa10226..261f56c0a 100644 --- a/src/lte/model/lte-net-device.cc +++ b/src/lte/model/lte-net-device.cc @@ -44,7 +44,7 @@ NS_OBJECT_ENSURE_REGISTERED ( LteNetDevice); TypeId LteNetDevice::GetTypeId (void) { static TypeId - tid = + tid = TypeId ("ns3::LteNetDevice") .SetParent () diff --git a/src/lte/model/lte-ue-net-device.cc b/src/lte/model/lte-ue-net-device.cc index 94803e4c0..7b2f89ab0 100644 --- a/src/lte/model/lte-ue-net-device.cc +++ b/src/lte/model/lte-ue-net-device.cc @@ -53,7 +53,7 @@ uint64_t LteUeNetDevice::m_imsiCounter = 0; TypeId LteUeNetDevice::GetTypeId (void) { static TypeId - tid = + tid = TypeId ("ns3::LteUeNetDevice") .SetParent () .AddAttribute ("LteUeRrc", diff --git a/src/mesh/examples/mesh.cc b/src/mesh/examples/mesh.cc index ee77d69b1..e28236f1b 100644 --- a/src/mesh/examples/mesh.cc +++ b/src/mesh/examples/mesh.cc @@ -175,7 +175,7 @@ MeshTest::CreateNodes () { mesh.SetSpreadInterfaceChannels (MeshHelper::ZERO_CHANNEL); } - mesh.SetMacType ("RandomStart", TimeValue (Seconds(m_randomStart))); + mesh.SetMacType ("RandomStart", TimeValue (Seconds (m_randomStart))); // Set number of interfaces - default is single-interface mesh point mesh.SetNumberOfInterfaces (m_nIfaces); // Install protocols and return container if MeshPointDevices @@ -224,7 +224,7 @@ MeshTest::Run () CreateNodes (); InstallInternetStack (); InstallApplication (); - Simulator::Schedule (Seconds(m_totalTime), &MeshTest::Report, this); + Simulator::Schedule (Seconds (m_totalTime), &MeshTest::Report, this); Simulator::Stop (Seconds (m_totalTime)); Simulator::Run (); Simulator::Destroy (); @@ -240,10 +240,10 @@ MeshTest::Report () os << "mp-report-" << n << ".xml"; std::cerr << "Printing mesh point device #" << n << " diagnostics to " << os.str () << "\n"; std::ofstream of; - of.open (os.str().c_str()); + of.open (os.str ().c_str ()); if (!of.is_open ()) { - std::cerr << "Error: Can't open file " << os.str() << "\n"; + std::cerr << "Error: Can't open file " << os.str () << "\n"; return; } mesh.Report (*i, of); @@ -255,5 +255,5 @@ main (int argc, char *argv[]) { MeshTest t; t.Configure (argc, argv); - return t.Run(); + return t.Run (); } diff --git a/src/mesh/helper/dot11s/dot11s-installer.cc b/src/mesh/helper/dot11s/dot11s-installer.cc index ac901a911..b82297fbc 100644 --- a/src/mesh/helper/dot11s/dot11s-installer.cc +++ b/src/mesh/helper/dot11s/dot11s-installer.cc @@ -68,7 +68,7 @@ Dot11sStack::InstallStack (Ptr mp) { return false; } - if (mp->GetAddress() == m_root) + if (mp->GetAddress () == m_root) { hwmp->SetRoot (); } diff --git a/src/mesh/model/dot11s/airtime-metric.cc b/src/mesh/model/dot11s/airtime-metric.cc index 86e81833d..747622223 100644 --- a/src/mesh/model/dot11s/airtime-metric.cc +++ b/src/mesh/model/dot11s/airtime-metric.cc @@ -89,6 +89,11 @@ AirtimeLinkMetricCalculator::CalculateMetric (Mac48Address peerAddress, PtrGetWifiRemoteStationManager ()->GetDataMode (peerAddress, &m_testHeader, m_testFrame, m_testFrame->GetSize ()); //obtain frame error rate: double failAvg = mac->GetWifiRemoteStationManager ()->GetInfo (peerAddress).GetFrameErrorRate (); + if (failAvg == 1) + { + // Retrun max metric value when frame error rate equals to 1 + return (uint32_t)0xffffffff; + } NS_ASSERT (failAvg < 1.0); //calculate metric uint32_t metric = (uint32_t)((double)( /*Overhead + payload*/ diff --git a/src/mesh/model/dot11s/hwmp-protocol-mac.cc b/src/mesh/model/dot11s/hwmp-protocol-mac.cc index f9e028e59..22b043270 100644 --- a/src/mesh/model/dot11s/hwmp-protocol-mac.cc +++ b/src/mesh/model/dot11s/hwmp-protocol-mac.cc @@ -104,7 +104,7 @@ HwmpProtocolMac::ReceiveAction (Ptr packet, const WifiMacHeader & header MeshInformationElementVector elements; packet->RemoveHeader (elements); std::vector failedDestinations; - for (MeshInformationElementVector::Iterator i = elements.Begin(); i != elements.End(); i++) + for (MeshInformationElementVector::Iterator i = elements.Begin (); i != elements.End (); i++) { if ((*i)->ElementId () == IE11S_RANN) { @@ -227,9 +227,9 @@ HwmpProtocolMac::SendPreq (std::vector preq) MeshInformationElementVector elements; for (std::vector::iterator i = preq.begin (); i != preq.end (); i++) { - elements.AddInformationElement(Ptr (&(*i))); + elements.AddInformationElement (Ptr (&(*i))); } - packet->AddHeader(elements); + packet->AddHeader (elements); packet->AddHeader (GetWifiActionHeader ()); //create 802.11 header: WifiMacHeader hdr; @@ -298,7 +298,7 @@ HwmpProtocolMac::SendPrep (IePrep prep, Mac48Address receiver) //Create packet Ptr packet = Create (); MeshInformationElementVector elements; - elements.AddInformationElement(Ptr (&prep)); + elements.AddInformationElement (Ptr (&prep)); packet->AddHeader (elements); packet->AddHeader (GetWifiActionHeader ()); //create 802.11 header: @@ -332,13 +332,13 @@ HwmpProtocolMac::ForwardPerr (std::vector faile } else { - elements.AddInformationElement(perr); + elements.AddInformationElement (perr); perr->ResetPerr (); } } if (perr->GetNumOfDest () > 0) { - elements.AddInformationElement(perr); + elements.AddInformationElement (perr); } packet->AddHeader (elements); packet->AddHeader (GetWifiActionHeader ()); diff --git a/src/mesh/model/dot11s/hwmp-protocol.cc b/src/mesh/model/dot11s/hwmp-protocol.cc index 8aa4c27a1..c889262c4 100644 --- a/src/mesh/model/dot11s/hwmp-protocol.cc +++ b/src/mesh/model/dot11s/hwmp-protocol.cc @@ -173,7 +173,7 @@ HwmpProtocol::HwmpProtocol () : m_hwmpSeqno (1), m_preqId (0), m_rtable (CreateObject ()), - m_randomStart(Seconds (0.1)), + m_randomStart (Seconds (0.1)), m_maxQueueSize (255), m_dot11MeshHWMPmaxPREQretries (3), m_dot11MeshHWMPnetDiameterTraversalTime (MicroSeconds (1024*100)), @@ -212,7 +212,7 @@ HwmpProtocol::DoDispose () { i->second.preqTimeout.Cancel (); } - m_proactivePreqTimer.Cancel(); + m_proactivePreqTimer.Cancel (); m_preqTimeouts.clear (); m_lastDataSeqno.clear (); m_hwmpSeqnoMetricDatabase.clear (); @@ -234,7 +234,7 @@ HwmpProtocol::RequestRoute ( { Ptr packet = constPacket->Copy (); HwmpTag tag; - if (sourceIface == GetMeshPoint ()->GetIfIndex()) + if (sourceIface == GetMeshPoint ()->GetIfIndex ()) { // packet from level 3 if (packet->PeekPacketTag (tag)) @@ -285,7 +285,7 @@ HwmpProtocol::RequestRoute ( std::vector receivers = GetBroadcastReceivers (plugin->first); for (std::vector::const_iterator i = receivers.begin (); i != receivers.end (); i++) { - Ptr packetCopy = packet->Copy(); + Ptr packetCopy = packet->Copy (); // // 64-bit Intel valgrind complains about tag.SetAddress (*i). It // likes this just fine. @@ -318,7 +318,7 @@ bool HwmpProtocol::ForwardUnicast (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination, Ptr packet, uint16_t protocolType, RouteReplyCallback routeReply, uint32_t ttl) { - NS_ASSERT(destination != Mac48Address::GetBroadcast ()); + NS_ASSERT (destination != Mac48Address::GetBroadcast ()); HwmpRtable::LookupResult result = m_rtable->LookupReactive (destination); NS_LOG_DEBUG ("Requested src = "< > destinations = preq.GetDestinationList (); //Add reactive path to originator: if ( @@ -457,13 +457,13 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M } for (std::vector >::const_iterator i = destinations.begin (); i != destinations.end (); i++) { - if ((*i)->GetDestinationAddress () == Mac48Address::GetBroadcast()) + if ((*i)->GetDestinationAddress () == Mac48Address::GetBroadcast ()) { //only proactive PREQ contains destination //address as broadcast! Proactive preq MUST //have destination count equal to 1 and //per destination flags DO and RF - NS_ASSERT (preq.GetDestCount() == 1); + NS_ASSERT (preq.GetDestCount () == 1); NS_ASSERT (((*i)->IsDo ()) && ((*i)->IsRf ())); //Add proactive path only if it is the better then existed //before @@ -509,7 +509,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M preq.GetLifetime (), interface ); - NS_ASSERT(m_rtable->LookupReactive (preq.GetOriginatorAddress ()).retransmitter != Mac48Address::GetBroadcast ()); + NS_ASSERT (m_rtable->LookupReactive (preq.GetOriginatorAddress ()).retransmitter != Mac48Address::GetBroadcast ()); preq.DelDestinationAddressElement ((*i)->GetDestinationAddress ()); continue; } @@ -551,7 +551,7 @@ HwmpProtocol::ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, M return; } //Forward PREQ to all interfaces: - NS_LOG_DEBUG("I am " << GetAddress () << "retransmitting PREQ:" << preq); + NS_LOG_DEBUG ("I am " << GetAddress () << "retransmitting PREQ:" << preq); for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) { i->second->SendPreq (preq); @@ -617,13 +617,13 @@ HwmpProtocol::ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, M from, interface, metric, - MicroSeconds(prep.GetLifetime () * 1024), + MicroSeconds (prep.GetLifetime () * 1024), prep.GetOriginatorSeqNumber ()); ReactivePathResolved (fromMp); } if (prep.GetDestinationAddress () == GetAddress ()) { - NS_LOG_DEBUG("I am "<second->SendPrep (prep, retransmitter); m_stats.initiatedPrep++; } @@ -718,7 +718,7 @@ HwmpProtocol::Install (Ptr mp) return true; } void -HwmpProtocol::PeerLinkStatus(Mac48Address meshPointAddress, Mac48Address peerAddress, uint32_t interface, bool status) +HwmpProtocol::PeerLinkStatus (Mac48Address meshPointAddress, Mac48Address peerAddress, uint32_t interface, bool status) { if (status) { @@ -773,7 +773,7 @@ HwmpProtocol::MakePathError (std::vector destinations) return retval; } void -HwmpProtocol::InitiatePathError(PathError perr) +HwmpProtocol::InitiatePathError (PathError perr) { for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) { @@ -789,7 +789,7 @@ HwmpProtocol::InitiatePathError(PathError perr) } } void -HwmpProtocol::ForwardPathError(PathError perr) +HwmpProtocol::ForwardPathError (PathError perr) { for (HwmpProtocolMacMap::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++) { @@ -914,7 +914,7 @@ HwmpProtocol::ReactivePathResolved (Mac48Address dst) } HwmpRtable::LookupResult result = m_rtable->LookupReactive (dst); - NS_ASSERT(result.retransmitter != Mac48Address::GetBroadcast ()); + NS_ASSERT (result.retransmitter != Mac48Address::GetBroadcast ()); //Send all packets stored for this destination QueuedPacket packet = DequeueFirstPacketByDst (dst); while (packet.pkt != 0) @@ -1016,7 +1016,7 @@ HwmpProtocol::RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry) void HwmpProtocol::SetRoot () { - UniformVariable coefficient (0.0, m_randomStart.GetSeconds()); + UniformVariable coefficient (0.0, m_randomStart.GetSeconds ()); Time randomStart = Seconds (coefficient.GetValue ()); m_proactivePreqTimer = Simulator::Schedule (randomStart, &HwmpProtocol::SendProactivePreq, this); NS_LOG_DEBUG ("ROOT IS: " << m_address); diff --git a/src/mesh/model/dot11s/hwmp-rtable.cc b/src/mesh/model/dot11s/hwmp-rtable.cc index a1d8e2cb1..330397c70 100644 --- a/src/mesh/model/dot11s/hwmp-rtable.cc +++ b/src/mesh/model/dot11s/hwmp-rtable.cc @@ -217,7 +217,7 @@ HwmpRtable::GetPrecursors (Mac48Address destination) { if (i->whenExpire > Simulator::Now ()) { - retval.push_back (std::make_pair(i->interface, i->address)); + retval.push_back (std::make_pair (i->interface, i->address)); } } } diff --git a/src/mesh/model/dot11s/hwmp-rtable.h b/src/mesh/model/dot11s/hwmp-rtable.h index 2e014f02f..daf7ccd84 100644 --- a/src/mesh/model/dot11s/hwmp-rtable.h +++ b/src/mesh/model/dot11s/hwmp-rtable.h @@ -56,7 +56,7 @@ public: /// True for valid route bool IsValid () const; /// Compare route lookup results, used by tests - bool operator==(const LookupResult & o) const; + bool operator== (const LookupResult & o) const; }; /// Path precursor = {MAC, interface ID} typedef std::vector > PrecursorList; diff --git a/src/mesh/model/dot11s/ie-dot11s-peer-management.h b/src/mesh/model/dot11s/ie-dot11s-peer-management.h index 51506fd95..a97c66f5b 100644 --- a/src/mesh/model/dot11s/ie-dot11s-peer-management.h +++ b/src/mesh/model/dot11s/ie-dot11s-peer-management.h @@ -68,7 +68,7 @@ public: uint16_t GetPeerLinkId () const; bool SubtypeIsOpen () const; bool SubtypeIsClose () const; - bool SubtypeIsConfirm () const ; + bool SubtypeIsConfirm () const; uint8_t GetSubtype () const; /** * \name Inherited from WifiInformationElement diff --git a/src/mesh/model/dot11s/ie-dot11s-prep.h b/src/mesh/model/dot11s/ie-dot11s-prep.h index f11e93d9e..e17d29b12 100644 --- a/src/mesh/model/dot11s/ie-dot11s-prep.h +++ b/src/mesh/model/dot11s/ie-dot11s-prep.h @@ -53,7 +53,7 @@ public: uint32_t GetLifetime () const; uint32_t GetMetric () const; Mac48Address GetOriginatorAddress () const; - uint32_t GetOriginatorSeqNumber () const ; + uint32_t GetOriginatorSeqNumber () const; void DecrementTtl (); void IncrementMetric (uint32_t metric); diff --git a/src/mesh/model/dot11s/ie-dot11s-preq.h b/src/mesh/model/dot11s/ie-dot11s-preq.h index 4d76e5c8e..f7aa524dd 100644 --- a/src/mesh/model/dot11s/ie-dot11s-preq.h +++ b/src/mesh/model/dot11s/ie-dot11s-preq.h @@ -101,7 +101,7 @@ public: bool IsUnicastPreq () const; bool IsNeedNotPrep () const; uint8_t GetHopCount () const; - uint8_t GetTtl () const ; + uint8_t GetTtl () const; uint32_t GetPreqID () const; Mac48Address GetOriginatorAddress () const; uint32_t GetOriginatorSeqNumber () const; diff --git a/src/mesh/model/dot11s/peer-link.cc b/src/mesh/model/dot11s/peer-link.cc index 6da0b3956..6e3d6d043 100644 --- a/src/mesh/model/dot11s/peer-link.cc +++ b/src/mesh/model/dot11s/peer-link.cc @@ -31,7 +31,7 @@ NS_LOG_COMPONENT_DEFINE ("Dot11sPeerManagementProtocol"); namespace ns3 { namespace dot11s { -NS_OBJECT_ENSURE_REGISTERED( PeerLink); +NS_OBJECT_ENSURE_REGISTERED ( PeerLink); TypeId PeerLink::GetTypeId () diff --git a/src/mesh/model/dot11s/peer-management-protocol-mac.cc b/src/mesh/model/dot11s/peer-management-protocol-mac.cc index 4d8e20565..135f04d9f 100644 --- a/src/mesh/model/dot11s/peer-management-protocol-mac.cc +++ b/src/mesh/model/dot11s/peer-management-protocol-mac.cc @@ -70,7 +70,7 @@ PeerManagementProtocolMac::Receive (Ptr const_packet, const WifiMacHeade MgtBeaconHeader beacon_hdr; packet->RemoveHeader (beacon_hdr); MeshInformationElementVector elements; - packet->RemoveHeader(elements); + packet->RemoveHeader (elements); Ptr beaconTiming = DynamicCast (elements.FindFirst (IE11S_BEACON_TIMING)); Ptr meshId = DynamicCast (elements.FindFirst (IE11S_MESH_ID)); @@ -124,7 +124,7 @@ PeerManagementProtocolMac::Receive (Ptr const_packet, const WifiMacHeade //Peer Management element is the last element in this frame - so, we can use MeshInformationElementVector MeshInformationElementVector elements; packet->RemoveHeader (elements); - peerElement = DynamicCast(elements.FindFirst(IE11S_PEERING_MANAGEMENT)); + peerElement = DynamicCast(elements.FindFirst (IE11S_PEERING_MANAGEMENT)); NS_ASSERT (peerElement != 0); //Check taht frame subtype corresponds peer link subtype if (peerElement->SubtypeIsOpen ()) @@ -200,7 +200,7 @@ PeerManagementProtocolMac::SendPeerLinkManagementFrame (Mac48Address peerAddress meshConfig.SetNeighborCount (m_protocol->GetNumberOfLinks ()); Ptr packet = Create (); MeshInformationElementVector elements; - elements.AddInformationElement(Ptr (&peerElement)); + elements.AddInformationElement (Ptr (&peerElement)); packet->AddHeader (elements); PeerLinkFrameStart::PlinkFrameStartFields fields; fields.rates = m_parent->GetSupportedRates (); diff --git a/src/mesh/model/dot11s/peer-management-protocol.cc b/src/mesh/model/dot11s/peer-management-protocol.cc index 1860a1343..a3eab778f 100644 --- a/src/mesh/model/dot11s/peer-management-protocol.cc +++ b/src/mesh/model/dot11s/peer-management-protocol.cc @@ -239,8 +239,8 @@ PeerManagementProtocol::ConfigurationMismatch (uint32_t interface, Mac48Address void PeerManagementProtocol::TransmissionFailure (uint32_t interface, Mac48Address peerAddress) { - NS_LOG_DEBUG("transmission failed between "< peerLink = FindPeerLink(interface, peerAddress); + NS_LOG_DEBUG ("transmission failed between "< peerLink = FindPeerLink (interface, peerAddress); if (peerLink != 0) { peerLink->TransmissionFailure (); @@ -249,8 +249,8 @@ PeerManagementProtocol::TransmissionFailure (uint32_t interface, Mac48Address pe void PeerManagementProtocol::TransmissionSuccess (uint32_t interface, Mac48Address peerAddress) { - NS_LOG_DEBUG("transmission success "< peerLink = FindPeerLink(interface, peerAddress); + NS_LOG_DEBUG ("transmission success "< peerLink = FindPeerLink (interface, peerAddress); if (peerLink != 0) { peerLink->TransmissionSuccess (); diff --git a/src/mesh/model/flame/flame-rtable.h b/src/mesh/model/flame/flame-rtable.h index d66d17d25..5c1378bb4 100644 --- a/src/mesh/model/flame/flame-rtable.h +++ b/src/mesh/model/flame/flame-rtable.h @@ -61,7 +61,7 @@ public: /// True for valid route bool IsValid () const; /// Compare route lookup results, used by tests - bool operator==(const LookupResult & o) const; + bool operator== (const LookupResult & o) const; }; public: static TypeId GetTypeId (); diff --git a/src/mesh/model/mesh-information-element-vector.cc b/src/mesh/model/mesh-information-element-vector.cc index 6a2a04ca6..b0eb53704 100644 --- a/src/mesh/model/mesh-information-element-vector.cc +++ b/src/mesh/model/mesh-information-element-vector.cc @@ -37,7 +37,7 @@ namespace ns3 { uint32_t -MeshInformationElementVector::DeserializeSingleIe(Buffer::Iterator start) +MeshInformationElementVector::DeserializeSingleIe (Buffer::Iterator start) { Buffer::Iterator i = start; uint8_t id = i.ReadU8 (); @@ -88,7 +88,7 @@ MeshInformationElementVector::DeserializeSingleIe(Buffer::Iterator start) newElement->DeserializeInformationField (i, length); i.Next (length); m_elements.push_back (newElement); - return i.GetDistanceFrom(start); + return i.GetDistanceFrom (start); } diff --git a/src/mesh/model/mesh-wifi-interface-mac.cc b/src/mesh/model/mesh-wifi-interface-mac.cc index 4512c33bc..7da9c16eb 100644 --- a/src/mesh/model/mesh-wifi-interface-mac.cc +++ b/src/mesh/model/mesh-wifi-interface-mac.cc @@ -209,15 +209,15 @@ MeshWifiInterfaceMac::ForwardDown (Ptr const_packet, Mac48Address // Assert that address1 is set. Assert will fail e.g. if there is no installed routing plugin. NS_ASSERT (hdr.GetAddr1 () != Mac48Address ()); // Queue frame - if (m_stationManager->IsBrandNew (to)) + if (m_stationManager->IsBrandNew (hdr.GetAddr1 ())) { // in adhoc mode, we assume that every destination // supports all the rates we support. for (uint32_t i = 0; i < m_phy->GetNModes (); i++) { - m_stationManager->AddSupportedMode (to, m_phy->GetMode (i)); + m_stationManager->AddSupportedMode (hdr.GetAddr1 (), m_phy->GetMode (i)); } - m_stationManager->RecordDisassociated (to); + m_stationManager->RecordDisassociated (hdr.GetAddr1 ()); } //Classify: application sets a tag, which is removed here // Get Qos tag: diff --git a/src/mesh/test/dot11s/hwmp-proactive-regression.cc b/src/mesh/test/dot11s/hwmp-proactive-regression.cc index aaf8175e6..af1302f0d 100644 --- a/src/mesh/test/dot11s/hwmp-proactive-regression.cc +++ b/src/mesh/test/dot11s/hwmp-proactive-regression.cc @@ -56,7 +56,7 @@ HwmpProactiveRegressionTest::~HwmpProactiveRegressionTest () void HwmpProactiveRegressionTest::DoRun () { - SeedManager::SetSeed(12345); + SeedManager::SetSeed (12345); CreateNodes (); CreateDevices (); InstallApplications (); @@ -94,7 +94,7 @@ HwmpProactiveRegressionTest::InstallApplications () serverApps.Stop (m_time); UdpEchoClientHelper echoClient (m_interfaces.GetAddress (0), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (300)); - echoClient.SetAttribute ("Interval", TimeValue (Seconds(0.5))); + echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.5))); echoClient.SetAttribute ("PacketSize", UintegerValue (100)); ApplicationContainer clientApps = echoClient.Install (m_nodes->Get (4)); clientApps.Start (Seconds (2.5)); @@ -112,7 +112,7 @@ HwmpProactiveRegressionTest::CreateDevices () // 2. setup mesh MeshHelper mesh = MeshHelper::Default (); mesh.SetStackInstaller ("ns3::Dot11sStack", "Root", Mac48AddressValue (Mac48Address ("00:00:00:00:00:0d"))); - mesh.SetMacType ("RandomStart", TimeValue (Seconds(0.1))); + mesh.SetMacType ("RandomStart", TimeValue (Seconds (0.1))); mesh.SetNumberOfInterfaces (1); NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes); // 3. setup TCP/IP @@ -122,7 +122,7 @@ HwmpProactiveRegressionTest::CreateDevices () address.SetBase ("10.1.1.0", "255.255.255.0"); m_interfaces = address.Assign (meshDevices); // 4. write PCAP if needed - std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string(GetTempDir ())) + PREFIX; + std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string (GetTempDir ())) + PREFIX; wifiPhy.EnablePcapAll (prefix); } @@ -136,9 +136,9 @@ HwmpProactiveRegressionTest::CheckResults () os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap"; os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap"; - uint32_t sec(0), usec(0); - bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); // TODO support default PcapWriter snap length here - NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() + uint32_t sec (0), usec (0); + bool diff = PcapFile::Diff (os1.str (), os2.str (), sec, usec); // TODO support default PcapWriter snap length here + NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str () << " and " << os2.str () << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/mesh/test/dot11s/hwmp-reactive-regression.cc b/src/mesh/test/dot11s/hwmp-reactive-regression.cc index 7bd27e2ff..0e8190e4b 100644 --- a/src/mesh/test/dot11s/hwmp-reactive-regression.cc +++ b/src/mesh/test/dot11s/hwmp-reactive-regression.cc @@ -52,7 +52,7 @@ HwmpReactiveRegressionTest::~HwmpReactiveRegressionTest () void HwmpReactiveRegressionTest::DoRun () { - SeedManager::SetSeed(12345); + SeedManager::SetSeed (12345); CreateNodes (); CreateDevices (); InstallApplications (); @@ -71,16 +71,16 @@ HwmpReactiveRegressionTest::CreateNodes () m_nodes->Create (6); MobilityHelper mobility; Ptr positionAlloc = CreateObject(); - positionAlloc->Add(Vector( 0, 0, 0)); - positionAlloc->Add(Vector( 0, 150, 0)); - positionAlloc->Add(Vector( 0, 300, 0)); - positionAlloc->Add(Vector( 0, 450, 0)); - positionAlloc->Add(Vector( 0, 600, 0)); - positionAlloc->Add(Vector( 0, 750, 0)); - mobility.SetPositionAllocator(positionAlloc); + positionAlloc->Add (Vector ( 0, 0, 0)); + positionAlloc->Add (Vector ( 0, 150, 0)); + positionAlloc->Add (Vector ( 0, 300, 0)); + positionAlloc->Add (Vector ( 0, 450, 0)); + positionAlloc->Add (Vector ( 0, 600, 0)); + positionAlloc->Add (Vector ( 0, 750, 0)); + mobility.SetPositionAllocator (positionAlloc); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (*m_nodes); - Simulator::Schedule (Seconds(5.0), &HwmpReactiveRegressionTest::ResetPosition, this); + Simulator::Schedule (Seconds (5.0), &HwmpReactiveRegressionTest::ResetPosition, this); } void HwmpReactiveRegressionTest::InstallApplications () @@ -91,7 +91,7 @@ HwmpReactiveRegressionTest::InstallApplications () serverApps.Stop (m_time); UdpEchoClientHelper echoClient (m_interfaces.GetAddress (0), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (300)); - echoClient.SetAttribute ("Interval", TimeValue (Seconds(0.5))); + echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.5))); echoClient.SetAttribute ("PacketSize", UintegerValue (20)); ApplicationContainer clientApps = echoClient.Install (m_nodes->Get (5)); clientApps.Start (Seconds (2.0)); @@ -109,7 +109,7 @@ HwmpReactiveRegressionTest::CreateDevices () // 2. setup mesh MeshHelper mesh = MeshHelper::Default (); mesh.SetStackInstaller ("ns3::Dot11sStack"); - mesh.SetMacType ("RandomStart", TimeValue (Seconds(0.1))); + mesh.SetMacType ("RandomStart", TimeValue (Seconds (0.1))); mesh.SetNumberOfInterfaces (1); NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes); // 3. setup TCP/IP @@ -119,7 +119,7 @@ HwmpReactiveRegressionTest::CreateDevices () address.SetBase ("10.1.1.0", "255.255.255.0"); m_interfaces = address.Assign (meshDevices); // 4. write PCAP if needed - std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string(GetTempDir ())) + PREFIX; + std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string (GetTempDir ())) + PREFIX; wifiPhy.EnablePcapAll (prefix); } @@ -134,9 +134,9 @@ HwmpReactiveRegressionTest::CheckResults () os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap"; os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap"; - uint32_t sec(0), usec(0); - bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); // TODO support default PcapWriter snap length here - NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() + uint32_t sec (0), usec (0); + bool diff = PcapFile::Diff (os1.str (), os2.str (), sec, usec); // TODO support default PcapWriter snap length here + NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str () << " and " << os2.str () << " differ starting from " << sec << " s " << usec << " us"); } } @@ -144,12 +144,12 @@ HwmpReactiveRegressionTest::CheckResults () void HwmpReactiveRegressionTest::ResetPosition () { - Ptr object = m_nodes->Get(3); + Ptr object = m_nodes->Get (3); Ptr model = object->GetObject (); if (model == 0) { return; } - model->SetPosition (Vector(9000, 0, 0)); + model->SetPosition (Vector (9000, 0, 0)); } diff --git a/src/mesh/test/dot11s/hwmp-simplest-regression.cc b/src/mesh/test/dot11s/hwmp-simplest-regression.cc index 472e545bc..411ad5a6e 100644 --- a/src/mesh/test/dot11s/hwmp-simplest-regression.cc +++ b/src/mesh/test/dot11s/hwmp-simplest-regression.cc @@ -55,7 +55,7 @@ HwmpSimplestRegressionTest::~HwmpSimplestRegressionTest () void HwmpSimplestRegressionTest::DoRun () { - SeedManager::SetSeed(12345); + SeedManager::SetSeed (12345); CreateNodes (); CreateDevices (); InstallApplications (); @@ -83,18 +83,18 @@ HwmpSimplestRegressionTest::CreateNodes () "LayoutType", StringValue ("RowFirst")); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install (*m_nodes); - Simulator::Schedule (Seconds(10.0), &HwmpSimplestRegressionTest::ResetPosition, this); + Simulator::Schedule (Seconds (10.0), &HwmpSimplestRegressionTest::ResetPosition, this); } void HwmpSimplestRegressionTest::ResetPosition () { - Ptr object = m_nodes->Get(1); + Ptr object = m_nodes->Get (1); Ptr model = object->GetObject (); if (model == 0) { return; } - model->SetPosition (Vector(9000, 0, 0)); + model->SetPosition (Vector (9000, 0, 0)); } void HwmpSimplestRegressionTest::InstallApplications () @@ -105,7 +105,7 @@ HwmpSimplestRegressionTest::InstallApplications () serverApps.Stop (m_time); UdpEchoClientHelper echoClient (m_interfaces.GetAddress (0), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (300)); - echoClient.SetAttribute ("Interval", TimeValue (Seconds(0.05))); + echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.05))); echoClient.SetAttribute ("PacketSize", UintegerValue (100)); ApplicationContainer clientApps = echoClient.Install (m_nodes->Get (1)); clientApps.Start (Seconds (2.0)); @@ -121,7 +121,7 @@ HwmpSimplestRegressionTest::CreateDevices () // 2. setup mesh MeshHelper mesh = MeshHelper::Default (); mesh.SetStackInstaller ("ns3::Dot11sStack"); - mesh.SetMacType ("RandomStart", TimeValue (Seconds(0.1))); + mesh.SetMacType ("RandomStart", TimeValue (Seconds (0.1))); mesh.SetNumberOfInterfaces (1); NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes); // 3. setup TCP/IP @@ -131,7 +131,7 @@ HwmpSimplestRegressionTest::CreateDevices () address.SetBase ("10.1.1.0", "255.255.255.0"); m_interfaces = address.Assign (meshDevices); // 4. write PCAP if needed - std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string(GetTempDir ())) + PREFIX; + std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string (GetTempDir ())) + PREFIX; wifiPhy.EnablePcapAll (prefix); } @@ -145,9 +145,9 @@ HwmpSimplestRegressionTest::CheckResults () os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap"; os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap"; - uint32_t sec(0), usec(0); - bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); // TODO support default PcapWriter snap length here - NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() + uint32_t sec (0), usec (0); + bool diff = PcapFile::Diff (os1.str (), os2.str (), sec, usec); // TODO support default PcapWriter snap length here + NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str () << " and " << os2.str () << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/mesh/test/dot11s/hwmp-target-flags-regression.cc b/src/mesh/test/dot11s/hwmp-target-flags-regression.cc index 3bdf3748e..2f2cdeb93 100644 --- a/src/mesh/test/dot11s/hwmp-target-flags-regression.cc +++ b/src/mesh/test/dot11s/hwmp-target-flags-regression.cc @@ -55,7 +55,7 @@ HwmpDoRfRegressionTest::~HwmpDoRfRegressionTest () void HwmpDoRfRegressionTest::DoRun () { - SeedManager::SetSeed(12345); + SeedManager::SetSeed (12345); CreateNodes (); CreateDevices (); InstallApplications (); @@ -93,7 +93,7 @@ HwmpDoRfRegressionTest::InstallApplications () serverApps.Stop (m_time); UdpEchoClientHelper echoClient (m_interfaces.GetAddress (0), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (300)); - echoClient.SetAttribute ("Interval", TimeValue (Seconds(1.0))); + echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0))); echoClient.SetAttribute ("PacketSize", UintegerValue (100)); //Install first client ApplicationContainer clientApps = echoClient.Install (m_nodes->Get (1)); @@ -110,7 +110,7 @@ HwmpDoRfRegressionTest::InstallApplications () serverApps.Stop (m_time); UdpEchoClientHelper echoClient1 (m_interfaces.GetAddress (3), 10); echoClient1.SetAttribute ("MaxPackets", UintegerValue (300)); - echoClient1.SetAttribute ("Interval", TimeValue (Seconds(1.0))); + echoClient1.SetAttribute ("Interval", TimeValue (Seconds (1.0))); echoClient1.SetAttribute ("PacketSize", UintegerValue (100)); clientApps = echoClient1.Install (m_nodes->Get (0)); clientApps.Start (Seconds (2.4)); @@ -128,7 +128,7 @@ HwmpDoRfRegressionTest::CreateDevices () // 2. setup mesh MeshHelper mesh = MeshHelper::Default (); mesh.SetStackInstaller ("ns3::Dot11sStack"); - mesh.SetMacType ("RandomStart", TimeValue (Seconds(0.1))); + mesh.SetMacType ("RandomStart", TimeValue (Seconds (0.1))); mesh.SetNumberOfInterfaces (1); NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes); // 3. setup TCP/IP @@ -138,7 +138,7 @@ HwmpDoRfRegressionTest::CreateDevices () address.SetBase ("10.1.1.0", "255.255.255.0"); m_interfaces = address.Assign (meshDevices); // 4. write PCAP if needed - std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string(GetTempDir ())) + PREFIX; + std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string (GetTempDir ())) + PREFIX; wifiPhy.EnablePcapAll (prefix); } @@ -152,9 +152,9 @@ HwmpDoRfRegressionTest::CheckResults () os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap"; os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap"; - uint32_t sec(0), usec(0); - bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); // TODO support default PcapWriter snap length here - NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() + uint32_t sec (0), usec (0); + bool diff = PcapFile::Diff (os1.str (), os2.str (), sec, usec); // TODO support default PcapWriter snap length here + NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str () << " and " << os2.str () << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/mesh/test/dot11s/pmp-regression.cc b/src/mesh/test/dot11s/pmp-regression.cc index a772dfc10..4f5557de5 100644 --- a/src/mesh/test/dot11s/pmp-regression.cc +++ b/src/mesh/test/dot11s/pmp-regression.cc @@ -53,7 +53,7 @@ PeerManagementProtocolRegressionTest::~PeerManagementProtocolRegressionTest () void PeerManagementProtocolRegressionTest::DoRun () { - SeedManager::SetSeed(12345); + SeedManager::SetSeed (12345); CreateNodes (); CreateDevices (); @@ -93,11 +93,11 @@ PeerManagementProtocolRegressionTest::CreateDevices () // 2. setup mesh MeshHelper mesh = MeshHelper::Default (); mesh.SetStackInstaller ("ns3::Dot11sStack"); - mesh.SetMacType ("RandomStart", TimeValue (Seconds(0.1))); + mesh.SetMacType ("RandomStart", TimeValue (Seconds (0.1))); mesh.SetNumberOfInterfaces (1); NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes); // 3. write PCAP if needed - std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string(GetTempDir ())) + PREFIX; + std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : std::string (GetTempDir ())) + PREFIX; wifiPhy.EnablePcapAll (prefix); } @@ -111,9 +111,9 @@ PeerManagementProtocolRegressionTest::CheckResults () os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap"; os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap"; - uint32_t sec(0), usec(0); - bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); // TODO support default PcapWriter snap length here - NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() + uint32_t sec (0), usec (0); + bool diff = PcapFile::Diff (os1.str (), os2.str (), sec, usec); // TODO support default PcapWriter snap length here + NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str () << " and " << os2.str () << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/mesh/test/flame/flame-regression.cc b/src/mesh/test/flame/flame-regression.cc index 0e04a73de..f5b70074b 100644 --- a/src/mesh/test/flame/flame-regression.cc +++ b/src/mesh/test/flame/flame-regression.cc @@ -56,7 +56,7 @@ FlameRegressionTest::~FlameRegressionTest () void FlameRegressionTest::DoRun () { - SeedManager::SetSeed(12345); + SeedManager::SetSeed (12345); CreateNodes (); CreateDevices (); InstallApplications (); @@ -99,7 +99,7 @@ FlameRegressionTest::CreateDevices () // 2. setup mesh MeshHelper mesh = MeshHelper::Default (); mesh.SetStackInstaller ("ns3::FlameStack"); - mesh.SetMacType ("RandomStart", TimeValue (Seconds(0.1))); + mesh.SetMacType ("RandomStart", TimeValue (Seconds (0.1))); mesh.SetNumberOfInterfaces (1); NetDeviceContainer meshDevices = mesh.Install (wifiPhy, *m_nodes); // 3. setup TCP/IP @@ -122,7 +122,7 @@ FlameRegressionTest::InstallApplications () serverApps.Stop (m_time); UdpEchoClientHelper echoClient (m_interfaces.GetAddress (0), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (300)); - echoClient.SetAttribute ("Interval", TimeValue (Seconds(1.1))); + echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.1))); echoClient.SetAttribute ("PacketSize", UintegerValue (20)); ApplicationContainer clientApps = echoClient.Install (m_nodes->Get (2)); clientApps.Start (Seconds (1.0)); @@ -139,9 +139,9 @@ FlameRegressionTest::CheckResults () os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap"; os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap"; - uint32_t sec(0), usec(0); - bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); // TODO support default PcapWriter snap length here - NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() + uint32_t sec (0), usec (0); + bool diff = PcapFile::Diff (os1.str (), os2.str (), sec, usec); // TODO support default PcapWriter snap length here + NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str () << " and " << os2.str () << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/mobility/helper/mobility-helper.cc b/src/mobility/helper/mobility-helper.cc index fd2450905..49eace2b5 100644 --- a/src/mobility/helper/mobility-helper.cc +++ b/src/mobility/helper/mobility-helper.cc @@ -35,8 +35,8 @@ NS_LOG_COMPONENT_DEFINE ("MobilityHelper"); MobilityHelper::MobilityHelper () { m_position = CreateObjectWithAttributes - ("X", RandomVariableValue (ConstantVariable (0.0)), - "Y", RandomVariableValue (ConstantVariable (0.0))); + ("X", RandomVariableValue (ConstantVariable (0.0)), + "Y", RandomVariableValue (ConstantVariable (0.0))); m_mobility.SetTypeId ("ns3::ConstantPositionMobilityModel"); } MobilityHelper::~MobilityHelper () diff --git a/src/mobility/model/mobility-model.cc b/src/mobility/model/mobility-model.cc index 1a976d41e..bf585db44 100644 --- a/src/mobility/model/mobility-model.cc +++ b/src/mobility/model/mobility-model.cc @@ -86,7 +86,7 @@ MobilityModel::GetDistanceFrom (Ptr other) const void MobilityModel::NotifyCourseChange (void) const { - m_courseChangeTrace(this); + m_courseChangeTrace (this); } } // namespace ns3 diff --git a/src/mobility/model/mobility.h b/src/mobility/model/mobility.h index e09b6d4db..04f69eeb4 100644 --- a/src/mobility/model/mobility.h +++ b/src/mobility/model/mobility.h @@ -1,3 +1,7 @@ +/** + * @defgroup mobility Mobility + */ + /** * \addtogroup mobility Mobility * diff --git a/src/mobility/model/position-allocator.cc b/src/mobility/model/position-allocator.cc index 9a81fd5fd..aeccc11a7 100644 --- a/src/mobility/model/position-allocator.cc +++ b/src/mobility/model/position-allocator.cc @@ -72,7 +72,7 @@ ListPositionAllocator::GetNext (void) const { Vector v = *m_current; m_current++; - if (m_current == m_positions.end()) + if (m_current == m_positions.end ()) { m_current = m_positions.begin (); } @@ -445,7 +445,7 @@ UniformDiscPositionAllocator::GetNext (void) const x = r.GetValue (); y = r.GetValue (); } - while (sqrt(x*x + y*y) > m_rho); + while (sqrt (x*x + y*y) > m_rho); x += m_x; y += m_y; diff --git a/src/mobility/model/steady-state-random-waypoint-mobility-model.cc b/src/mobility/model/steady-state-random-waypoint-mobility-model.cc index 1d417ed2a..d95ed71ff 100644 --- a/src/mobility/model/steady-state-random-waypoint-mobility-model.cc +++ b/src/mobility/model/steady-state-random-waypoint-mobility-model.cc @@ -118,24 +118,24 @@ SteadyStateRandomWaypointMobilityModel::SteadyStateStart (void) double log2 = a*a / b*std::log (std::sqrt ((b*b)/(a*a) + 1) + b/a); double expectedTravelTime = 1.0/6.0*(log1 + log2); expectedTravelTime += 1.0/15.0*((a*a*a)/(b*b) + (b*b*b)/(a*a)) - - 1.0/15.0*std::sqrt(a*a + b*b)*((a*a)/(b*b) + (b*b)/(a*a) - 3); + 1.0/15.0*std::sqrt (a*a + b*b)*((a*a)/(b*b) + (b*b)/(a*a) - 3); if (v0 == v1) { expectedTravelTime /= v0; } else { - expectedTravelTime *= std::log(v1/v0)/(v1 - v0); + expectedTravelTime *= std::log (v1/v0)/(v1 - v0); } double probabilityPaused = expectedPauseTime/(expectedPauseTime + expectedTravelTime); NS_ASSERT (probabilityPaused >= 0 && probabilityPaused <= 1); UniformVariable u_r; - double u = u_r.GetValue(0, 1); + double u = u_r.GetValue (0, 1); if (u < probabilityPaused) // node initially paused { m_helper.SetPosition (m_position->GetNext ()); - u = u_r.GetValue(0, 1); + u = u_r.GetValue (0, 1); Time pause; if (m_minPause != m_maxPause) { @@ -154,7 +154,7 @@ SteadyStateRandomWaypointMobilityModel::SteadyStateStart (void) { pause = Seconds (u*expectedPauseTime); } - NS_ASSERT (!m_event.IsRunning()); + NS_ASSERT (!m_event.IsRunning ()); m_event = Simulator::Schedule (pause, &SteadyStateRandomWaypointMobilityModel::BeginWalk, this); } else // node initially moving @@ -175,7 +175,7 @@ SteadyStateRandomWaypointMobilityModel::SteadyStateStart (void) } double u2 = u_r.GetValue (0, 1); m_helper.SetPosition (Vector (m_minX + u2*x1 + (1 - u2)*x2, m_minY + u2*y1 + (1 - u2)*y2, 0)); - NS_ASSERT (!m_event.IsRunning()); + NS_ASSERT (!m_event.IsRunning ()); m_event = Simulator::ScheduleNow (&SteadyStateRandomWaypointMobilityModel::SteadyStateBeginWalk, this, Vector (m_minX + x2, m_minY + y2, 0)); } diff --git a/src/mobility/test/ns2-mobility-helper-test-suite.cc b/src/mobility/test/ns2-mobility-helper-test-suite.cc index 113303462..1213ad22f 100644 --- a/src/mobility/test/ns2-mobility-helper-test-suite.cc +++ b/src/mobility/test/ns2-mobility-helper-test-suite.cc @@ -201,6 +201,19 @@ private: NS_TEST_EXPECT_MSG_EQ (pos, ref.pos, "Position mismatch at time " << time.GetSeconds () << " s for node " << id); NS_TEST_EXPECT_MSG_EQ (vel, ref.vel, "Velocity mismatch at time " << time.GetSeconds () << " s for node " << id); } + + void DoSetup () + { + CreateNodes (); + } + + void DoTeardown () + { + Names::Clear (); + std::remove (m_traceFile.c_str ()); + Simulator::Destroy (); + } + /// Go void DoRun () { @@ -211,7 +224,6 @@ private: { return; } - CreateNodes (); Ns2MobilityHelper mobility (m_traceFile); mobility.Install (); if (CheckInitialPositions ()) @@ -222,9 +234,6 @@ private: MakeCallback (&Ns2MobilityHelperTest::CourseChange, this)); Simulator::Stop (m_timeLimit); Simulator::Run (); - Names::Clear (); - std::remove (m_traceFile.c_str ()); - Simulator::Destroy (); } }; diff --git a/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc b/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc index d042f2c82..688b50d64 100644 --- a/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc +++ b/src/mobility/test/steady-state-random-waypoint-mobility-model-test.cc @@ -39,13 +39,20 @@ private: double count; private: virtual void DoRun (void); + virtual void DoTeardown (void); void DistribCompare (); }; +void +SteadyStateRandomWaypointTest::DoTeardown (void) +{ + mobilityStack.clear(); +} + void SteadyStateRandomWaypointTest::DoRun (void) { - SeedManager::SetSeed(123); + SeedManager::SetSeed (123); // Total simulation time, seconds double totalTime = 1000; @@ -92,9 +99,9 @@ SteadyStateRandomWaypointTest::DistribCompare () for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i) { model = (*i); - velocity = sqrt (pow (model->GetVelocity().x, 2) + pow (model->GetVelocity().y, 2)); - sum_x += model->GetPosition().x; - sum_y += model->GetPosition().y; + velocity = sqrt (pow (model->GetVelocity ().x, 2) + pow (model->GetVelocity ().y, 2)); + sum_x += model->GetPosition ().x; + sum_y += model->GetPosition ().y; sum_v += velocity; } double mean_x = sum_x / count; @@ -112,10 +119,10 @@ SteadyStateRandomWaypointTest::DistribCompare () for (i = mobilityStack.begin (); i != mobilityStack.end (); ++i) { model = (*i); - velocity = sqrt (pow (model->GetVelocity().x, 2) + pow (model->GetVelocity().y, 2)); - tmp = model->GetPosition().x - mean_x; + velocity = sqrt (pow (model->GetVelocity ().x, 2) + pow (model->GetVelocity ().y, 2)); + tmp = model->GetPosition ().x - mean_x; sum_x += tmp * tmp; - tmp = model->GetPosition().y - mean_y; + tmp = model->GetPosition ().y - mean_y; sum_y += tmp * tmp; tmp = velocity - mean_v; sum_v += tmp * tmp; diff --git a/src/mobility/test/waypoint-mobility-model-test.cc b/src/mobility/test/waypoint-mobility-model-test.cc index 524347dbe..98808eb7d 100644 --- a/src/mobility/test/waypoint-mobility-model-test.cc +++ b/src/mobility/test/waypoint-mobility-model-test.cc @@ -31,7 +31,7 @@ class WaypointMobilityModelNotifyTest : public TestCase public: WaypointMobilityModelNotifyTest (bool lazy) : TestCase (lazy ? "Check Waypoint Mobility Model LAZY notification accuracy" - : "Check Waypoint Mobility Model NON-LAZY notification accuracy"), + : "Check Waypoint Mobility Model NON-LAZY notification accuracy"), lazyNotify (lazy) { } @@ -47,9 +47,18 @@ private: bool lazyNotify; private: virtual void DoRun (void); + virtual void DoTeardown (void); void ForceUpdates (void); void CourseChangeCallback (std::string path, Ptr model); }; + +void +WaypointMobilityModelNotifyTest::DoTeardown (void) +{ + mobilityStack.clear(); + waypoints.clear(); +} + void WaypointMobilityModelNotifyTest::DoRun (void) { diff --git a/src/mpi/doc/distributed.rst b/src/mpi/doc/distributed.rst index 08e53e99e..d7fa44eb0 100644 --- a/src/mpi/doc/distributed.rst +++ b/src/mpi/doc/distributed.rst @@ -14,6 +14,8 @@ Interface (MPI) is used, along with a new distributed simulator class. Currently, dividing a simulation for distributed purposes in |ns3| can only occur across point-to-point links. +.. _current-implementation-details: + Current Implementation Details ****************************** @@ -179,7 +181,7 @@ system ids::: Next, where the simulation is divided is determined by the placement of point-to-point links. If a point-to-point link is created between two nodes with different system ids, a remote point-to-point link is created, -as described in :ref:`Current Implementation Details`. +as described in :ref:`current-implementation-details`. Finally, installing applications only on the LP associated with the target node is very important. For example, if a traffic generator is to be placed on node diff --git a/src/mpi/examples/nms-p2p-nix-distributed.cc b/src/mpi/examples/nms-p2p-nix-distributed.cc index 381dd0f45..ed2961347 100644 --- a/src/mpi/examples/nms-p2p-nix-distributed.cc +++ b/src/mpi/examples/nms-p2p-nix-distributed.cc @@ -429,7 +429,7 @@ main (int argc, char *argv[]) { OnOffHelper client ("ns3::UdpSocketFactory", Address ()); AddressValue remoteAddress - (InetSocketAddress (ifs1[1][0].GetAddress (0), 9999)); + (InetSocketAddress (ifs1[1][0].GetAddress (0), 9999)); cout << "Remote Address is " << ifs1[1][0].GetAddress (0) << endl; client.SetAttribute ("Remote", remoteAddress); @@ -461,8 +461,8 @@ main (int argc, char *argv[]) if (systemCount == 1) { PacketSinkHelper sinkHelper - ("ns3::UdpSocketFactory", - InetSocketAddress (Ipv4Address::GetAny (), 9999)); + ("ns3::UdpSocketFactory", + InetSocketAddress (Ipv4Address::GetAny (), 9999)); ApplicationContainer sinkApp = sinkHelper.Install (nodes_net2LAN[z][i][j].Get (0)); @@ -472,8 +472,8 @@ main (int argc, char *argv[]) else if (systemId == z % systemCount) { PacketSinkHelper sinkHelper - ("ns3::UdpSocketFactory", - InetSocketAddress (Ipv4Address::GetAny (), 9999)); + ("ns3::UdpSocketFactory", + InetSocketAddress (Ipv4Address::GetAny (), 9999)); ApplicationContainer sinkApp = sinkHelper.Install (nodes_net2LAN[z][i][j].Get (0)); @@ -488,7 +488,7 @@ main (int argc, char *argv[]) OnOffHelper client ("ns3::UdpSocketFactory", Address ()); AddressValue remoteAddress - (InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999)); + (InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999)); client.SetAttribute ("Remote", remoteAddress); ApplicationContainer clientApp; @@ -502,7 +502,7 @@ main (int argc, char *argv[]) OnOffHelper client ("ns3::UdpSocketFactory", Address ()); AddressValue remoteAddress - (InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999)); + (InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999)); client.SetAttribute ("Remote", remoteAddress); ApplicationContainer clientApp; @@ -521,8 +521,8 @@ main (int argc, char *argv[]) if (systemCount == 1) { PacketSinkHelper sinkHelper - ("ns3::UdpSocketFactory", - InetSocketAddress (Ipv4Address::GetAny (), 9999)); + ("ns3::UdpSocketFactory", + InetSocketAddress (Ipv4Address::GetAny (), 9999)); ApplicationContainer sinkApp = sinkHelper.Install (nodes_net3LAN[z][i][j].Get (0)); @@ -532,8 +532,8 @@ main (int argc, char *argv[]) else if (systemId == z % systemCount) { PacketSinkHelper sinkHelper - ("ns3::UdpSocketFactory", - InetSocketAddress (Ipv4Address::GetAny (), 9999)); + ("ns3::UdpSocketFactory", + InetSocketAddress (Ipv4Address::GetAny (), 9999)); ApplicationContainer sinkApp = sinkHelper.Install (nodes_net3LAN[z][i][j].Get (0)); @@ -548,7 +548,7 @@ main (int argc, char *argv[]) OnOffHelper client ("ns3::UdpSocketFactory", Address ()); AddressValue remoteAddress - (InetSocketAddress (ifs3LAN[z][i][j].GetAddress (0), 9999)); + (InetSocketAddress (ifs3LAN[z][i][j].GetAddress (0), 9999)); client.SetAttribute ("Remote", remoteAddress); ApplicationContainer clientApp; @@ -562,7 +562,7 @@ main (int argc, char *argv[]) OnOffHelper client ("ns3::UdpSocketFactory", Address ()); AddressValue remoteAddress - (InetSocketAddress (ifs3LAN[z][i][j].GetAddress (0), 9999)); + (InetSocketAddress (ifs3LAN[z][i][j].GetAddress (0), 9999)); client.SetAttribute ("Remote", remoteAddress); ApplicationContainer clientApp; diff --git a/src/mpi/examples/simple-distributed.cc b/src/mpi/examples/simple-distributed.cc index c16fbea1b..f1245814f 100644 --- a/src/mpi/examples/simple-distributed.cc +++ b/src/mpi/examples/simple-distributed.cc @@ -226,15 +226,15 @@ main (int argc, char *argv[]) { OnOffHelper clientHelper ("ns3::UdpSocketFactory", Address ()); clientHelper.SetAttribute - ("OnTime", RandomVariableValue (ConstantVariable (1))); + ("OnTime", RandomVariableValue (ConstantVariable (1))); clientHelper.SetAttribute - ("OffTime", RandomVariableValue (ConstantVariable (0))); + ("OffTime", RandomVariableValue (ConstantVariable (0))); ApplicationContainer clientApps; for (uint32_t i = 0; i < 4; ++i) { AddressValue remoteAddress - (InetSocketAddress (rightLeafInterfaces.GetAddress (i), port)); + (InetSocketAddress (rightLeafInterfaces.GetAddress (i), port)); clientHelper.SetAttribute ("Remote", remoteAddress); clientApps.Add (clientHelper.Install (leftLeafNodes.Get (i))); } diff --git a/src/mpi/examples/third-distributed.cc b/src/mpi/examples/third-distributed.cc index 681c08bc3..e49a6d6d9 100644 --- a/src/mpi/examples/third-distributed.cc +++ b/src/mpi/examples/third-distributed.cc @@ -94,8 +94,8 @@ main (int argc, char *argv[]) if (verbose) { - LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); - LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); } NodeContainer p2pNodes; diff --git a/src/mpi/model/mpi-interface.cc b/src/mpi/model/mpi-interface.cc index 4199bc36d..91b04a79c 100644 --- a/src/mpi/model/mpi-interface.cc +++ b/src/mpi/model/mpi-interface.cc @@ -288,7 +288,7 @@ void MpiInterface::Disable () { #ifdef NS3_MPI - int flag = 0 ; + int flag = 0; MPI_Initialized (&flag); if (flag) { diff --git a/src/netanim/examples/dumbbell-animation.cc b/src/netanim/examples/dumbbell-animation.cc index c948c2d95..b2297d2e2 100644 --- a/src/netanim/examples/dumbbell-animation.cc +++ b/src/netanim/examples/dumbbell-animation.cc @@ -61,9 +61,9 @@ int main (int argc, char *argv[]) pointToPointLeaf.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); pointToPointLeaf.SetChannelAttribute ("Delay", StringValue ("1ms")); - PointToPointDumbbellHelper d(nLeftLeaf, pointToPointLeaf, - nRightLeaf, pointToPointLeaf, - pointToPointRouter); + PointToPointDumbbellHelper d (nLeftLeaf, pointToPointLeaf, + nRightLeaf, pointToPointLeaf, + pointToPointRouter); // Install Stack InternetStackHelper stack; @@ -77,9 +77,9 @@ int main (int argc, char *argv[]) // Install on/off app on all right side nodes OnOffHelper clientHelper ("ns3::UdpSocketFactory", Address ()); clientHelper.SetAttribute - ("OnTime", RandomVariableValue (UniformVariable (0, 1))); + ("OnTime", RandomVariableValue (UniformVariable (0, 1))); clientHelper.SetAttribute - ("OffTime", RandomVariableValue (UniformVariable (0, 1))); + ("OffTime", RandomVariableValue (UniformVariable (0, 1))); ApplicationContainer clientApps; for (uint32_t i = 0; i < d.RightCount (); ++i) @@ -87,7 +87,7 @@ int main (int argc, char *argv[]) // Create an on/off app sending packets to the same leaf right side AddressValue remoteAddress (InetSocketAddress (d.GetLeftIpv4Address (i), 1000)); clientHelper.SetAttribute ("Remote", remoteAddress); - clientApps.Add(clientHelper.Install (d.GetRight (i))); + clientApps.Add (clientHelper.Install (d.GetRight (i))); } clientApps.Start (Seconds (0.0)); @@ -116,6 +116,6 @@ int main (int argc, char *argv[]) std::cout << "Destroying the simulation" << std::endl; Simulator::Destroy (); std::cout << "Stopping the animation" << std::endl; - anim.StopAnimation(); + anim.StopAnimation (); return 0; } diff --git a/src/netanim/examples/grid-animation.cc b/src/netanim/examples/grid-animation.cc index 1ad6ad7cc..349061314 100644 --- a/src/netanim/examples/grid-animation.cc +++ b/src/netanim/examples/grid-animation.cc @@ -68,9 +68,9 @@ int main (int argc, char *argv[]) OnOffHelper clientHelper ("ns3::UdpSocketFactory", Address ()); clientHelper.SetAttribute - ("OnTime", RandomVariableValue (ConstantVariable (1))); + ("OnTime", RandomVariableValue (ConstantVariable (1))); clientHelper.SetAttribute - ("OffTime", RandomVariableValue (ConstantVariable (0))); + ("OffTime", RandomVariableValue (ConstantVariable (0))); ApplicationContainer clientApps; // Create an on/off app sending packets @@ -104,6 +104,6 @@ int main (int argc, char *argv[]) std::cout << "Destroying the simulation" << std::endl; Simulator::Destroy (); std::cout << "Stopping the animation" << std::endl; - anim.StopAnimation(); + anim.StopAnimation (); return 0; } diff --git a/src/netanim/examples/star-animation.cc b/src/netanim/examples/star-animation.cc index 3d73f8ee2..61d5cc91b 100644 --- a/src/netanim/examples/star-animation.cc +++ b/src/netanim/examples/star-animation.cc @@ -59,7 +59,7 @@ main (int argc, char *argv[]) std::string animFile; CommandLine cmd; - cmd.AddValue("nSpokes", "Number of spoke nodes to place in the star", nSpokes); + cmd.AddValue ("nSpokes", "Number of spoke nodes to place in the star", nSpokes); cmd.AddValue ("animPort", "Port Number for Remote Animation", animPort); cmd.AddValue ("animFile", "File Name for Animation Output", animFile); diff --git a/src/netanim/model/animation-interface.cc b/src/netanim/model/animation-interface.cc index d55efd9e3..0f94c6502 100644 --- a/src/netanim/model/animation-interface.cc +++ b/src/netanim/model/animation-interface.cc @@ -188,11 +188,11 @@ void AnimationInterface::DevTxTrace (std::string context, Ptr p, { Time now = Simulator::Now (); ostringstream oss; - oss << now.GetSeconds() << " P " + oss << now.GetSeconds () << " P " << tx->GetNode ()->GetId () << " " << rx->GetNode ()->GetId () << " " << (now + txTime).GetSeconds () << " " // last bit tx time - << (now + rxTime - txTime).GetSeconds() << " " // first bit rx time + << (now + rxTime - txTime).GetSeconds () << " " // first bit rx time << (now + rxTime).GetSeconds () << endl; // last bit rx time WriteN (m_fHandle, oss.str ().c_str (), oss.str ().length ()); } diff --git a/src/netanim/model/animation-interface.h b/src/netanim/model/animation-interface.h index d736d71e1..6ad30fd23 100644 --- a/src/netanim/model/animation-interface.h +++ b/src/netanim/model/animation-interface.h @@ -32,13 +32,14 @@ namespace ns3 { -/** - * \defgroup netanim Animation - * - */ - class NetModel; +/** + * \defgroup netanim Netanim + * + * This section documents the API of the ns-3 netanim module. For a generic functional description, please refer to the ns-3 manual. + */ + /** * \ingroup netanim * diff --git a/src/network/doc/network.h b/src/network/doc/network.h new file mode 100644 index 000000000..2deaff4da --- /dev/null +++ b/src/network/doc/network.h @@ -0,0 +1,27 @@ +/* -*- 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 + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef NETWORK_H +#define NETWORK_H + +/** + * \defgroup network Network + * + * This section documents the API of the ns-3 network module. For a generic functional description, please refer to the ns-3 manual. + */ + +#endif /* NETWORK_H */ diff --git a/src/network/doc/sockets-api.rst b/src/network/doc/sockets-api.rst index f3493c2b5..8b8f8900c 100644 --- a/src/network/doc/sockets-api.rst +++ b/src/network/doc/sockets-api.rst @@ -157,7 +157,7 @@ There are two basic variants of ``Send()`` and ``Recv()`` supported:: The non-Packet variants are provided for legacy API reasons. When calling the raw buffer variant of :cpp:func:`ns3::Socket::Send`, the buffer is immediately -written into a Packet and the :cpp:func:`ns3::Socket::Send (Ptr p)` is invoked. +written into a Packet and the packet variant is invoked. Users may find it semantically odd to pass a Packet to a stream socket such as TCP. However, do not let the name bother you; think of diff --git a/src/network/helper/trace-helper.cc b/src/network/helper/trace-helper.cc index 3343e9927..db52a9270 100644 --- a/src/network/helper/trace-helper.cc +++ b/src/network/helper/trace-helper.cc @@ -31,7 +31,7 @@ #include "trace-helper.h" -NS_LOG_COMPONENT_DEFINE("TraceHelper"); +NS_LOG_COMPONENT_DEFINE ("TraceHelper"); namespace ns3 { @@ -167,7 +167,7 @@ void PcapHelper::DefaultSink (Ptr file, Ptr p) { NS_LOG_FUNCTION (file << p); - file->Write(Simulator::Now(), p); + file->Write (Simulator::Now (), p); } AsciiTraceHelper::AsciiTraceHelper () diff --git a/src/network/model/address.cc b/src/network/model/address.cc index 6878fe6a7..a71abdc9d 100644 --- a/src/network/model/address.cc +++ b/src/network/model/address.cc @@ -197,8 +197,8 @@ bool operator < (const Address &a, const Address &b) { return false; } - NS_ASSERT (a.GetLength() == b.GetLength()); - for (uint8_t i = 0; i < a.GetLength(); i++) + NS_ASSERT (a.GetLength () == b.GetLength ()); + for (uint8_t i = 0; i < a.GetLength (); i++) { if (a.m_data[i] < b.m_data[i]) { @@ -215,16 +215,16 @@ bool operator < (const Address &a, const Address &b) std::ostream& operator<< (std::ostream& os, const Address & address) { os.setf (std::ios::hex, std::ios::basefield); - os.fill('0'); - os << std::setw(2) << (uint32_t) address.m_type << "-" << std::setw(2) << (uint32_t) address.m_len << "-"; + os.fill ('0'); + os << std::setw (2) << (uint32_t) address.m_type << "-" << std::setw (2) << (uint32_t) address.m_len << "-"; for (uint8_t i = 0; i < (address.m_len-1); ++i) { - os << std::setw(2) << (uint32_t)address.m_data[i] << ":"; + os << std::setw (2) << (uint32_t)address.m_data[i] << ":"; } // Final byte not suffixed by ":" - os << std::setw(2) << (uint32_t) address.m_data[address.m_len-1]; + os << std::setw (2) << (uint32_t) address.m_data[address.m_len-1]; os.setf (std::ios::dec, std::ios::basefield); - os.fill(' '); + os.fill (' '); return os; } diff --git a/src/network/model/application.cc b/src/network/model/application.cc index e77f3cb0b..69304fc13 100644 --- a/src/network/model/application.cc +++ b/src/network/model/application.cc @@ -94,7 +94,7 @@ Application::DoStart (void) Object::DoStart (); } -Ptr Application::GetNode() const +Ptr Application::GetNode () const { return m_node; } @@ -107,11 +107,11 @@ Application::SetNode (Ptr node) // Protected methods // StartApp and StopApp will likely be overridden by application subclasses -void Application::StartApplication() +void Application::StartApplication () { // Provide null functionality in case subclass is not interested } -void Application::StopApplication() +void Application::StopApplication () { // Provide null functionality in case subclass is not interested } diff --git a/src/network/model/buffer.cc b/src/network/model/buffer.cc index fc87433c6..0fd99c17c 100644 --- a/src/network/model/buffer.cc +++ b/src/network/model/buffer.cc @@ -68,7 +68,7 @@ uint32_t Buffer::g_recommendedStart = 0; #define MAGIC_DESTROYED (~(long) 0) #define IS_UNINITIALIZED(x) (x == (Buffer::FreeList*)0) #define IS_DESTROYED(x) (x == (Buffer::FreeList*)MAGIC_DESTROYED) -#define IS_INITIALIZED(x) (!IS_UNINITIALIZED(x) && !IS_DESTROYED(x)) +#define IS_INITIALIZED(x) (!IS_UNINITIALIZED (x) && !IS_DESTROYED (x)) #define DESTROYED ((Buffer::FreeList*)MAGIC_DESTROYED) #define UNINITIALIZED ((Buffer::FreeList*)0) uint32_t Buffer::g_maxSize = 0; @@ -77,7 +77,7 @@ struct Buffer::LocalStaticDestructor Buffer::g_localStaticDestructor; Buffer::LocalStaticDestructor::~LocalStaticDestructor(void) { - if (IS_INITIALIZED(g_freeList)) + if (IS_INITIALIZED (g_freeList)) { for (Buffer::FreeList::iterator i = g_freeList->begin (); i != g_freeList->end (); i++) @@ -93,18 +93,18 @@ void Buffer::Recycle (struct Buffer::Data *data) { NS_ASSERT (data->m_count == 0); - NS_ASSERT (!IS_UNINITIALIZED(g_freeList)); + NS_ASSERT (!IS_UNINITIALIZED (g_freeList)); g_maxSize = std::max (g_maxSize, data->m_size); /* feed into free list */ if (data->m_size < g_maxSize || - IS_DESTROYED(g_freeList) || + IS_DESTROYED (g_freeList) || g_freeList->size () > 1000) { Buffer::Deallocate (data); } else { - NS_ASSERT (IS_INITIALIZED(g_freeList)); + NS_ASSERT (IS_INITIALIZED (g_freeList)); g_freeList->push_back (data); } } @@ -113,11 +113,11 @@ Buffer::Data * Buffer::Create (uint32_t dataSize) { /* try to find a buffer correctly sized. */ - if (IS_UNINITIALIZED(g_freeList)) + if (IS_UNINITIALIZED (g_freeList)) { g_freeList = new Buffer::FreeList (); } - else if (IS_INITIALIZED(g_freeList)) + else if (IS_INITIALIZED (g_freeList)) { while (!g_freeList->empty ()) { @@ -611,7 +611,7 @@ Buffer::Serialize (uint8_t* buffer, uint32_t maxSize) const if (size + ((dataStartLength + 3) & (~3)) <= maxSize) { size += (dataStartLength + 3) & (~3); - memcpy(p, m_data->m_data + m_start, dataStartLength); + memcpy (p, m_data->m_data + m_start, dataStartLength); p += (((dataStartLength + 3) & (~3))/4); // Advance p, insuring 4 byte boundary } else @@ -635,7 +635,7 @@ Buffer::Serialize (uint8_t* buffer, uint32_t maxSize) const if (size + ((dataEndLength + 3) & (~3)) <= maxSize) { size += (dataEndLength + 3) & (~3); - memcpy(p, m_data->m_data+m_zeroAreaStart,dataEndLength); + memcpy (p, m_data->m_data+m_zeroAreaStart,dataEndLength); p += (((dataEndLength + 3) & (~3))/4); // Advance p, insuring 4 byte boundary } else @@ -722,12 +722,12 @@ Buffer::PeekData (void) const } void -Buffer::CopyData(std::ostream *os, uint32_t size) const +Buffer::CopyData (std::ostream *os, uint32_t size) const { if (size > 0) { uint32_t tmpsize = std::min (m_zeroAreaStart-m_start, size); - os->write((const char*)(m_data->m_data + m_start), tmpsize); + os->write ((const char*)(m_data->m_data + m_start), tmpsize); if (size > tmpsize) { size -= m_zeroAreaStart-m_start; @@ -1115,13 +1115,13 @@ Buffer::Iterator::Read (uint8_t *buffer, uint32_t size) } uint16_t -Buffer::Iterator::CalculateIpChecksum(uint16_t size) +Buffer::Iterator::CalculateIpChecksum (uint16_t size) { - return CalculateIpChecksum(size, 0); + return CalculateIpChecksum (size, 0); } uint16_t -Buffer::Iterator::CalculateIpChecksum(uint16_t size, uint32_t initialChecksum) +Buffer::Iterator::CalculateIpChecksum (uint16_t size, uint32_t initialChecksum) { /* see RFC 1071 to understand this code. */ uint32_t sum = initialChecksum; diff --git a/src/network/model/buffer.h b/src/network/model/buffer.h index 65617fb12..95b5f4eb4 100644 --- a/src/network/model/buffer.h +++ b/src/network/model/buffer.h @@ -342,7 +342,7 @@ public: * \param size size of the buffer. * \return checksum */ - uint16_t CalculateIpChecksum(uint16_t size); + uint16_t CalculateIpChecksum (uint16_t size); /** * \brief Calculate the checksum. @@ -350,7 +350,7 @@ public: * \param initialChecksum initial value * \return checksum */ - uint16_t CalculateIpChecksum(uint16_t size, uint32_t initialChecksum); + uint16_t CalculateIpChecksum (uint16_t size, uint32_t initialChecksum); /** * \returns the size of the underlying buffer we are iterating diff --git a/src/network/model/channel.cc b/src/network/model/channel.cc index be32b65bd..daee0713e 100644 --- a/src/network/model/channel.cc +++ b/src/network/model/channel.cc @@ -43,7 +43,7 @@ Channel::GetTypeId (void) } Channel::Channel () - : m_id(0) + : m_id (0) { NS_LOG_FUNCTION_NOARGS (); m_id = ChannelList::Add (this); diff --git a/src/network/model/net-device.h b/src/network/model/net-device.h index 9e6048e28..1ada158b7 100644 --- a/src/network/model/net-device.h +++ b/src/network/model/net-device.h @@ -81,11 +81,11 @@ public: /** * \param index ifIndex of the device */ - virtual void SetIfIndex(const uint32_t index) = 0; + virtual void SetIfIndex (const uint32_t index) = 0; /** * \return index ifIndex of the device */ - virtual uint32_t GetIfIndex(void) const = 0; + virtual uint32_t GetIfIndex (void) const = 0; /** @@ -219,7 +219,7 @@ public: * * \return whether the Send operation succeeded */ - virtual bool Send(Ptr packet, const Address& dest, uint16_t protocolNumber) = 0; + virtual bool Send (Ptr packet, const Address& dest, uint16_t protocolNumber) = 0; /** * \param packet packet sent from above down to Network Device * \param source source mac address (so called "MAC spoofing") @@ -233,7 +233,7 @@ public: * * \return whether the Send operation succeeded */ - virtual bool SendFrom(Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) = 0; + virtual bool SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) = 0; /** * \returns the node base class which contains this network * interface. diff --git a/src/network/model/nix-vector.cc b/src/network/model/nix-vector.cc index 0b4882455..79dc8cddb 100644 --- a/src/network/model/nix-vector.cc +++ b/src/network/model/nix-vector.cc @@ -102,7 +102,7 @@ NixVector::AddNeighborIndex (uint32_t newBits, uint32_t numberOfBits) { // can't add any more to this vector, so // start a new one - m_nixVector.push_back(newBits); + m_nixVector.push_back (newBits); // also reset number of bits in // m_currentVectorBitSize @@ -171,7 +171,7 @@ NixVector::ExtractNeighborIndex (uint32_t numberOfBits) if (numberOfBits > totalRemainingBits) { NS_FATAL_ERROR ("You've tried to extract too many bits of the Nix-vector, " << this << ". NumberBits: " - << numberOfBits << " Remaining: " << totalRemainingBits); + << numberOfBits << " Remaining: " << totalRemainingBits); } if (numberOfBits <= 0) @@ -263,7 +263,7 @@ NixVector::Serialize (uint32_t* buffer, uint32_t maxSize) const if (size + 4 <= maxSize) { size += 4; - *p++ = m_nixVector.at(j); + *p++ = m_nixVector.at (j); } else { diff --git a/src/network/model/nix-vector.h b/src/network/model/nix-vector.h index 86a3cdf6a..4c00472ff 100644 --- a/src/network/model/nix-vector.h +++ b/src/network/model/nix-vector.h @@ -47,7 +47,7 @@ namespace ns3 { * bits long and can store multiple neighbor-indexes. A * fair amount of bit manipulation is used to store these * neighbor-indexes efficiently. A vector is used so that - * the nix-vector can grow arbitraily if the topology and + * the nix-vector can grow arbitrarily if the topology and * route requires a large number of neighbor-indexes. * * As the nix-vector travels along the route, an internal @@ -155,7 +155,7 @@ private: /* for printing of nix-vector */ void DumpNixVector (std::ostream &os) const; /* for printing of nix-vector */ - friend std::ostream & operator <<( std::ostream &outs, const NixVector &nix); + friend std::ostream & operator << ( std::ostream &outs, const NixVector &nix); /* the actual nix-vector */ NixBits_t m_nixVector; diff --git a/src/network/model/node.cc b/src/network/model/node.cc index ba27f8292..2aeb676a6 100644 --- a/src/network/model/node.cc +++ b/src/network/model/node.cc @@ -67,15 +67,15 @@ Node::GetTypeId (void) } Node::Node() - : m_id(0), - m_sid(0) + : m_id (0), + m_sid (0) { Construct (); } Node::Node(uint32_t sid) - : m_id(0), - m_sid(sid) + : m_id (0), + m_sid (sid) { Construct (); } @@ -108,7 +108,7 @@ Node::AddDevice (Ptr device) uint32_t index = m_devices.size (); m_devices.push_back (device); device->SetNode (this); - device->SetIfIndex(index); + device->SetIfIndex (index); device->SetReceiveCallback (MakeCallback (&Node::NonPromiscReceiveFromDevice, this)); Simulator::ScheduleWithContext (GetId (), Seconds (0.0), &NetDevice::Start, device); @@ -152,7 +152,7 @@ Node::GetNApplications (void) const } void -Node::DoDispose() +Node::DoDispose () { m_handlers.clear (); for (std::vector >::iterator i = m_devices.begin (); @@ -255,7 +255,7 @@ bool Node::PromiscReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType) { - NS_LOG_FUNCTION(this); + NS_LOG_FUNCTION (this); return ReceiveFromDevice (device, packet, protocol, from, to, packetType, true); } @@ -263,8 +263,8 @@ bool Node::NonPromiscReceiveFromDevice (Ptr device, Ptr packet, uint16_t protocol, const Address &from) { - NS_LOG_FUNCTION(this); - return ReceiveFromDevice (device, packet, protocol, from, device->GetAddress(), NetDevice::PacketType (0), false); + NS_LOG_FUNCTION (this); + return ReceiveFromDevice (device, packet, protocol, from, device->GetAddress (), NetDevice::PacketType (0), false); } bool @@ -274,9 +274,9 @@ Node::ReceiveFromDevice (Ptr device, Ptr packet, uint16 NS_ASSERT_MSG (Simulator::GetContext () == GetId (), "Received packet with erroneous context ; " << "make sure the channels in use are correctly updating events context " << "when transfering events from one node to another."); - NS_LOG_DEBUG("Node " << GetId () << " ReceiveFromDevice: dev " - << device->GetIfIndex () << " (type=" << device->GetInstanceTypeId ().GetName () - << ") Packet UID " << packet->GetUid ()); + NS_LOG_DEBUG ("Node " << GetId () << " ReceiveFromDevice: dev " + << device->GetIfIndex () << " (type=" << device->GetInstanceTypeId ().GetName () + << ") Packet UID " << packet->GetUid ()); bool found = false; for (ProtocolHandlerList::iterator i = m_handlers.begin (); diff --git a/src/network/model/packet-metadata.cc b/src/network/model/packet-metadata.cc index 3e74492da..fbeaa6458 100644 --- a/src/network/model/packet-metadata.cc +++ b/src/network/model/packet-metadata.cc @@ -1410,7 +1410,7 @@ PacketMetadata::ReadFromRawU8 (uint8_t& data, { return 0; } - memcpy(&data, current, sizeof (uint8_t)); + memcpy (&data, current, sizeof (uint8_t)); return const_cast (current) + sizeof (uint8_t); } @@ -1425,7 +1425,7 @@ PacketMetadata::ReadFromRawU16 (uint16_t& data, { return 0; } - memcpy(&data, current, sizeof (uint16_t)); + memcpy (&data, current, sizeof (uint16_t)); return const_cast (current) + sizeof (uint16_t); } @@ -1440,7 +1440,7 @@ PacketMetadata::ReadFromRawU32 (uint32_t& data, { return 0; } - memcpy(&data, current, sizeof (uint32_t)); + memcpy (&data, current, sizeof (uint32_t)); return const_cast (current) + sizeof (uint32_t); } @@ -1455,7 +1455,7 @@ PacketMetadata::ReadFromRawU64 (uint64_t& data, { return 0; } - memcpy(&data, current, sizeof (uint64_t)); + memcpy (&data, current, sizeof (uint64_t)); return const_cast (current) + sizeof (uint64_t); } diff --git a/src/network/model/packet.cc b/src/network/model/packet.cc index 1ab807d60..72ccc949f 100644 --- a/src/network/model/packet.cc +++ b/src/network/model/packet.cc @@ -382,7 +382,7 @@ Packet::CopyData (uint8_t *buffer, uint32_t size) const } void -Packet::CopyData(std::ostream *os, uint32_t size) const +Packet::CopyData (std::ostream *os, uint32_t size) const { return m_buffer.CopyData (os, size); } diff --git a/src/network/model/packet.h b/src/network/model/packet.h index 734ed1c79..8ddba63fb 100644 --- a/src/network/model/packet.h +++ b/src/network/model/packet.h @@ -362,7 +362,7 @@ public: * \param size the maximum number of bytes we want to write * in the output stream. */ - void CopyData(std::ostream *os, uint32_t size) const; + void CopyData (std::ostream *os, uint32_t size) const; /** * \returns a COW copy of the packet. diff --git a/src/network/model/socket.cc b/src/network/model/socket.cc index e0877c3ce..0fb41104d 100644 --- a/src/network/model/socket.cc +++ b/src/network/model/socket.cc @@ -150,7 +150,7 @@ Ptr Socket::Recv (void) { NS_LOG_FUNCTION_NOARGS (); - return Recv (std::numeric_limits::max(), 0); + return Recv (std::numeric_limits::max (), 0); } int @@ -170,7 +170,7 @@ Ptr Socket::RecvFrom (Address &fromAddress) { NS_LOG_FUNCTION_NOARGS (); - return RecvFrom (std::numeric_limits::max(), 0, fromAddress); + return RecvFrom (std::numeric_limits::max (), 0, fromAddress); } int @@ -305,9 +305,9 @@ Socket::BindToNetDevice (Ptr netdevice) if (netdevice != 0) { bool found = false; - for (uint32_t i = 0; i < GetNode()->GetNDevices (); i++) + for (uint32_t i = 0; i < GetNode ()->GetNDevices (); i++) { - if (GetNode()->GetDevice (i) == netdevice) + if (GetNode ()->GetDevice (i) == netdevice) { found = true; break; diff --git a/src/network/model/socket.h b/src/network/model/socket.h index b19f9c82c..b10fa63bf 100644 --- a/src/network/model/socket.h +++ b/src/network/model/socket.h @@ -596,8 +596,8 @@ public: protected: void NotifyConnectionSucceeded (void); void NotifyConnectionFailed (void); - void NotifyNormalClose(void); - void NotifyErrorClose(void); + void NotifyNormalClose (void); + void NotifyErrorClose (void); bool NotifyConnectionRequest (const Address &from); void NotifyNewConnectionCreated (Ptr socket, const Address &from); void NotifyDataSent (uint32_t size); diff --git a/src/network/test/buffer-test.cc b/src/network/test/buffer-test.cc index cc94cb8b3..be8db6b06 100644 --- a/src/network/test/buffer-test.cc +++ b/src/network/test/buffer-test.cc @@ -53,7 +53,7 @@ BufferTest::EnsureWrittenBytes (Buffer b, uint32_t n, uint8_t array[], const cha failure << (uint16_t)got[j] << " "; } failure << std::endl; - NS_TEST_ASSERT_MSG_EQ_INTERNAL(true, false, failure.str(), file, line); + NS_TEST_ASSERT_MSG_EQ_INTERNAL (true, false, failure.str (), file, line); } } @@ -133,22 +133,22 @@ BufferTest::DoRun (void) // test 64-bit read/write Buffer buff64; - buff64.AddAtStart(8); - i = buff64.Begin(); + buff64.AddAtStart (8); + i = buff64.Begin (); i.WriteU64 (0x0123456789ABCDEFllu); ENSURE_WRITTEN_BYTES (buff64, 8, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01); - i = buff64.Begin(); - NS_TEST_ASSERT_MSG_EQ(i.ReadLsbtohU64(), 0x0123456789abcdefllu, "Could not read expected value"); - i = buff64.Begin(); + i = buff64.Begin (); + NS_TEST_ASSERT_MSG_EQ (i.ReadLsbtohU64 (), 0x0123456789abcdefllu, "Could not read expected value"); + i = buff64.Begin (); i.WriteHtolsbU64 (0x0123456789ABCDEFllu); ENSURE_WRITTEN_BYTES (buff64, 8, 0xef, 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01); - i = buff64.Begin(); - NS_TEST_ASSERT_MSG_EQ (i.ReadLsbtohU64(), 0x0123456789abcdefllu, "Could not read expected value"); - i = buff64.Begin(); + i = buff64.Begin (); + NS_TEST_ASSERT_MSG_EQ (i.ReadLsbtohU64 (), 0x0123456789abcdefllu, "Could not read expected value"); + i = buff64.Begin (); i.WriteHtonU64 (0x0123456789ABCDEFllu); ENSURE_WRITTEN_BYTES (buff64, 8, 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef); - i = buff64.Begin(); - NS_TEST_ASSERT_MSG_EQ (i.ReadNtohU64(), 0x0123456789abcdefllu, "could not read expected value"); + i = buff64.Begin (); + NS_TEST_ASSERT_MSG_EQ (i.ReadNtohU64 (), 0x0123456789abcdefllu, "could not read expected value"); // test self-assignment { @@ -164,7 +164,7 @@ BufferTest::DoRun (void) buffer.AddAtStart (1); buffer.Begin ().WriteU8 (0xff); ENSURE_WRITTEN_BYTES (buffer, 5, 0xff, 0, 0, 0, 0); - buffer.RemoveAtStart(3); + buffer.RemoveAtStart (3); ENSURE_WRITTEN_BYTES (buffer, 2, 0, 0); buffer.AddAtStart (4); buffer.Begin ().WriteHtonU32 (0xdeadbeaf); diff --git a/src/network/test/packet-metadata-test.cc b/src/network/test/packet-metadata-test.cc index 6acdba0e3..655484666 100644 --- a/src/network/test/packet-metadata-test.cc +++ b/src/network/test/packet-metadata-test.cc @@ -330,7 +330,7 @@ PacketMetadataTest::CheckHistory (Ptr p, const char *file, int line, uin } for (std::list::iterator i = got.begin (), - j = expected.begin (); + j = expected.begin (); i != got.end (); i++, j++) { NS_ASSERT (j != expected.end ()); @@ -355,7 +355,7 @@ error: failure << *j << ", "; } failure << "\""; - NS_TEST_ASSERT_MSG_EQ_INTERNAL (false, true, failure.str(), file, line); + NS_TEST_ASSERT_MSG_EQ_INTERNAL (false, true, failure.str (), file, line); } #define ADD_HEADER(p, n) \ @@ -741,8 +741,8 @@ PacketMetadataTest::DoRun (void) p = Create (200); ADD_HEADER (p, 24); - p1 = p->CreateFragment(0, 100); - p2 = p->CreateFragment(100, 100); + p1 = p->CreateFragment (0, 100); + p2 = p->CreateFragment (100, 100); p1->AddAtEnd (p2); p = Create (); @@ -778,48 +778,48 @@ PacketMetadataTest::DoRun (void) CHECK_HISTORY (p, 4, 5, 20, 10, 500); p1 = p->CreateFragment (0,6); p2 = p->CreateFragment (6,535-6); - p1->AddAtEnd(p2); + p1->AddAtEnd (p2); // bug 1072#2 p = Create (reinterpret_cast ("hello world"), 11); ADD_HEADER (p, 2); - CHECK_HISTORY(p, 2, 2, 11); + CHECK_HISTORY (p, 2, 2, 11); p1 = p->CreateFragment (0, 5); - CHECK_HISTORY(p1, 2, 2, 3); + CHECK_HISTORY (p1, 2, 2, 3); p2 = p->CreateFragment (5, 8); - CHECK_HISTORY(p2, 1, 8); + CHECK_HISTORY (p2, 1, 8); ADD_HEADER (p1, 8+2+2*6); ADD_TRAILER (p1, 4); - CHECK_HISTORY(p1, 4, 22, 2, 3, 4); + CHECK_HISTORY (p1, 4, 22, 2, 3, 4); ADD_HEADER (p2, 8+2+2*6); ADD_TRAILER (p2, 4); - CHECK_HISTORY(p2, 3, 22, 8, 4); + CHECK_HISTORY (p2, 3, 22, 8, 4); REM_TRAILER (p1, 4); REM_HEADER (p1, 8+2+2*6); - CHECK_HISTORY(p1, 2, 2, 3); + CHECK_HISTORY (p1, 2, 2, 3); REM_TRAILER (p2, 4); REM_HEADER (p2, 8+2+2*6); - CHECK_HISTORY(p2, 1, 8); + CHECK_HISTORY (p2, 1, 8); - p3 = p1->Copy(); - CHECK_HISTORY(p3, 2, 2, 3); - p3->AddAtEnd(p2); - CHECK_HISTORY(p3, 2, 2, 11); + p3 = p1->Copy (); + CHECK_HISTORY (p3, 2, 2, 3); + p3->AddAtEnd (p2); + CHECK_HISTORY (p3, 2, 2, 11); - CHECK_HISTORY(p, 2, 2, 11); + CHECK_HISTORY (p, 2, 2, 11); REM_HEADER (p, 2); - CHECK_HISTORY(p, 1, 11); + CHECK_HISTORY (p, 1, 11); REM_HEADER (p3, 2); - CHECK_HISTORY(p3, 1, 11); + CHECK_HISTORY (p3, 1, 11); uint8_t *buf = new uint8_t[p3->GetSize ()]; p3->CopyData (buf, p3->GetSize ()); std::string msg = std::string (reinterpret_cast(buf), p3->GetSize ()); delete [] buf; - NS_TEST_EXPECT_MSG_EQ(msg, std::string("hello world"), "Could not find original data in received packet"); + NS_TEST_EXPECT_MSG_EQ (msg, std::string ("hello world"), "Could not find original data in received packet"); } //----------------------------------------------------------------------------- class PacketMetadataTestSuite : public TestSuite diff --git a/src/network/test/packet-test-suite.cc b/src/network/test/packet-test-suite.cc index 59f20319c..7a65e5e71 100644 --- a/src/network/test/packet-test-suite.cc +++ b/src/network/test/packet-test-suite.cc @@ -282,7 +282,7 @@ PacketTest::DoRun (void) CHECK (copy, 1, E (1, 0, 1000)); p->AddByteTag (ATestTag<2> ()); - CHECK (p, 2, E (1, 0, 1000), E(2, 0, 1000)); + CHECK (p, 2, E (1, 0, 1000), E (2, 0, 1000)); CHECK (copy, 1, E (1, 0, 1000)); { @@ -302,21 +302,21 @@ PacketTest::DoRun (void) Ptr frag1 = p->CreateFragment (10, 90); Ptr frag2 = p->CreateFragment (100, 900); frag0->AddByteTag (ATestTag<3> ()); - CHECK (frag0, 3, E (1, 0, 10), E(2, 0, 10), E (3, 0, 10)); + CHECK (frag0, 3, E (1, 0, 10), E (2, 0, 10), E (3, 0, 10)); frag1->AddByteTag (ATestTag<4> ()); - CHECK (frag1, 3, E (1, 0, 90), E(2, 0, 90), E (4, 0, 90)); + CHECK (frag1, 3, E (1, 0, 90), E (2, 0, 90), E (4, 0, 90)); frag2->AddByteTag (ATestTag<5> ()); - CHECK (frag2, 3, E (1, 0, 900), E(2, 0, 900), E (5, 0, 900)); + CHECK (frag2, 3, E (1, 0, 900), E (2, 0, 900), E (5, 0, 900)); frag1->AddAtEnd (frag2); - CHECK (frag1, 6, E (1, 0, 90), E(2, 0, 90), E (4, 0, 90), E (1, 90, 990), E(2, 90, 990), E (5, 90, 990)); + CHECK (frag1, 6, E (1, 0, 90), E (2, 0, 90), E (4, 0, 90), E (1, 90, 990), E (2, 90, 990), E (5, 90, 990)); - CHECK (frag0, 3, E (1, 0, 10), E(2, 0, 10), E (3, 0, 10)); + CHECK (frag0, 3, E (1, 0, 10), E (2, 0, 10), E (3, 0, 10)); frag0->AddAtEnd (frag1); CHECK (frag0, 9, - E (1, 0, 10), E(2, 0, 10), E (3, 0, 10), - E (1, 10, 100), E(2, 10, 100), E (4, 10, 100), - E (1, 100, 1000), E(2, 100, 1000), E (5, 100, 1000)); + E (1, 0, 10), E (2, 0, 10), E (3, 0, 10), + E (1, 10, 100), E (2, 10, 100), E (4, 10, 100), + E (1, 100, 1000), E (2, 100, 1000), E (5, 100, 1000)); // force caching a buffer of the right size. diff --git a/src/network/test/packetbb-test-suite.cc b/src/network/test/packetbb-test-suite.cc index affd820dc..43d96d0eb 100644 --- a/src/network/test/packetbb-test-suite.cc +++ b/src/network/test/packetbb-test-suite.cc @@ -259,7 +259,7 @@ PbbTestSuite::PbbTestSuite () tlv2->SetTypeExt (100); uint8_t tlv2val[] = { 1, 2, 3, 4}; - tlv2->SetValue(tlv2val, sizeof(tlv2val)); + tlv2->SetValue (tlv2val, sizeof(tlv2val)); packet->TlvPushBack (tlv2); @@ -452,7 +452,7 @@ PbbTestSuite::PbbTestSuite () 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c }; - tlv2->SetValue(tlv2val, sizeof(tlv2val)); + tlv2->SetValue (tlv2val, sizeof(tlv2val)); packet->TlvPushBack (tlv2); @@ -622,7 +622,7 @@ PbbTestSuite::PbbTestSuite () Ptr msg2 = Create (); msg2->SetType (2); - msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1")); + msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1")); packet->MessagePushBack (msg2); uint8_t buffer[] = { @@ -679,7 +679,7 @@ PbbTestSuite::PbbTestSuite () Ptr msg2 = Create (); msg2->SetType (2); - msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1")); + msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1")); msg2->SetHopCount (1); packet->MessagePushBack (msg2); @@ -738,7 +738,7 @@ PbbTestSuite::PbbTestSuite () Ptr msg2 = Create (); msg2->SetType (2); - msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1")); + msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1")); msg2->SetHopLimit (255); msg2->SetHopCount (1); packet->MessagePushBack (msg2); @@ -800,7 +800,7 @@ PbbTestSuite::PbbTestSuite () Ptr msg2 = Create (); msg2->SetType (2); - msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1")); + msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1")); msg2->SetHopLimit (255); msg2->SetHopCount (1); msg2->SetSequenceNumber (12345); @@ -863,7 +863,7 @@ PbbTestSuite::PbbTestSuite () Ptr msg2 = Create (); msg2->SetType (2); - msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1")); + msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1")); msg2->SetHopLimit (255); msg2->SetHopCount (1); msg2->SetSequenceNumber (12345); @@ -935,7 +935,7 @@ PbbTestSuite::PbbTestSuite () Ptr msg2 = Create (); msg2->SetType (2); - msg2->SetOriginatorAddress(Ipv4Address("10.0.0.1")); + msg2->SetOriginatorAddress (Ipv4Address ("10.0.0.1")); msg2->SetHopLimit (255); msg2->SetHopCount (1); msg2->SetSequenceNumber (12345); @@ -2223,7 +2223,7 @@ PbbTestSuite::PbbTestSuite () msg2a2tlv1->SetIndexStop (3); uint8_t value[] = { 1, 2, 3}; - msg2a2tlv1->SetValue(value, sizeof (value)); + msg2a2tlv1->SetValue (value, sizeof (value)); msg2a2tlv1->SetMultivalue (true); msg2a2->TlvPushBack (msg2a2tlv1); @@ -2505,7 +2505,7 @@ PbbTestSuite::PbbTestSuite () 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, }; - msg2a2tlv1->SetValue(value, sizeof (value)); + msg2a2tlv1->SetValue (value, sizeof (value)); msg2a2->TlvPushBack (msg2a2tlv1); @@ -2630,7 +2630,7 @@ PbbTestSuite::PbbTestSuite () Ptr packet = Create (); Ptr m1 = Create (); - m1->SetType(1); + m1->SetType (1); packet->MessagePushBack (m1); @@ -2661,8 +2661,8 @@ PbbTestSuite::PbbTestSuite () Ptr packet = Create (); Ptr m1 = Create (); - m1->SetType(1); - m1->SetOriginatorAddress (Ipv6Address("abcd::1")); + m1->SetType (1); + m1->SetOriginatorAddress (Ipv6Address ("abcd::1")); packet->MessagePushBack (m1); @@ -2701,8 +2701,8 @@ PbbTestSuite::PbbTestSuite () Ptr packet = Create (); Ptr m1 = Create (); - m1->SetType(1); - m1->SetOriginatorAddress (Ipv6Address("abcd::1")); + m1->SetType (1); + m1->SetOriginatorAddress (Ipv6Address ("abcd::1")); Ptr m1a1 = Create (); m1a1->AddressPushBack (Ipv6Address ("10::1")); @@ -2751,8 +2751,8 @@ PbbTestSuite::PbbTestSuite () Ptr packet = Create (); Ptr m1 = Create (); - m1->SetType(1); - m1->SetOriginatorAddress (Ipv6Address("abcd::1")); + m1->SetType (1); + m1->SetOriginatorAddress (Ipv6Address ("abcd::1")); Ptr m1a1 = Create (); m1a1->AddressPushBack (Ipv6Address ("10::1")); @@ -2803,8 +2803,8 @@ PbbTestSuite::PbbTestSuite () Ptr packet = Create (); Ptr m1 = Create (); - m1->SetType(1); - m1->SetOriginatorAddress (Ipv6Address("abcd::1")); + m1->SetType (1); + m1->SetOriginatorAddress (Ipv6Address ("abcd::1")); Ptr m1a1 = Create (); m1a1->AddressPushBack (Ipv6Address ("10::2")); @@ -2860,8 +2860,8 @@ PbbTestSuite::PbbTestSuite () Ptr packet = Create (); Ptr m1 = Create (); - m1->SetType(1); - m1->SetOriginatorAddress (Ipv6Address("abcd::1")); + m1->SetType (1); + m1->SetOriginatorAddress (Ipv6Address ("abcd::1")); Ptr m1a1 = Create (); m1a1->AddressPushBack (Ipv6Address ("10::2")); @@ -2926,8 +2926,8 @@ PbbTestSuite::PbbTestSuite () Ptr packet = Create (); Ptr m1 = Create (); - m1->SetType(1); - m1->SetOriginatorAddress (Ipv6Address("abcd::1")); + m1->SetType (1); + m1->SetOriginatorAddress (Ipv6Address ("abcd::1")); Ptr m1a1 = Create (); m1a1->AddressPushBack (Ipv6Address ("10::2")); diff --git a/src/network/test/pcap-file-test-suite.cc b/src/network/test/pcap-file-test-suite.cc index c90ba904f..f78942226 100644 --- a/src/network/test/pcap-file-test-suite.cc +++ b/src/network/test/pcap-file-test-suite.cc @@ -180,7 +180,7 @@ WriteModeCreateTestCase::DoRun (void) // data. // uint8_t buffer[128]; - memset(buffer, 0, sizeof(buffer)); + memset (buffer, 0, sizeof(buffer)); f.Write (0, 0, buffer, 128); NS_TEST_ASSERT_MSG_EQ (f.Fail (), false, "Write (write-only-file " << m_testFilename << ") returns error"); @@ -390,7 +390,7 @@ AppendModeCreateTestCase::DoRun (void) // We should be able to write to it since it was opened in "std::ios::app" mode. // uint8_t buffer[128]; - memset(buffer, 0, sizeof(buffer)); + memset (buffer, 0, sizeof(buffer)); f.Write (0, 0, buffer, 128); NS_TEST_ASSERT_MSG_EQ (f.Fail (), false, "Write (append-mode-file " << m_testFilename << ") returns error"); @@ -582,19 +582,19 @@ FileHeaderTestCase::DoRun (void) result = fread (&val32, sizeof(val32), 1, p); NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() magic number"); - NS_TEST_ASSERT_MSG_EQ (val32, Swap(uint32_t (0xa1b2c3d4)), "Magic number written incorrectly"); + NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (0xa1b2c3d4)), "Magic number written incorrectly"); result = fread (&val16, sizeof(val16), 1, p); NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() version major"); - NS_TEST_ASSERT_MSG_EQ (val16, Swap(uint16_t (2)), "Version major written incorrectly"); + NS_TEST_ASSERT_MSG_EQ (val16, Swap (uint16_t (2)), "Version major written incorrectly"); result = fread (&val16, sizeof(val16), 1, p); NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() version minor"); - NS_TEST_ASSERT_MSG_EQ (val16, Swap(uint16_t (4)), "Version minor written incorrectly"); + NS_TEST_ASSERT_MSG_EQ (val16, Swap (uint16_t (4)), "Version minor written incorrectly"); result = fread (&val32, sizeof(val32), 1, p); NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() time zone correction"); - NS_TEST_ASSERT_MSG_EQ (val32, Swap(uint32_t (7)), "Version minor written incorrectly"); + NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (7)), "Version minor written incorrectly"); result = fread (&val32, sizeof(val32), 1, p); NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() sig figs"); @@ -602,11 +602,11 @@ FileHeaderTestCase::DoRun (void) result = fread (&val32, sizeof(val32), 1, p); NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() snap length"); - NS_TEST_ASSERT_MSG_EQ (val32, Swap(uint32_t (5678)), "Snap length written incorrectly"); + NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (5678)), "Snap length written incorrectly"); result = fread (&val32, sizeof(val32), 1, p); NS_TEST_ASSERT_MSG_EQ (result, 1, "Unable to fread() data link type"); - NS_TEST_ASSERT_MSG_EQ (val32, Swap(uint32_t (1234)), "Data length type written incorrectly"); + NS_TEST_ASSERT_MSG_EQ (val32, Swap (uint32_t (1234)), "Data length type written incorrectly"); fclose (p); p = 0; @@ -1071,7 +1071,7 @@ DiffTestCase::DoRun (void) // Check that PcapDiff(file, file) is false // std::string filename = NS_TEST_SOURCEDIR + "known.pcap"; - uint32_t sec(0), usec(0); + uint32_t sec (0), usec (0); bool diff = PcapFile::Diff (filename, filename, sec, usec); NS_TEST_EXPECT_MSG_EQ (diff, false, "PcapDiff(file, file) must always be false"); diff --git a/src/network/test/sequence-number-test-suite.cc b/src/network/test/sequence-number-test-suite.cc index 601c1c9e5..2ee9c887d 100644 --- a/src/network/test/sequence-number-test-suite.cc +++ b/src/network/test/sequence-number-test-suite.cc @@ -40,7 +40,7 @@ public: static TypeId GetTypeId (void) { - static TypeId tid = TypeId("ns3::SequenceNumberTestObj") + static TypeId tid = TypeId ("ns3::SequenceNumberTestObj") .SetParent () .AddTraceSource ("TestTracedSequenceNumber", "A traceable sequence number", @@ -97,8 +97,8 @@ SequenceNumberTestCase::SequenceNumberTracer (SequenceNumber32 oldval, SequenceN void SequenceNumberTestCase::DoRun (void) { -#define NS_TEST_ASSERT_EQUAL(a,b) NS_TEST_ASSERT_MSG_EQ(a,b, "foo") -#define NS_TEST_ASSERT(a) NS_TEST_ASSERT_MSG_EQ(bool(a), true, "foo") +#define NS_TEST_ASSERT_EQUAL(a,b) NS_TEST_ASSERT_MSG_EQ (a,b, "foo") +#define NS_TEST_ASSERT(a) NS_TEST_ASSERT_MSG_EQ (bool(a), true, "foo") { SequenceNumber32 num1 (3), num2 (5); diff --git a/src/network/utils/address-utils.cc b/src/network/utils/address-utils.cc index 500d74322..078da244c 100644 --- a/src/network/utils/address-utils.cc +++ b/src/network/utils/address-utils.cc @@ -29,8 +29,8 @@ void WriteTo (Buffer::Iterator &i, Ipv4Address ad) void WriteTo (Buffer::Iterator &i, Ipv6Address ad) { uint8_t buf[16]; - ad.GetBytes(buf); - i.Write(buf, 16); + ad.GetBytes (buf); + i.Write (buf, 16); } void WriteTo (Buffer::Iterator &i, const Address &ad) { @@ -52,7 +52,7 @@ void ReadFrom (Buffer::Iterator &i, Ipv4Address &ad) void ReadFrom (Buffer::Iterator &i, Ipv6Address &ad) { uint8_t ipv6[16]; - i.Read(ipv6, 16); + i.Read (ipv6, 16); ad.Set (ipv6); } void ReadFrom (Buffer::Iterator &i, Address &ad, uint32_t len) diff --git a/src/network/utils/data-rate.cc b/src/network/utils/data-rate.cc index a793292b0..8ecd06697 100644 --- a/src/network/utils/data-rate.cc +++ b/src/network/utils/data-rate.cc @@ -26,14 +26,14 @@ static bool DoParse (const std::string s, uint64_t *v) { - std::string::size_type n = s.find_first_not_of("0123456789."); + std::string::size_type n = s.find_first_not_of ("0123456789."); if (n != std::string::npos) { // Found non-numeric std::istringstream iss; - iss.str (s.substr(0, n)); + iss.str (s.substr (0, n)); double r; iss >> r; - std::string trailer = s.substr(n, std::string::npos); + std::string trailer = s.substr (n, std::string::npos); if (trailer == "bps") { // bit/s @@ -187,7 +187,7 @@ DataRate::DataRate () } DataRate::DataRate(uint64_t bps) - : m_bps(bps) + : m_bps (bps) { } @@ -221,12 +221,12 @@ bool DataRate::operator != (const DataRate& rhs) const return m_bps!=rhs.m_bps; } -double DataRate::CalculateTxTime(uint32_t bytes) const +double DataRate::CalculateTxTime (uint32_t bytes) const { return static_cast(bytes)*8/m_bps; } -uint64_t DataRate::GetBitRate() const +uint64_t DataRate::GetBitRate () const { return m_bps; } @@ -261,14 +261,14 @@ std::istream &operator >> (std::istream &is, DataRate &rate) -double operator*(const DataRate& lhs, const Time& rhs) +double operator* (const DataRate& lhs, const Time& rhs) { - return rhs.GetSeconds()*lhs.GetBitRate(); + return rhs.GetSeconds ()*lhs.GetBitRate (); } -double operator*(const Time& lhs, const DataRate& rhs) +double operator* (const Time& lhs, const DataRate& rhs) { - return lhs.GetSeconds()*rhs.GetBitRate(); + return lhs.GetSeconds ()*rhs.GetBitRate (); } } //namespace ns3 diff --git a/src/network/utils/data-rate.h b/src/network/utils/data-rate.h index f4777f8b6..9d980da17 100644 --- a/src/network/utils/data-rate.h +++ b/src/network/utils/data-rate.h @@ -97,17 +97,17 @@ public: * \param bytes The number of bytes (not bits) for which to calculate * \return The transmission time in seconds for the number of bytes specified */ - double CalculateTxTime(uint32_t bytes) const; + double CalculateTxTime (uint32_t bytes) const; /** * Get the underlying bitrate * \return The underlying bitrate in bits per second */ - uint64_t GetBitRate() const; + uint64_t GetBitRate () const; private: uint64_t m_bps; - static uint64_t Parse(const std::string); + static uint64_t Parse (const std::string); }; std::ostream &operator << (std::ostream &os, const DataRate &rate); @@ -125,8 +125,8 @@ ATTRIBUTE_HELPER_HEADER (DataRate); * \param rhs * \return Bits transmitted in rhs seconds at lhs b/s */ -double operator*(const DataRate& lhs, const Time& rhs); -double operator*(const Time& lhs, const DataRate& rhs); +double operator* (const DataRate& lhs, const Time& rhs); +double operator* (const Time& lhs, const DataRate& rhs); } //namespace ns3 diff --git a/src/network/utils/drop-tail-queue.cc b/src/network/utils/drop-tail-queue.cc index 73b919689..03de05210 100644 --- a/src/network/utils/drop-tail-queue.cc +++ b/src/network/utils/drop-tail-queue.cc @@ -100,7 +100,7 @@ DropTailQueue::DoEnqueue (Ptr p) } m_bytesInQueue += p->GetSize (); - m_packets.push(p); + m_packets.push (p); NS_LOG_LOGIC ("Number packets " << m_packets.size ()); NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue); @@ -113,7 +113,7 @@ DropTailQueue::DoDequeue (void) { NS_LOG_FUNCTION (this); - if (m_packets.empty()) + if (m_packets.empty ()) { NS_LOG_LOGIC ("Queue empty"); return 0; @@ -136,7 +136,7 @@ DropTailQueue::DoPeek (void) const { NS_LOG_FUNCTION (this); - if (m_packets.empty()) + if (m_packets.empty ()) { NS_LOG_LOGIC ("Queue empty"); return 0; diff --git a/src/network/utils/error-model.cc b/src/network/utils/error-model.cc index 3f50690df..1c8d2d1ad 100644 --- a/src/network/utils/error-model.cc +++ b/src/network/utils/error-model.cc @@ -214,7 +214,7 @@ RateErrorModel::DoCorruptByte (Ptr p) } bool -RateErrorModel::DoCorruptBit(Ptr p) +RateErrorModel::DoCorruptBit (Ptr p) { NS_LOG_FUNCTION_NOARGS (); // compute pkt error rate, assume uniformly distributed bit error @@ -295,7 +295,7 @@ void ListErrorModel::DoReset (void) { NS_LOG_FUNCTION_NOARGS (); - m_packetList.clear(); + m_packetList.clear (); } // @@ -363,7 +363,7 @@ void ReceiveListErrorModel::DoReset (void) { NS_LOG_FUNCTION_NOARGS (); - m_packetList.clear(); + m_packetList.clear (); } diff --git a/src/network/utils/ethernet-header.cc b/src/network/utils/ethernet-header.cc index ba0715d38..9b98f1653 100644 --- a/src/network/utils/ethernet-header.cc +++ b/src/network/utils/ethernet-header.cc @@ -97,7 +97,7 @@ EthernetHeader::GetPacketType (void) const uint32_t EthernetHeader::GetHeaderSize (void) const { - return GetSerializedSize(); + return GetSerializedSize (); } @@ -148,7 +148,7 @@ EthernetHeader::Serialize (Buffer::Iterator start) const if (m_enPreambleSfd) { - i.WriteU64(m_preambleSfd); + i.WriteU64 (m_preambleSfd); } WriteTo (i, m_destination); WriteTo (i, m_source); diff --git a/src/network/utils/ethernet-header.h b/src/network/utils/ethernet-header.h index c4eb6ad60..a1dc233e6 100644 --- a/src/network/utils/ethernet-header.h +++ b/src/network/utils/ethernet-header.h @@ -101,7 +101,7 @@ public: /** * \return The size of the header */ - uint32_t GetHeaderSize() const; + uint32_t GetHeaderSize () const; static TypeId GetTypeId (void); virtual TypeId GetInstanceTypeId (void) const; diff --git a/src/network/utils/ethernet-trailer.cc b/src/network/utils/ethernet-trailer.cc index 014347d63..4b4cccb1f 100644 --- a/src/network/utils/ethernet-trailer.cc +++ b/src/network/utils/ethernet-trailer.cc @@ -92,7 +92,7 @@ EthernetTrailer::GetFcs (void) uint32_t EthernetTrailer::GetTrailerSize (void) const { - return GetSerializedSize(); + return GetSerializedSize (); } TypeId @@ -124,7 +124,7 @@ void EthernetTrailer::Serialize (Buffer::Iterator end) const { Buffer::Iterator i = end; - i.Prev(GetSerializedSize()); + i.Prev (GetSerializedSize ()); i.WriteU32 (m_fcs); } @@ -132,8 +132,8 @@ uint32_t EthernetTrailer::Deserialize (Buffer::Iterator end) { Buffer::Iterator i = end; - uint32_t size = GetSerializedSize(); - i.Prev(size); + uint32_t size = GetSerializedSize (); + i.Prev (size); m_fcs = i.ReadU32 (); diff --git a/src/network/utils/ethernet-trailer.h b/src/network/utils/ethernet-trailer.h index 22aae5458..884e6acf5 100644 --- a/src/network/utils/ethernet-trailer.h +++ b/src/network/utils/ethernet-trailer.h @@ -88,7 +88,7 @@ public: /** *\return Returns the size of the trailer */ - uint32_t GetTrailerSize() const; + uint32_t GetTrailerSize () const; static TypeId GetTypeId (void); virtual TypeId GetInstanceTypeId (void) const; diff --git a/src/network/utils/inet6-socket-address.cc b/src/network/utils/inet6-socket-address.cc index e26d2a0a2..d307f23e7 100644 --- a/src/network/utils/inet6-socket-address.cc +++ b/src/network/utils/inet6-socket-address.cc @@ -26,32 +26,32 @@ namespace ns3 { Inet6SocketAddress::Inet6SocketAddress (Ipv6Address ipv6, uint16_t port) - : m_ipv6(ipv6), - m_port(port) + : m_ipv6 (ipv6), + m_port (port) { } Inet6SocketAddress::Inet6SocketAddress (Ipv6Address ipv6) - : m_ipv6(ipv6), - m_port(0) + : m_ipv6 (ipv6), + m_port (0) { } Inet6SocketAddress::Inet6SocketAddress (const char* ipv6, uint16_t port) - : m_ipv6(Ipv6Address(ipv6)), - m_port(port) + : m_ipv6 (Ipv6Address (ipv6)), + m_port (port) { } Inet6SocketAddress::Inet6SocketAddress (const char* ipv6) - : m_ipv6(Ipv6Address(ipv6)), - m_port(0) + : m_ipv6 (Ipv6Address (ipv6)), + m_port (0) { } Inet6SocketAddress::Inet6SocketAddress (uint16_t port) - : m_ipv6(Ipv6Address::GetAny()), - m_port(port) + : m_ipv6 (Ipv6Address::GetAny ()), + m_port (port) { } @@ -77,36 +77,36 @@ void Inet6SocketAddress::SetIpv6 (Ipv6Address ipv6) bool Inet6SocketAddress::IsMatchingType (const Address &addr) { - return addr.CheckCompatible(GetType(), 18); /* 16 (address) + 2 (port) */ + return addr.CheckCompatible (GetType (), 18); /* 16 (address) + 2 (port) */ } Inet6SocketAddress::operator Address (void) const { - return ConvertTo(); + return ConvertTo (); } Address Inet6SocketAddress::ConvertTo (void) const { uint8_t buf[18]; - m_ipv6.Serialize(buf); + m_ipv6.Serialize (buf); buf[16]=m_port & 0xff; buf[17]=(m_port >> 8) &0xff; - return Address(GetType(), buf, 18); + return Address (GetType (), buf, 18); } Inet6SocketAddress Inet6SocketAddress::ConvertFrom (const Address &addr) { - NS_ASSERT(addr.CheckCompatible(GetType(), 18)); + NS_ASSERT (addr.CheckCompatible (GetType (), 18)); uint8_t buf[18]; - addr.CopyTo(buf); - Ipv6Address ipv6=Ipv6Address::Deserialize(buf); + addr.CopyTo (buf); + Ipv6Address ipv6=Ipv6Address::Deserialize (buf); uint16_t port= buf[16] | (buf[17] << 8); - return Inet6SocketAddress(ipv6, port); + return Inet6SocketAddress (ipv6, port); } uint8_t Inet6SocketAddress::GetType (void) { - static uint8_t type=Address::Register(); + static uint8_t type=Address::Register (); return type; } diff --git a/src/network/utils/ipv4-address.cc b/src/network/utils/ipv4-address.cc index 862bf3ccc..b2f070fe0 100644 --- a/src/network/utils/ipv4-address.cc +++ b/src/network/utils/ipv4-address.cc @@ -23,7 +23,7 @@ #include "ipv4-address.h" #include "ns3/assert.h" -NS_LOG_COMPONENT_DEFINE("Ipv4Address"); +NS_LOG_COMPONENT_DEFINE ("Ipv4Address"); namespace ns3 { @@ -341,7 +341,7 @@ Ipv4Address::GetLoopback (void) return loopback; } -size_t Ipv4AddressHash::operator()(Ipv4Address const &x) const +size_t Ipv4AddressHash::operator() (Ipv4Address const &x) const { return x.Get (); } diff --git a/src/network/utils/ipv4-address.h b/src/network/utils/ipv4-address.h index fab1f2b2d..86f303486 100644 --- a/src/network/utils/ipv4-address.h +++ b/src/network/utils/ipv4-address.h @@ -310,7 +310,7 @@ inline bool operator < (const Ipv4Address &a, const Ipv4Address &b) class Ipv4AddressHash : public std::unary_function { public: - size_t operator()(Ipv4Address const &x) const; + size_t operator() (Ipv4Address const &x) const; }; bool operator == (Ipv4Mask const &a, Ipv4Mask const &b); diff --git a/src/network/utils/ipv6-address.cc b/src/network/utils/ipv6-address.cc index b57ff471e..455183e24 100644 --- a/src/network/utils/ipv6-address.cc +++ b/src/network/utils/ipv6-address.cc @@ -195,7 +195,7 @@ static bool AsciiToIpv6Host (const char *address, uint8_t addr[16]) /* TODO Handle IPv4 mapped address (2001::192.168.0.1) */ #if 0 if (ch == '.' && ((tp + 4 /*NS_INADDRSZ*/) <= endp) && - inet_pton4(curtok, tp) > 0) + inet_pton4 (curtok, tp) > 0) { tp += 4 /*NS_INADDRSZ*/; seen_xdigits = 0; @@ -296,7 +296,7 @@ void Ipv6Address::Serialize (uint8_t buf[16]) const Ipv6Address Ipv6Address::Deserialize (const uint8_t buf[16]) { - Ipv6Address ipv6((uint8_t*)buf); + Ipv6Address ipv6 ((uint8_t*)buf); return ipv6; } @@ -408,7 +408,7 @@ Ipv6Address Ipv6Address::CombinePrefix (Ipv6Prefix const& prefix) ((Ipv6Prefix)prefix).GetBytes (pref); /* a little bit ugly... */ - for (i = 0 ; i < 16 ; i++) + for (i = 0; i < 16; i++) { addr[i] = addr[i] & pref[i]; } @@ -609,7 +609,7 @@ Ipv6Prefix::Ipv6Prefix (uint8_t prefix) if (nb < 16) { nb++; - for (i = nb; i < 16 ; i++) + for (i = nb; i < 16; i++) { m_prefix[i] = 0x00; } @@ -641,7 +641,7 @@ bool Ipv6Prefix::IsMatch (Ipv6Address a, Ipv6Address b) const b.GetBytes (addrB); /* a little bit ugly... */ - for (i = 0 ; i < 16 ; i++) + for (i = 0; i < 16; i++) { if ((addrA[i] & m_prefix[i]) != (addrB[i] & m_prefix[i])) { @@ -654,21 +654,21 @@ bool Ipv6Prefix::IsMatch (Ipv6Address a, Ipv6Address b) const void Ipv6Prefix::Print (std::ostream &os) const { os << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[0] - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[1] << ":" - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[2] - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[3] << ":" - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[4] - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[5] << ":" - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[6] - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[7] << ":" - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[8] - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[9] << ":" - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[10] - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[11] << ":" - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[12] - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[13] << ":" - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[14] - << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[15]; + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[1] << ":" + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[2] + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[3] << ":" + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[4] + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[5] << ":" + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[6] + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[7] << ":" + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[8] + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[9] << ":" + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[10] + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[11] << ":" + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[12] + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[13] << ":" + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[14] + << std::hex << std::setw (2) << std::setfill ('0') << (unsigned int) m_prefix[15]; } Ipv6Prefix Ipv6Prefix::GetLoopback () @@ -699,7 +699,7 @@ uint8_t Ipv6Prefix::GetPrefixLength () const uint8_t i = 0; uint8_t prefixLength = 0; - for(i = 0 ; i < 16 ; i++) + for(i = 0; i < 16; i++) { uint8_t mask = m_prefix[i]; diff --git a/src/network/utils/mac48-address.cc b/src/network/utils/mac48-address.cc index a3a3e4a86..22d4930f6 100644 --- a/src/network/utils/mac48-address.cc +++ b/src/network/utils/mac48-address.cc @@ -200,9 +200,9 @@ Mac48Address::GetMulticast (Ipv4Address multicastGroup) result.CopyFrom (etherBuffer); return result; } -Mac48Address Mac48Address::GetMulticast(Ipv6Address addr) +Mac48Address Mac48Address::GetMulticast (Ipv6Address addr) { - Mac48Address etherAddr = Mac48Address::GetMulticast6Prefix(); + Mac48Address etherAddr = Mac48Address::GetMulticast6Prefix (); uint8_t etherBuffer[6]; uint8_t ipBuffer[16]; @@ -227,15 +227,15 @@ std::ostream& operator<< (std::ostream& os, const Mac48Address & address) address.CopyTo (ad); os.setf (std::ios::hex, std::ios::basefield); - os.fill('0'); + os.fill ('0'); for (uint8_t i=0; i < 5; i++) { - os << std::setw(2) << (uint32_t)ad[i] << ":"; + os << std::setw (2) << (uint32_t)ad[i] << ":"; } // Final byte not suffixed by ":" - os << std::setw(2) << (uint32_t)ad[5]; + os << std::setw (2) << (uint32_t)ad[5]; os.setf (std::ios::dec, std::ios::basefield); - os.fill(' '); + os.fill (' '); return os; } diff --git a/src/network/utils/mac64-address.cc b/src/network/utils/mac64-address.cc index 10669589d..3d020676d 100644 --- a/src/network/utils/mac64-address.cc +++ b/src/network/utils/mac64-address.cc @@ -156,15 +156,15 @@ std::ostream& operator<< (std::ostream& os, const Mac64Address & address) address.CopyTo (ad); os.setf (std::ios::hex, std::ios::basefield); - os.fill('0'); + os.fill ('0'); for (uint8_t i=0; i < 7; i++) { - os << std::setw(2) << (uint32_t)ad[i] << ":"; + os << std::setw (2) << (uint32_t)ad[i] << ":"; } // Final byte not suffixed by ":" - os << std::setw(2) << (uint32_t)ad[7]; + os << std::setw (2) << (uint32_t)ad[7]; os.setf (std::ios::dec, std::ios::basefield); - os.fill(' '); + os.fill (' '); return os; } diff --git a/src/network/utils/packet-socket.cc b/src/network/utils/packet-socket.cc index e6c14df60..5308ca9fa 100644 --- a/src/network/utils/packet-socket.cc +++ b/src/network/utils/packet-socket.cc @@ -140,7 +140,7 @@ PacketSocket::DoBind (const PacketSocketAddress &address) m_errno = ERROR_BADF; return -1; } - Ptr dev ; + Ptr dev; if (address.IsSingleDevice ()) { dev = m_node->GetDevice (address.GetSingleDevice ()); @@ -185,7 +185,7 @@ PacketSocket::ShutdownRecv (void) } int -PacketSocket::Close(void) +PacketSocket::Close (void) { NS_LOG_FUNCTION (this); if (m_state == STATE_CLOSED) @@ -204,7 +204,7 @@ PacketSocket::Close(void) } int -PacketSocket::Connect(const Address &ad) +PacketSocket::Connect (const Address &ad) { NS_LOG_FUNCTION (this << ad); PacketSocketAddress address; @@ -238,7 +238,7 @@ error: return -1; } int -PacketSocket::Listen(void) +PacketSocket::Listen (void) { m_errno = Socket::ERROR_OPNOTSUPP; return -1; @@ -385,7 +385,7 @@ PacketSocket::ForwardUp (Ptr device, Ptr packet, copy->AddPacketTag (tag); m_deliveryQueue.push (copy); m_rxAvailable += packet->GetSize (); - NS_LOG_LOGIC ("UID is " << packet->GetUid() << " PacketSocket " << this); + NS_LOG_LOGIC ("UID is " << packet->GetUid () << " PacketSocket " << this); NotifyDataRecv (); } else @@ -413,7 +413,7 @@ Ptr PacketSocket::Recv (uint32_t maxSize, uint32_t flags) { NS_LOG_FUNCTION (this << maxSize << flags); - if (m_deliveryQueue.empty() ) + if (m_deliveryQueue.empty () ) { return 0; } @@ -453,18 +453,18 @@ int PacketSocket::GetSockName (Address &address) const { NS_LOG_FUNCTION (this << address); - PacketSocketAddress ad = PacketSocketAddress::ConvertFrom(address); + PacketSocketAddress ad = PacketSocketAddress::ConvertFrom (address); ad.SetProtocol (m_protocol); if (m_isSingleDevice) { Ptr device = m_node->GetDevice (ad.GetSingleDevice ()); - ad.SetPhysicalAddress(device->GetAddress()); + ad.SetPhysicalAddress (device->GetAddress ()); ad.SetSingleDevice (m_device); } else { - ad.SetPhysicalAddress(Address()); + ad.SetPhysicalAddress (Address ()); ad.SetAllDevices (); } address = ad; diff --git a/src/network/utils/packet-socket.h b/src/network/utils/packet-socket.h index 2c753e41a..9457e94b1 100644 --- a/src/network/utils/packet-socket.h +++ b/src/network/utils/packet-socket.h @@ -93,11 +93,11 @@ public: virtual int Close (void); virtual int ShutdownSend (void); virtual int ShutdownRecv (void); - virtual int Connect(const Address &address); - virtual int Listen(void); + virtual int Connect (const Address &address); + virtual int Listen (void); virtual uint32_t GetTxAvailable (void) const; virtual int Send (Ptr p, uint32_t flags); - virtual int SendTo(Ptr p, uint32_t flags, const Address &toAddress); + virtual int SendTo (Ptr p, uint32_t flags, const Address &toAddress); virtual uint32_t GetRxAvailable (void) const; virtual Ptr Recv (uint32_t maxSize, uint32_t flags); virtual Ptr RecvFrom (uint32_t maxSize, uint32_t flags, diff --git a/src/network/utils/packetbb.cc b/src/network/utils/packetbb.cc index 5c621ad36..329af15a7 100644 --- a/src/network/utils/packetbb.cc +++ b/src/network/utils/packetbb.cc @@ -231,7 +231,7 @@ PbbTlvBlock::Print (std::ostream &os, int level) const std::string prefix = ""; for (int i = 0; i < level; i++) { - prefix.append("\t"); + prefix.append ("\t"); } os << prefix << "TLV Block {" << std::endl; @@ -449,7 +449,7 @@ PbbAddressTlvBlock::Print (std::ostream &os, int level) const std::string prefix = ""; for (int i = 0; i < level; i++) { - prefix.append("\t"); + prefix.append ("\t"); } os << prefix << "TLV Block {" << std::endl; @@ -768,7 +768,7 @@ PbbPacket::GetSerializedSize (void) const /* Version number + flags */ uint32_t size = 1; - if (HasSequenceNumber()) + if (HasSequenceNumber ()) { size += 2; } @@ -812,7 +812,7 @@ PbbPacket::Serialize (Buffer::Iterator start) const m_tlvList.Serialize (start); } - bufref.WriteU8(flags); + bufref.WriteU8 (flags); for (ConstMessageIterator iter = MessageBegin (); iter != MessageEnd (); @@ -839,7 +839,7 @@ PbbPacket::Deserialize (Buffer::Iterator start) m_tlvList.Deserialize (start); } - while (!start.IsEnd()) + while (!start.IsEnd ()) { Ptr newmsg = PbbMessage::DeserializeMessage (start); if (newmsg == 0) @@ -1047,103 +1047,103 @@ PbbMessage::HasSequenceNumber (void) const PbbMessage::TlvIterator PbbMessage::TlvBegin (void) { - return m_tlvList.Begin(); + return m_tlvList.Begin (); } PbbMessage::ConstTlvIterator PbbMessage::TlvBegin (void) const { - return m_tlvList.Begin(); + return m_tlvList.Begin (); } PbbMessage::TlvIterator PbbMessage::TlvEnd (void) { - return m_tlvList.End(); + return m_tlvList.End (); } PbbMessage::ConstTlvIterator PbbMessage::TlvEnd (void) const { - return m_tlvList.End(); + return m_tlvList.End (); } int PbbMessage::TlvSize (void) const { - return m_tlvList.Size(); + return m_tlvList.Size (); } bool PbbMessage::TlvEmpty (void) const { - return m_tlvList.Empty(); + return m_tlvList.Empty (); } Ptr PbbMessage::TlvFront (void) { - return m_tlvList.Front(); + return m_tlvList.Front (); } const Ptr PbbMessage::TlvFront (void) const { - return m_tlvList.Front(); + return m_tlvList.Front (); } Ptr PbbMessage::TlvBack (void) { - return m_tlvList.Back(); + return m_tlvList.Back (); } const Ptr PbbMessage::TlvBack (void) const { - return m_tlvList.Back(); + return m_tlvList.Back (); } void PbbMessage::TlvPushFront (Ptr tlv) { - m_tlvList.PushFront(tlv); + m_tlvList.PushFront (tlv); } void PbbMessage::TlvPopFront (void) { - m_tlvList.PopFront(); + m_tlvList.PopFront (); } void PbbMessage::TlvPushBack (Ptr tlv) { - m_tlvList.PushBack(tlv); + m_tlvList.PushBack (tlv); } void PbbMessage::TlvPopBack (void) { - m_tlvList.PopBack(); + m_tlvList.PopBack (); } PbbMessage::TlvIterator PbbMessage::TlvErase (PbbMessage::TlvIterator position) { - return m_tlvList.Erase(position); + return m_tlvList.Erase (position); } PbbMessage::TlvIterator PbbMessage::TlvErase (PbbMessage::TlvIterator first, PbbMessage::TlvIterator last) { - return m_tlvList.Erase(first, last); + return m_tlvList.Erase (first, last); } void PbbMessage::TlvClear (void) { - m_tlvList.Clear(); + m_tlvList.Clear (); } /* Manipulating Address Block and Address TLV pairs */ @@ -1151,98 +1151,98 @@ PbbMessage::TlvClear (void) PbbMessage::AddressBlockIterator PbbMessage::AddressBlockBegin (void) { - return m_addressBlockList.begin(); + return m_addressBlockList.begin (); } PbbMessage::ConstAddressBlockIterator PbbMessage::AddressBlockBegin (void) const { - return m_addressBlockList.begin(); + return m_addressBlockList.begin (); } PbbMessage::AddressBlockIterator PbbMessage::AddressBlockEnd (void) { - return m_addressBlockList.end(); + return m_addressBlockList.end (); } PbbMessage::ConstAddressBlockIterator PbbMessage::AddressBlockEnd (void) const { - return m_addressBlockList.end(); + return m_addressBlockList.end (); } int PbbMessage::AddressBlockSize (void) const { - return m_addressBlockList.size(); + return m_addressBlockList.size (); } bool PbbMessage::AddressBlockEmpty (void) const { - return m_addressBlockList.empty(); + return m_addressBlockList.empty (); } Ptr PbbMessage::AddressBlockFront (void) { - return m_addressBlockList.front(); + return m_addressBlockList.front (); } const Ptr PbbMessage::AddressBlockFront (void) const { - return m_addressBlockList.front(); + return m_addressBlockList.front (); } Ptr PbbMessage::AddressBlockBack (void) { - return m_addressBlockList.back(); + return m_addressBlockList.back (); } const Ptr PbbMessage::AddressBlockBack (void) const { - return m_addressBlockList.back(); + return m_addressBlockList.back (); } void PbbMessage::AddressBlockPushFront (Ptr tlv) { - m_addressBlockList.push_front(tlv); + m_addressBlockList.push_front (tlv); } void PbbMessage::AddressBlockPopFront (void) { - m_addressBlockList.pop_front(); + m_addressBlockList.pop_front (); } void PbbMessage::AddressBlockPushBack (Ptr tlv) { - m_addressBlockList.push_back(tlv); + m_addressBlockList.push_back (tlv); } void PbbMessage::AddressBlockPopBack (void) { - m_addressBlockList.pop_back(); + m_addressBlockList.pop_back (); } PbbMessage::AddressBlockIterator PbbMessage::AddressBlockErase (PbbMessage::AddressBlockIterator position) { - return m_addressBlockList.erase(position); + return m_addressBlockList.erase (position); } PbbMessage::AddressBlockIterator PbbMessage::AddressBlockErase (PbbMessage::AddressBlockIterator first, PbbMessage::AddressBlockIterator last) { - return m_addressBlockList.erase(first, last); + return m_addressBlockList.erase (first, last); } void @@ -1254,7 +1254,7 @@ PbbMessage::AddressBlockClear (void) { *iter = 0; } - return m_addressBlockList.clear(); + return m_addressBlockList.clear (); } uint32_t @@ -1263,22 +1263,22 @@ PbbMessage::GetSerializedSize (void) const /* msg-type + (msg-flags + msg-addr-length) + 2msg-size */ uint32_t size = 4; - if (HasOriginatorAddress()) + if (HasOriginatorAddress ()) { - size += GetAddressLength() + 1; + size += GetAddressLength () + 1; } - if (HasHopLimit()) + if (HasHopLimit ()) { size++; } - if (HasHopCount()) + if (HasHopCount ()) { size++; } - if (HasSequenceNumber()) + if (HasSequenceNumber ()) { size += 2; } @@ -1300,7 +1300,7 @@ PbbMessage::Serialize (Buffer::Iterator &start) const { Buffer::Iterator front = start; - start.WriteU8 (GetType()); + start.WriteU8 (GetType ()); /* Save a reference to the spot where we will later write the flags */ Buffer::Iterator bufref = start; @@ -1337,7 +1337,7 @@ PbbMessage::Serialize (Buffer::Iterator &start) const start.WriteHtonU16 (GetSequenceNumber ()); } - bufref.WriteU8(flags); + bufref.WriteU8 (flags); m_tlvList.Serialize (start); @@ -1416,7 +1416,7 @@ PbbMessage::Deserialize (Buffer::Iterator &start) if (size > 0) { - while (start.GetDistanceFrom(front) < size) + while (start.GetDistanceFrom (front) < size) { Ptr newab = AddressBlockDeserialize (start); AddressBlockPushBack (newab); @@ -1591,7 +1591,7 @@ void PbbMessageIpv4::SerializeOriginatorAddress (Buffer::Iterator &start) const { uint8_t buffer[GetAddressLength () + 1]; - Ipv4Address::ConvertFrom (GetOriginatorAddress ()).Serialize(buffer); + Ipv4Address::ConvertFrom (GetOriginatorAddress ()).Serialize (buffer); start.Write (buffer, GetAddressLength () + 1); } @@ -1599,7 +1599,7 @@ Address PbbMessageIpv4::DeserializeOriginatorAddress (Buffer::Iterator &start) const { uint8_t buffer[GetAddressLength () + 1]; - start.Read(buffer, GetAddressLength () + 1); + start.Read (buffer, GetAddressLength () + 1); return Ipv4Address::Deserialize (buffer); } @@ -1637,7 +1637,7 @@ void PbbMessageIpv6::SerializeOriginatorAddress (Buffer::Iterator &start) const { uint8_t buffer[GetAddressLength () + 1]; - Ipv6Address::ConvertFrom (GetOriginatorAddress ()).Serialize(buffer); + Ipv6Address::ConvertFrom (GetOriginatorAddress ()).Serialize (buffer); start.Write (buffer, GetAddressLength () + 1); } @@ -1645,7 +1645,7 @@ Address PbbMessageIpv6::DeserializeOriginatorAddress (Buffer::Iterator &start) const { uint8_t buffer[GetAddressLength () + 1]; - start.Read(buffer, GetAddressLength () + 1); + start.Read (buffer, GetAddressLength () + 1); return Ipv6Address::Deserialize (buffer); } @@ -1678,92 +1678,92 @@ PbbAddressBlock::~PbbAddressBlock () PbbAddressBlock::AddressIterator PbbAddressBlock::AddressBegin (void) { - return m_addressList.begin(); + return m_addressList.begin (); } PbbAddressBlock::ConstAddressIterator PbbAddressBlock::AddressBegin (void) const { - return m_addressList.begin(); + return m_addressList.begin (); } PbbAddressBlock::AddressIterator PbbAddressBlock::AddressEnd (void) { - return m_addressList.end(); + return m_addressList.end (); } PbbAddressBlock::ConstAddressIterator PbbAddressBlock::AddressEnd (void) const { - return m_addressList.end(); + return m_addressList.end (); } int PbbAddressBlock::AddressSize (void) const { - return m_addressList.size(); + return m_addressList.size (); } bool PbbAddressBlock::AddressEmpty (void) const { - return m_addressList.empty(); + return m_addressList.empty (); } Address PbbAddressBlock::AddressFront (void) const { - return m_addressList.front(); + return m_addressList.front (); } Address PbbAddressBlock::AddressBack (void) const { - return m_addressList.back(); + return m_addressList.back (); } void PbbAddressBlock::AddressPushFront (Address tlv) { - m_addressList.push_front(tlv); + m_addressList.push_front (tlv); } void PbbAddressBlock::AddressPopFront (void) { - m_addressList.pop_front(); + m_addressList.pop_front (); } void PbbAddressBlock::AddressPushBack (Address tlv) { - m_addressList.push_back(tlv); + m_addressList.push_back (tlv); } void PbbAddressBlock::AddressPopBack (void) { - m_addressList.pop_back(); + m_addressList.pop_back (); } PbbAddressBlock::AddressIterator PbbAddressBlock::AddressErase (PbbAddressBlock::AddressIterator position) { - return m_addressList.erase(position); + return m_addressList.erase (position); } PbbAddressBlock::AddressIterator PbbAddressBlock::AddressErase (PbbAddressBlock::AddressIterator first, PbbAddressBlock::AddressIterator last) { - return m_addressList.erase(first, last); + return m_addressList.erase (first, last); } void PbbAddressBlock::AddressClear (void) { - return m_addressList.clear(); + return m_addressList.clear (); } /* Manipulating the prefix list */ @@ -1869,104 +1869,104 @@ PbbAddressBlock::PrefixClear (void) PbbAddressBlock::TlvIterator PbbAddressBlock::TlvBegin (void) { - return m_addressTlvList.Begin(); + return m_addressTlvList.Begin (); } PbbAddressBlock::ConstTlvIterator PbbAddressBlock::TlvBegin (void) const { - return m_addressTlvList.Begin(); + return m_addressTlvList.Begin (); } PbbAddressBlock::TlvIterator PbbAddressBlock::TlvEnd (void) { - return m_addressTlvList.End(); + return m_addressTlvList.End (); } PbbAddressBlock::ConstTlvIterator PbbAddressBlock::TlvEnd (void) const { - return m_addressTlvList.End(); + return m_addressTlvList.End (); } int PbbAddressBlock::TlvSize (void) const { - return m_addressTlvList.Size(); + return m_addressTlvList.Size (); } bool PbbAddressBlock::TlvEmpty (void) const { - return m_addressTlvList.Empty(); + return m_addressTlvList.Empty (); } Ptr PbbAddressBlock::TlvFront (void) { - return m_addressTlvList.Front(); + return m_addressTlvList.Front (); } const Ptr PbbAddressBlock::TlvFront (void) const { - return m_addressTlvList.Front(); + return m_addressTlvList.Front (); } Ptr PbbAddressBlock::TlvBack (void) { - return m_addressTlvList.Back(); + return m_addressTlvList.Back (); } const Ptr PbbAddressBlock::TlvBack (void) const { - return m_addressTlvList.Back(); + return m_addressTlvList.Back (); } void PbbAddressBlock::TlvPushFront (Ptr tlv) { - m_addressTlvList.PushFront(tlv); + m_addressTlvList.PushFront (tlv); } void PbbAddressBlock::TlvPopFront (void) { - m_addressTlvList.PopFront(); + m_addressTlvList.PopFront (); } void PbbAddressBlock::TlvPushBack (Ptr tlv) { - m_addressTlvList.PushBack(tlv); + m_addressTlvList.PushBack (tlv); } void PbbAddressBlock::TlvPopBack (void) { - m_addressTlvList.PopBack(); + m_addressTlvList.PopBack (); } PbbAddressBlock::TlvIterator PbbAddressBlock::TlvErase (PbbAddressBlock::TlvIterator position) { - return m_addressTlvList.Erase(position); + return m_addressTlvList.Erase (position); } PbbAddressBlock::TlvIterator PbbAddressBlock::TlvErase (PbbAddressBlock::TlvIterator first, PbbAddressBlock::TlvIterator last) { - return m_addressTlvList.Erase(first, last); + return m_addressTlvList.Erase (first, last); } void PbbAddressBlock::TlvClear (void) { - m_addressTlvList.Clear(); + m_addressTlvList.Clear (); } uint32_t PbbAddressBlock::GetSerializedSize (void) const @@ -1976,7 +1976,7 @@ PbbAddressBlock::GetSerializedSize (void) const if (AddressSize () == 1) { - size += GetAddressLength () + PrefixSize(); + size += GetAddressLength () + PrefixSize (); } else if (AddressSize () > 0) { @@ -2101,7 +2101,7 @@ PbbAddressBlock::Deserialize (Buffer::Iterator &start) uint8_t headlen = 0; uint8_t taillen = 0; uint8_t addrtmp[GetAddressLength ()]; - memset(addrtmp, 0, GetAddressLength ()); + memset (addrtmp, 0, GetAddressLength ()); if (flags & AHAS_HEAD) { @@ -2163,7 +2163,7 @@ PbbAddressBlock::Print (std::ostream &os, int level) const iter++) { os << prefix << "\t\t"; - PrintAddress(os, iter); + PrintAddress (os, iter); os << std::endl; } @@ -2303,8 +2303,8 @@ PbbAddressBlock::GetHeadTail (uint8_t *head, uint8_t &headlen, bufcur = tmp; } - memcpy(head, bufcur, headlen); - memcpy(tail, bufcur + (GetAddressLength () - taillen), taillen); + memcpy (head, bufcur, headlen); + memcpy (tail, bufcur + (GetAddressLength () - taillen), taillen); delete[] buflast; delete[] bufcur; @@ -2564,9 +2564,9 @@ PbbTlv::Serialize (Buffer::Iterator &start) const Buffer::Iterator bufref = start; uint8_t flags = 0; - start.Next(); + start.Next (); - if (HasTypeExt()) + if (HasTypeExt ()) { flags |= THAS_TYPE_EXT; start.WriteU8 (GetTypeExt ()); @@ -2607,7 +2607,7 @@ PbbTlv::Serialize (Buffer::Iterator &start) const flags |= TIS_MULTIVALUE; } - start.Write(GetValue ().Begin (), GetValue ().End ()); + start.Write (GetValue ().Begin (), GetValue ().End ()); } bufref.WriteU8 (flags); diff --git a/src/network/utils/pcap-file.cc b/src/network/utils/pcap-file.cc index 5d6f8a742..fb3999e95 100644 --- a/src/network/utils/pcap-file.cc +++ b/src/network/utils/pcap-file.cc @@ -152,7 +152,7 @@ PcapFile::Swap (PcapFileHeader *from, PcapFileHeader *to) to->m_magicNumber = Swap (from->m_magicNumber); to->m_versionMajor = Swap (from->m_versionMajor); to->m_versionMinor = Swap (from->m_versionMinor); - to->m_zone = Swap (uint32_t(from->m_zone)); + to->m_zone = Swap (uint32_t (from->m_zone)); to->m_sigFigs = Swap (from->m_sigFigs); to->m_snapLen = Swap (from->m_snapLen); to->m_type = Swap (from->m_type); @@ -512,7 +512,7 @@ PcapFile::Diff (std::string const & f1, std::string const & f2, break; } - if (std::memcmp(data1, data2, readLen1) != 0) + if (std::memcmp (data1, data2, readLen1) != 0) { diff = true; // Packet data do not match break; diff --git a/src/network/utils/queue.cc b/src/network/utils/queue.cc index e32b61931..6788d36ca 100644 --- a/src/network/utils/queue.cc +++ b/src/network/utils/queue.cc @@ -42,12 +42,12 @@ Queue::GetTypeId (void) } Queue::Queue() : - m_nBytes(0), - m_nTotalReceivedBytes(0), - m_nPackets(0), - m_nTotalReceivedPackets(0), - m_nTotalDroppedBytes(0), - m_nTotalDroppedPackets(0) + m_nBytes (0), + m_nTotalReceivedBytes (0), + m_nPackets (0), + m_nTotalReceivedPackets (0), + m_nTotalDroppedBytes (0), + m_nTotalDroppedPackets (0) { NS_LOG_FUNCTION_NOARGS (); } @@ -97,7 +97,7 @@ Queue::Dequeue (void) m_nBytes -= packet->GetSize (); m_nPackets--; - NS_LOG_LOGIC("m_traceDequeue (packet)"); + NS_LOG_LOGIC ("m_traceDequeue (packet)"); m_traceDequeue (packet); } return packet; @@ -149,7 +149,7 @@ uint32_t Queue::GetTotalReceivedBytes (void) const { NS_LOG_FUNCTION_NOARGS (); - NS_LOG_LOGIC("returns " << m_nTotalReceivedBytes); + NS_LOG_LOGIC ("returns " << m_nTotalReceivedBytes); return m_nTotalReceivedBytes; } @@ -173,7 +173,7 @@ uint32_t Queue::GetTotalDroppedPackets (void) const { NS_LOG_FUNCTION_NOARGS (); - NS_LOG_LOGIC("returns " << m_nTotalDroppedPackets); + NS_LOG_LOGIC ("returns " << m_nTotalDroppedPackets); return m_nTotalDroppedPackets; } diff --git a/src/network/utils/radiotap-header.cc b/src/network/utils/radiotap-header.cc index d9336056b..3b7604bb6 100644 --- a/src/network/utils/radiotap-header.cc +++ b/src/network/utils/radiotap-header.cc @@ -30,15 +30,15 @@ namespace ns3 { NS_OBJECT_ENSURE_REGISTERED (RadiotapHeader); RadiotapHeader::RadiotapHeader() - : m_length(8), - m_present(0), - m_tsft(0), - m_flags(FRAME_FLAG_NONE), - m_rate(0), - m_channelFreq(0), - m_channelFlags(CHANNEL_FLAG_NONE), - m_antennaSignal(0), - m_antennaNoise(0) + : m_length (8), + m_present (0), + m_tsft (0), + m_flags (FRAME_FLAG_NONE), + m_rate (0), + m_channelFreq (0), + m_channelFlags (CHANNEL_FLAG_NONE), + m_antennaSignal (0), + m_antennaNoise (0) { NS_LOG_FUNCTION (this); } @@ -148,7 +148,7 @@ RadiotapHeader::Deserialize (Buffer::Iterator start) // if (m_present & RADIOTAP_TSFT) // bit 0 { - m_tsft = start.ReadU64(); + m_tsft = start.ReadU64 (); bytesRead += 8; } @@ -157,7 +157,7 @@ RadiotapHeader::Deserialize (Buffer::Iterator start) // if (m_present & RADIOTAP_FLAGS) // bit 1 { - m_flags = start.ReadU8(); + m_flags = start.ReadU8 (); ++bytesRead; } @@ -166,7 +166,7 @@ RadiotapHeader::Deserialize (Buffer::Iterator start) // if (m_present & RADIOTAP_RATE) // bit 2 { - m_rate = start.ReadU8(); + m_rate = start.ReadU8 (); ++bytesRead; } @@ -175,8 +175,8 @@ RadiotapHeader::Deserialize (Buffer::Iterator start) // if (m_present & RADIOTAP_CHANNEL) // bit 3 { - m_channelFreq = start.ReadU16(); - m_channelFlags = start.ReadU16(); + m_channelFreq = start.ReadU16 (); + m_channelFlags = start.ReadU16 (); bytesRead += 4; } @@ -186,7 +186,7 @@ RadiotapHeader::Deserialize (Buffer::Iterator start) // if (m_present & RADIOTAP_FHSS) // bit 4 { - start.ReadU8(); + start.ReadU8 (); ++bytesRead; } @@ -196,7 +196,7 @@ RadiotapHeader::Deserialize (Buffer::Iterator start) // if (m_present & RADIOTAP_DBM_ANTSIGNAL) // bit 5 { - m_antennaSignal = start.ReadU8(); + m_antennaSignal = start.ReadU8 (); ++bytesRead; } @@ -206,11 +206,11 @@ RadiotapHeader::Deserialize (Buffer::Iterator start) // if (m_present & RADIOTAP_DBM_ANTNOISE) // bit 6 { - m_antennaNoise = start.ReadU8(); + m_antennaNoise = start.ReadU8 (); ++bytesRead; } - NS_ASSERT_MSG(m_length == bytesRead, "RadiotapHeader::Deserialize(): expected and actual lengths inconsistent"); + NS_ASSERT_MSG (m_length == bytesRead, "RadiotapHeader::Deserialize(): expected and actual lengths inconsistent"); return bytesRead; } @@ -343,7 +343,7 @@ RadiotapHeader::SetAntennaSignalPower (double signal) } else { - m_antennaSignal = static_cast (floor(signal + 0.5)); + m_antennaSignal = static_cast (floor (signal + 0.5)); } NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec); diff --git a/src/network/utils/radiotap-header.h b/src/network/utils/radiotap-header.h index 13be11d64..45358145f 100644 --- a/src/network/utils/radiotap-header.h +++ b/src/network/utils/radiotap-header.h @@ -242,7 +242,7 @@ private: RADIOTAP_EXT = 0x10000000 }; - void CheckAddChannelField(); + void CheckAddChannelField (); uint16_t m_length; uint32_t m_present; diff --git a/src/network/utils/simple-net-device.cc b/src/network/utils/simple-net-device.cc index eaf7b53af..ce083b289 100644 --- a/src/network/utils/simple-net-device.cc +++ b/src/network/utils/simple-net-device.cc @@ -108,12 +108,12 @@ SimpleNetDevice::SetReceiveErrorModel (Ptr em) } void -SimpleNetDevice::SetIfIndex(const uint32_t index) +SimpleNetDevice::SetIfIndex (const uint32_t index) { m_ifIndex = index; } uint32_t -SimpleNetDevice::GetIfIndex(void) const +SimpleNetDevice::GetIfIndex (void) const { return m_ifIndex; } @@ -125,7 +125,7 @@ SimpleNetDevice::GetChannel (void) const void SimpleNetDevice::SetAddress (Address address) { - m_address = Mac48Address::ConvertFrom(address); + m_address = Mac48Address::ConvertFrom (address); } Address SimpleNetDevice::GetAddress (void) const @@ -193,7 +193,7 @@ SimpleNetDevice::IsBridge (void) const } bool -SimpleNetDevice::Send(Ptr packet, const Address& dest, uint16_t protocolNumber) +SimpleNetDevice::Send (Ptr packet, const Address& dest, uint16_t protocolNumber) { NS_LOG_FUNCTION (packet << dest << protocolNumber); Mac48Address to = Mac48Address::ConvertFrom (dest); @@ -201,7 +201,7 @@ SimpleNetDevice::Send(Ptr packet, const Address& dest, uint16_t protocol return true; } bool -SimpleNetDevice::SendFrom(Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) +SimpleNetDevice::SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber) { Mac48Address to = Mac48Address::ConvertFrom (dest); Mac48Address from = Mac48Address::ConvertFrom (source); diff --git a/src/network/utils/simple-net-device.h b/src/network/utils/simple-net-device.h index 68375cf35..60d193ba1 100644 --- a/src/network/utils/simple-net-device.h +++ b/src/network/utils/simple-net-device.h @@ -60,11 +60,11 @@ public: * \see ErrorModel * \param em Ptr to the ErrorModel. */ - void SetReceiveErrorModel(Ptr em); + void SetReceiveErrorModel (Ptr em); // inherited from NetDevice base class. - virtual void SetIfIndex(const uint32_t index); - virtual uint32_t GetIfIndex(void) const; + virtual void SetIfIndex (const uint32_t index); + virtual uint32_t GetIfIndex (void) const; virtual Ptr GetChannel (void) const; virtual void SetAddress (Address address); virtual Address GetAddress (void) const; @@ -78,8 +78,8 @@ public: virtual Address GetMulticast (Ipv4Address multicastGroup) const; virtual bool IsPointToPoint (void) const; virtual bool IsBridge (void) const; - virtual bool Send(Ptr packet, const Address& dest, uint16_t protocolNumber); - virtual bool SendFrom(Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber); + virtual bool Send (Ptr packet, const Address& dest, uint16_t protocolNumber); + virtual bool SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber); virtual Ptr GetNode (void) const; virtual void SetNode (Ptr node); virtual bool NeedsArp (void) const; diff --git a/src/nix-vector-routing/examples/nix-simple.cc b/src/nix-vector-routing/examples/nix-simple.cc index 7aabc4f89..e56f0013e 100644 --- a/src/nix-vector-routing/examples/nix-simple.cc +++ b/src/nix-vector-routing/examples/nix-simple.cc @@ -45,8 +45,8 @@ NS_LOG_COMPONENT_DEFINE ("NixSimpleExample"); int main (int argc, char *argv[]) { - LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); - LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); + LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); NodeContainer nodes12; nodes12.Create (2); @@ -56,7 +56,7 @@ main (int argc, char *argv[]) nodes23.Create (1); NodeContainer nodes34; - nodes34.Add(nodes23.Get (1)); + nodes34.Add (nodes23.Get (1)); nodes34.Create (1); PointToPointHelper pointToPoint; diff --git a/src/nix-vector-routing/examples/nms-p2p-nix.cc b/src/nix-vector-routing/examples/nms-p2p-nix.cc index c7834d71d..0426705cc 100644 --- a/src/nix-vector-routing/examples/nms-p2p-nix.cc +++ b/src/nix-vector-routing/examples/nms-p2p-nix.cc @@ -52,9 +52,9 @@ using namespace std; using namespace ns3; typedef struct timeval TIMER_TYPE; -#define TIMER_NOW(_t) gettimeofday(&_t,NULL); +#define TIMER_NOW(_t) gettimeofday (&_t,NULL); #define TIMER_SECONDS(_t) ((double)(_t).tv_sec + (_t).tv_usec*1e-6) -#define TIMER_DIFF(_t1, _t2) (TIMER_SECONDS(_t1)-TIMER_SECONDS(_t2)) +#define TIMER_DIFF(_t1, _t2) (TIMER_SECONDS (_t1)-TIMER_SECONDS (_t2)) NS_LOG_COMPONENT_DEFINE ("CampusNetworkModel"); @@ -67,7 +67,7 @@ int main (int argc, char *argv[]) { TIMER_TYPE t0, t1, t2; - TIMER_NOW(t0); + TIMER_NOW (t0); cout << " ==== DARPA NMS CAMPUS NETWORK SIMULATION ====" << endl; LogComponentEnable ("OnOffApplication", LOG_LEVEL_INFO); @@ -165,7 +165,7 @@ main (int argc, char *argv[]) net0_1.Add (nodes_net1[z][0].Get (0)); NetDeviceContainer ndc0_1; ndc0_1 = p2p_1gb5ms.Install (net0_1); - oss.str(""); + oss.str (""); oss << 10 + z << ".1.252.0"; address.SetBase (oss.str ().c_str (), "255.255.255.0"); ifs = address.Assign (ndc0_1); @@ -215,7 +215,7 @@ main (int argc, char *argv[]) for (int i = 0; i < 9; ++i) { nodes_net3[z][i].Create (1); - stack.Install(nodes_net3[z][i]); + stack.Install (nodes_net3[z][i]); } nodes_net3[z][0].Add (nodes_net3[z][1].Get (0)); nodes_net3[z][1].Add (nodes_net3[z][2].Get (0)); @@ -394,8 +394,8 @@ main (int argc, char *argv[]) r1 = 2 + (int)(4 * urng.GetValue ()); r2 = 10 * urng.GetValue (); OnOffHelper client ("ns3::TcpSocketFactory", Address ()); - AddressValue remoteAddress(InetSocketAddress ( - ifs2LAN[z][i][j].GetAddress (0), 9999)); + AddressValue remoteAddress (InetSocketAddress ( + ifs2LAN[z][i][j].GetAddress (0), 9999)); client.SetAttribute ("Remote", remoteAddress); ApplicationContainer clientApp; clientApp.Add (client.Install (nodes_net1[x][r1].Get (0))); diff --git a/src/nix-vector-routing/helper/ipv4-nix-vector-helper.cc b/src/nix-vector-routing/helper/ipv4-nix-vector-helper.cc index 5d02e0e17..46eb4369b 100644 --- a/src/nix-vector-routing/helper/ipv4-nix-vector-helper.cc +++ b/src/nix-vector-routing/helper/ipv4-nix-vector-helper.cc @@ -43,7 +43,7 @@ Ptr Ipv4NixVectorHelper::Create (Ptr node) const { Ptr agent = m_agentFactory.Create (); - agent->SetNode(node); + agent->SetNode (node); node->AggregateObject (agent); return agent; } diff --git a/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc b/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc index b8b937561..807203248 100644 --- a/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc +++ b/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc @@ -140,7 +140,7 @@ Ipv4NixVectorRouting::GetNixVector (Ptr source, Ipv4Address dest, Ptr nixVector) Ipv4Address loopback ("127.0.0.1"); for (uint32_t i = 0; i < numberOfDevices; i++) { - uint32_t interfaceIndex = (m_ipv4)->GetInterfaceForDevice(m_node->GetDevice(i)); + uint32_t interfaceIndex = (m_ipv4)->GetInterfaceForDevice (m_node->GetDevice (i)); Ipv4InterfaceAddress ifAddr = m_ipv4->GetAddress (interfaceIndex, 0); - if (ifAddr.GetLocal() == loopback) + if (ifAddr.GetLocal () == loopback) { NS_LOG_LOGIC ("Adding loopback to nix."); NS_LOG_LOGIC ("Adding Nix: " << i << " with " << nixVector->BitCount (numberOfDevices) - << " bits, for node " << m_node->GetId()); + << " bits, for node " << m_node->GetId ()); nixVector->AddNeighborIndex (i, nixVector->BitCount (numberOfDevices)); return true; } @@ -286,7 +286,7 @@ Ipv4NixVectorRouting::BuildNixVector (const std::vector< Ptr > & parentVec totalNeighbors += netDeviceContainer.GetN (); } NS_LOG_LOGIC ("Adding Nix: " << destId << " with " - << nixVector->BitCount (totalNeighbors) << " bits, for node " << parentNode->GetId()); + << nixVector->BitCount (totalNeighbors) << " bits, for node " << parentNode->GetId ()); nixVector->AddNeighborIndex (destId, nixVector->BitCount (totalNeighbors)); // recurse through parent vector, grabbing the path @@ -400,7 +400,7 @@ Ipv4NixVectorRouting::NetDeviceIsBridged (Ptr nd) const NS_LOG_FUNCTION (nd); Ptr node = nd->GetNode (); - uint32_t nDevices = node->GetNDevices(); + uint32_t nDevices = node->GetNDevices (); // // There is no bit on a net device that says it is being bridged, so we have @@ -410,7 +410,7 @@ Ipv4NixVectorRouting::NetDeviceIsBridged (Ptr nd) const // for (uint32_t i = 0; i < nDevices; ++i) { - Ptr ndTest = node->GetDevice(i); + Ptr ndTest = node->GetDevice (i); NS_LOG_LOGIC ("Examine device " << i << " " << ndTest); if (ndTest->IsBridge ()) @@ -469,7 +469,7 @@ Ipv4NixVectorRouting::FindNetDeviceForNixIndex (uint32_t nodeIndex, Ipv4Address Ptr gatewayNode = gatewayDevice->GetNode (); Ptr ipv4 = gatewayNode->GetObject (); - uint32_t interfaceIndex = (ipv4)->GetInterfaceForDevice(gatewayDevice); + uint32_t interfaceIndex = (ipv4)->GetInterfaceForDevice (gatewayDevice); Ipv4InterfaceAddress ifAddr = ipv4->GetAddress (interfaceIndex, 0); gatewayIp = ifAddr.GetLocal (); break; @@ -490,7 +490,7 @@ Ipv4NixVectorRouting::RouteOutput (Ptr p, const Ipv4Header &header, Ptr< NS_LOG_DEBUG ("Dest IP from header: " << header.GetDestination ()); // check if cache - nixVectorInCache = GetNixVectorInCache(header.GetDestination ()); + nixVectorInCache = GetNixVectorInCache (header.GetDestination ()); // not in cache if (!nixVectorInCache) @@ -539,7 +539,7 @@ Ipv4NixVectorRouting::RouteOutput (Ptr p, const Ipv4Header &header, Ptr< // rtentry from the map if (rtentry) { - m_ipv4RouteCache.erase(header.GetDestination ()); + m_ipv4RouteCache.erase (header.GetDestination ()); } NS_LOG_LOGIC ("Ipv4Route not in cache, build: "); @@ -549,11 +549,11 @@ Ipv4NixVectorRouting::RouteOutput (Ptr p, const Ipv4Header &header, Ptr< if (!oif) { - interfaceIndex = (m_ipv4)->GetInterfaceForDevice(m_node->GetDevice(index)); + interfaceIndex = (m_ipv4)->GetInterfaceForDevice (m_node->GetDevice (index)); } else { - interfaceIndex = (m_ipv4)->GetInterfaceForDevice(oif); + interfaceIndex = (m_ipv4)->GetInterfaceForDevice (oif); } NS_ASSERT_MSG (interfaceIndex != -1, "Interface index not found for device"); @@ -579,10 +579,10 @@ Ipv4NixVectorRouting::RouteOutput (Ptr p, const Ipv4Header &header, Ptr< sockerr = Socket::ERROR_NOTERROR; // add rtentry to cache - m_ipv4RouteCache.insert(Ipv4RouteMap_t::value_type(header.GetDestination (), rtentry)); + m_ipv4RouteCache.insert (Ipv4RouteMap_t::value_type (header.GetDestination (), rtentry)); } - NS_LOG_LOGIC ("Nix-vector contents: " << *nixVectorInCache << " : Remaining bits: " << nixVectorForPacket->GetRemainingBits()); + NS_LOG_LOGIC ("Nix-vector contents: " << *nixVectorInCache << " : Remaining bits: " << nixVectorForPacket->GetRemainingBits ()); // Add nix-vector in the packet class // make sure the packet exists first @@ -611,7 +611,7 @@ Ipv4NixVectorRouting::RouteInput (Ptr p, const Ipv4Header &header, Ptr rtentry; // Get the nix-vector from the packet - Ptr nixVector = p->GetNixVector(); + Ptr nixVector = p->GetNixVector (); // If nixVector isn't in packet, something went wrong NS_ASSERT (nixVector); @@ -632,7 +632,7 @@ Ipv4NixVectorRouting::RouteInput (Ptr p, const Ipv4Header &header, NS_LOG_LOGIC ("Ipv4Route not in cache, build: "); Ipv4Address gatewayIp; uint32_t index = FindNetDeviceForNixIndex (nodeIndex, gatewayIp); - uint32_t interfaceIndex = (m_ipv4)->GetInterfaceForDevice(m_node->GetDevice(index)); + uint32_t interfaceIndex = (m_ipv4)->GetInterfaceForDevice (m_node->GetDevice (index)); Ipv4InterfaceAddress ifAddr = m_ipv4->GetAddress (interfaceIndex, 0); // start filling in the Ipv4Route info @@ -644,10 +644,10 @@ Ipv4NixVectorRouting::RouteInput (Ptr p, const Ipv4Header &header, rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIndex)); // add rtentry to cache - m_ipv4RouteCache.insert(Ipv4RouteMap_t::value_type(header.GetDestination (), rtentry)); + m_ipv4RouteCache.insert (Ipv4RouteMap_t::value_type (header.GetDestination (), rtentry)); } - NS_LOG_LOGIC ("At Node " << m_node->GetId() << ", Extracting " << numberOfBits << + NS_LOG_LOGIC ("At Node " << m_node->GetId () << ", Extracting " << numberOfBits << " bits from Nix-vector: " << nixVector << " : " << *nixVector); // call the unicast callback @@ -660,10 +660,10 @@ Ipv4NixVectorRouting::RouteInput (Ptr p, const Ipv4Header &header, } void -Ipv4NixVectorRouting::PrintRoutingTable(Ptr stream) const +Ipv4NixVectorRouting::PrintRoutingTable (Ptr stream) const { - std::ostream* os = stream->GetStream(); + std::ostream* os = stream->GetStream (); *os << "NixCache:" << std::endl; if (m_nixCache.size () > 0) { @@ -672,23 +672,23 @@ Ipv4NixVectorRouting::PrintRoutingTable(Ptr stream) const { std::ostringstream dest; dest << it->first; - *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str(); + *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str (); *os << *(it->second) << std::endl; } } *os << "Ipv4RouteCache:" << std::endl; if (m_ipv4RouteCache.size () > 0) { - *os << "Destination Gateway Source OutputDevice" << std::endl; + *os << "Destination Gateway Source OutputDevice" << std::endl; for (Ipv4RouteMap_t::const_iterator it = m_ipv4RouteCache.begin (); it != m_ipv4RouteCache.end (); it++) { std::ostringstream dest, gw, src; dest << it->second->GetDestination (); - *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str(); + *os << std::setiosflags (std::ios::left) << std::setw (16) << dest.str (); gw << it->second->GetGateway (); - *os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str(); + *os << std::setiosflags (std::ios::left) << std::setw (16) << gw.str (); src << it->second->GetSource (); - *os << std::setiosflags (std::ios::left) << std::setw (16) << src.str(); + *os << std::setiosflags (std::ios::left) << std::setw (16) << src.str (); *os << " "; if (Names::FindName (it->second->GetOutputDevice ()) != "") { @@ -732,7 +732,7 @@ Ipv4NixVectorRouting::BFS (uint32_t numberOfNodes, Ptr source, { NS_LOG_FUNCTION_NOARGS (); - NS_LOG_LOGIC ("Going from Node " << source->GetId() << " to Node " << dest->GetId()); + NS_LOG_LOGIC ("Going from Node " << source->GetId () << " to Node " << dest->GetId ()); std::queue< Ptr > greyNodeList; // discovered nodes with unexplored children // reset the parent vector @@ -742,7 +742,7 @@ Ipv4NixVectorRouting::BFS (uint32_t numberOfNodes, Ptr source, // Add the source node to the queue, set its parent to itself greyNodeList.push (source); - parentVector.at (source->GetId()) = source; + parentVector.at (source->GetId ()) = source; // BFS loop while (greyNodeList.size () != 0) @@ -752,7 +752,7 @@ Ipv4NixVectorRouting::BFS (uint32_t numberOfNodes, Ptr source, if (currNode == dest) { - NS_LOG_LOGIC ("Made it to Node " << currNode->GetId()); + NS_LOG_LOGIC ("Made it to Node " << currNode->GetId ()); return true; } @@ -764,7 +764,7 @@ Ipv4NixVectorRouting::BFS (uint32_t numberOfNodes, Ptr source, // make sure that we can go this way if (ipv4) { - uint32_t interfaceIndex = (ipv4)->GetInterfaceForDevice(oif); + uint32_t interfaceIndex = (ipv4)->GetInterfaceForDevice (oif); if (!(ipv4->IsUp (interfaceIndex))) { NS_LOG_LOGIC ("Ipv4Interface is down"); @@ -820,7 +820,7 @@ Ipv4NixVectorRouting::BFS (uint32_t numberOfNodes, Ptr source, // make sure that we can go this way if (ipv4) { - uint32_t interfaceIndex = (ipv4)->GetInterfaceForDevice(currNode->GetDevice(i)); + uint32_t interfaceIndex = (ipv4)->GetInterfaceForDevice (currNode->GetDevice (i)); if (!(ipv4->IsUp (interfaceIndex))) { NS_LOG_LOGIC ("Ipv4Interface is down"); diff --git a/src/olsr/doc/olsr.h b/src/olsr/doc/olsr.h deleted file mode 100644 index caf2ce73f..000000000 --- a/src/olsr/doc/olsr.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2007 INESC Porto - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Gustavo J. A. M. Carneiro - */ - -#ifndef OLSR_H -#define OLSR_H - -/** - * \defgroup olsr OLSR Routing - * - * \section model Model - * - * This model implements the base specification of the Optimized - * Link State Routing (OLSR) protocol, which is a dynamic mobile ad hoc - * unicast routing protocol. It has been developed at the - * University of Murcia (Spain) by Francisco J. Ros for NS-2, and was - * ported to NS-3 by Gustavo Carneiro at INESC Porto (Portugal). - * - * Here is a summary of software's main features: - * - Mostly compliant with OLSR as documented in RFC 3626 (http://www.ietf.org/rfc/rfc3626.txt), with the following differences: - * - The use of multiple interfaces was not supported by the NS-2 version, but is supported in NS-3; - * - * \section api API and Usage - * - * A helper class for OLSR has been written. After an IPv4 topology - * has been created and unique IP addresses assigned to each node, the - * simulation script writer can call one of three overloaded functions - * with different scope to enable OLSR: ns3::OlsrHelper::Install - * (NodeContainer container); ns3::OlsrHelper::Install (Ptr - * node); or ns3::OlsrHelper::InstallAll (void); - * - * In addition, the behavior of OLSR can be modified by changing certain - * attributes. The method ns3::OlsrHelper::Set () can be used - * to set OLSR attributes. These include HelloInterval, TcInterval, - * MidInterval, Willingness. Other parameters are defined as macros - * in olsr-routing-protocol.cc. - * - * Host Network Association (HNA) is supported in this implementation - * of OLSR. Refer to examples/routing/olsr-hna.cc to see how the API - * is used. - * - * \section list Open Issues - * - * - OLSR does not respond to the routing event notifications corresponding - * to dynamic interface up and down (RoutingProtocol::NotifyInterfaceUp and - * RoutingProtocol::NotifyInterfaceDown) or address insertion/removal - * (RoutingProtocol::NotifyAddAddress and - * RoutingProtocol::NotifyRemoveAddress). - * - Unlike the NS-2 version, does not yet support MAC layer feedback as described in RFC 3626; - * - */ - - -#endif /* OLSR_H */ diff --git a/src/olsr/doc/olsr.rst b/src/olsr/doc/olsr.rst new file mode 100644 index 000000000..feaff8a4d --- /dev/null +++ b/src/olsr/doc/olsr.rst @@ -0,0 +1,81 @@ +.. include:: replace.txt + +Optimized Link State Routing (OLSR) +----------------------------------- + +This model implements the base specification of the Optimized +Link State Routing (OLSR) protocol, which is a dynamic mobile ad hoc +unicast routing protocol. It has been developed at the +University of Murcia (Spain) by Francisco J. Ros for NS-2, and was +ported to NS-3 by Gustavo Carneiro at INESC Porto (Portugal). + +Model Description +***************** + +The source code for the OLSR model lives in the directory `src/olsr`. + +Design +++++++ + +Scope and Limitations ++++++++++++++++++++++ + +The model is for IPv4 only. + +* Mostly compliant with OLSR as documented in [rfc3626]_, +* The use of multiple interfaces was not supported by the NS-2 version, but is supported in NS-3; +* OLSR does not respond to the routing event notifications corresponding to dynamic interface up and down (``ns3::RoutingProtocol::NotifyInterfaceUp`` and ``ns3::RoutingProtocol::NotifyInterfaceDown``) or address insertion/removal ``ns3::RoutingProtocol::NotifyAddAddress`` and ``ns3::RoutingProtocol::NotifyRemoveAddress``). +* Unlike the NS-2 version, does not yet support MAC layer feedback as described in RFC 3626; + +Host Network Association (HNA) is supported in this implementation +of OLSR. Refer to ``examples/olsr-hna.cc`` to see how the API +is used. + +References +++++++++++ + +.. [rfc3626] RFC 3626 *Optimized Link State Routing* + +Usage +***** + +Examples +++++++++ + +Helpers ++++++++ + +A helper class for OLSR has been written. After an IPv4 topology +has been created and unique IP addresses assigned to each node, the +simulation script writer can call one of three overloaded functions +with different scope to enable OLSR: ``ns3::OlsrHelper::Install +(NodeContainer container)``; ``ns3::OlsrHelper::Install (Ptr +node)``; or ``ns3::OlsrHelper::InstallAll (void)`` + +Attributes +++++++++++ + +In addition, the behavior of OLSR can be modified by changing certain +attributes. The method ``ns3::OlsrHelper::Set ()`` can be used +to set OLSR attributes. These include HelloInterval, TcInterval, +MidInterval, Willingness. Other parameters are defined as macros +in ``olsr-routing-protocol.cc``. + +Tracing ++++++++ + +Logging ++++++++ + +Caveats ++++++++ + +Validation +********** + +Unit tests +++++++++++ + +Larger-scale performance tests +++++++++++++++++++++++++++++++ + diff --git a/src/olsr/examples/olsr-hna.cc b/src/olsr/examples/olsr-hna.cc index 709dcca98..d1e2a543f 100644 --- a/src/olsr/examples/olsr-hna.cc +++ b/src/olsr/examples/olsr-hna.cc @@ -145,18 +145,18 @@ int main (int argc, char *argv[]) // ns-3 supports RadioTap and Prism tracing extensions for 802.11b wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - YansWifiChannelHelper wifiChannel ; + YansWifiChannelHelper wifiChannel; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); // The below FixedRssLossModel will cause the rss to be fixed regardless // of the distance between the two stations, and the transmit power - wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss)); + wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue (rss)); wifiPhy.SetChannel (wifiChannel.Create ()); // Add a non-QoS upper mac, and disable rate control NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode",StringValue(phyMode), - "ControlMode",StringValue(phyMode)); + "DataMode",StringValue (phyMode), + "ControlMode",StringValue (phyMode)); // Set it to adhoc mode wifiMac.SetType ("ns3::AdhocWifiMac"); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, olsrNodes); @@ -164,7 +164,7 @@ int main (int argc, char *argv[]) CsmaHelper csma; csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); - NetDeviceContainer csmaDevices = csma.Install (NodeContainer (csmaNodes.Get(0), olsrNodes.Get(1))); + NetDeviceContainer csmaDevices = csma.Install (NodeContainer (csmaNodes.Get (0), olsrNodes.Get (1))); // Note that with FixedRssLossModel, the positions below are not // used for received signal strength. @@ -203,7 +203,7 @@ int main (int argc, char *argv[]) ipv4.Assign (csmaDevices); TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); - Ptr recvSink = Socket::CreateSocket (csmaNodes.Get(0), tid); + Ptr recvSink = Socket::CreateSocket (csmaNodes.Get (0), tid); InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80); recvSink->Bind (local); recvSink->SetRecvCallback (MakeCallback (&ReceivePacket)); @@ -239,7 +239,7 @@ int main (int argc, char *argv[]) // Add the required routes into the Ipv4StaticRouting Protocol instance // and have the node generate HNA messages for all these routes // which are associated with non-OLSR interfaces specified above. - hnaEntries->AddNetworkRouteTo (Ipv4Address ("172.16.1.0"), Ipv4Mask ("255.255.255.0"), uint32_t(2), uint32_t(1)); + hnaEntries->AddNetworkRouteTo (Ipv4Address ("172.16.1.0"), Ipv4Mask ("255.255.255.0"), uint32_t (2), uint32_t (1)); olsrrp_Gw->SetRoutingTableAssociation (hnaEntries); } diff --git a/src/olsr/examples/simple-point-to-point-olsr.cc b/src/olsr/examples/simple-point-to-point-olsr.cc index 272b36bd3..b512ba14f 100644 --- a/src/olsr/examples/simple-point-to-point-olsr.cc +++ b/src/olsr/examples/simple-point-to-point-olsr.cc @@ -79,9 +79,9 @@ main (int argc, char *argv[]) NS_LOG_INFO ("Create nodes."); NodeContainer c; c.Create (5); - NodeContainer n02 = NodeContainer (c.Get(0), c.Get (2)); - NodeContainer n12 = NodeContainer (c.Get(1), c.Get (2)); - NodeContainer n32 = NodeContainer (c.Get(3), c.Get (2)); + NodeContainer n02 = NodeContainer (c.Get (0), c.Get (2)); + NodeContainer n12 = NodeContainer (c.Get (1), c.Get (2)); + NodeContainer n32 = NodeContainer (c.Get (3), c.Get (2)); NodeContainer n34 = NodeContainer (c.Get (3), c.Get (4)); // Enable OLSR diff --git a/src/olsr/model/olsr-header.cc b/src/olsr/model/olsr-header.cc index 42a18a3dd..ca159ad58 100644 --- a/src/olsr/model/olsr-header.cc +++ b/src/olsr/model/olsr-header.cc @@ -31,7 +31,7 @@ namespace ns3 { namespace olsr { -NS_LOG_COMPONENT_DEFINE("OlsrHeader"); +NS_LOG_COMPONENT_DEFINE ("OlsrHeader"); /// Scaling factor used in RFC 3626. #define OLSR_C 0.0625 @@ -310,7 +310,7 @@ MessageHeader::Mid::Deserialize (Buffer::Iterator start, uint32_t messageSize) NS_ASSERT (messageSize % IPV4_ADDRESS_SIZE == 0); int numAddresses = messageSize / IPV4_ADDRESS_SIZE; - this->interfaceAddresses.erase (this->interfaceAddresses.begin(), + this->interfaceAddresses.erase (this->interfaceAddresses.begin (), this->interfaceAddresses.end ()); for (int n = 0; n < numAddresses; ++n) this->interfaceAddresses.push_back (Ipv4Address (i.ReadNtohU32 ())); diff --git a/src/olsr/model/olsr-repositories.h b/src/olsr/model/olsr-repositories.h index dba957e51..a9dcc56c5 100644 --- a/src/olsr/model/olsr-repositories.h +++ b/src/olsr/model/olsr-repositories.h @@ -60,8 +60,8 @@ namespace ns3 { namespace olsr { operator << (std::ostream &os, const IfaceAssocTuple &tuple) { os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr - << ", mainAddr=" << tuple.mainAddr - << ", time=" << tuple.time << ")"; + << ", mainAddr=" << tuple.mainAddr + << ", time=" << tuple.time << ")"; return os; } @@ -91,11 +91,11 @@ namespace ns3 { namespace olsr { operator << (std::ostream &os, const LinkTuple &tuple) { os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr - << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr - << ", symTime=" << tuple.symTime - << ", asymTime=" << tuple.asymTime - << ", expTime=" << tuple.time - << ")"; + << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr + << ", symTime=" << tuple.symTime + << ", asymTime=" << tuple.asymTime + << ", expTime=" << tuple.time + << ")"; return os; } @@ -125,8 +125,8 @@ namespace ns3 { namespace olsr { operator << (std::ostream &os, const NeighborTuple &tuple) { os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr - << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM") - << ", willingness=" << (int) tuple.willingness << ")"; + << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM") + << ", willingness=" << (int) tuple.willingness << ")"; return os; } @@ -145,9 +145,9 @@ namespace ns3 { namespace olsr { operator << (std::ostream &os, const TwoHopNeighborTuple &tuple) { os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr - << ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr - << ", expirationTime=" << tuple.expirationTime - << ")"; + << ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr + << ", expirationTime=" << tuple.expirationTime + << ")"; return os; } @@ -224,10 +224,10 @@ namespace ns3 { namespace olsr { operator << (std::ostream &os, const TopologyTuple &tuple) { os << "TopologyTuple(destAddr=" << tuple.destAddr - << ", lastAddr=" << tuple.lastAddr - << ", sequenceNumber=" << (int) tuple.sequenceNumber - << ", expirationTime=" << tuple.expirationTime - << ")"; + << ", lastAddr=" << tuple.lastAddr + << ", sequenceNumber=" << (int) tuple.sequenceNumber + << ", expirationTime=" << tuple.expirationTime + << ")"; return os; } @@ -249,8 +249,8 @@ namespace ns3 { namespace olsr { operator << (std::ostream &os, const Association &tuple) { os << "Association(networkAddr=" << tuple.networkAddr - << ", netmask=" << tuple.netmask - << ")"; + << ", netmask=" << tuple.netmask + << ")"; return os; } @@ -279,10 +279,10 @@ namespace ns3 { namespace olsr { operator << (std::ostream &os, const AssociationTuple &tuple) { os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr - << ", networkAddr=" << tuple.networkAddr - << ", netmask=" << tuple.netmask - << ", expirationTime=" << tuple.expirationTime - << ")"; + << ", networkAddr=" << tuple.networkAddr + << ", netmask=" << tuple.netmask + << ", expirationTime=" << tuple.expirationTime + << ")"; return os; } diff --git a/src/olsr/model/olsr-routing-protocol.cc b/src/olsr/model/olsr-routing-protocol.cc index c7f695ebf..f0d1eba84 100644 --- a/src/olsr/model/olsr-routing-protocol.cc +++ b/src/olsr/model/olsr-routing-protocol.cc @@ -126,7 +126,7 @@ /// Maximum allowed sequence number. #define OLSR_MAX_SEQ_NUM 65535 /// Random number between [0-OLSR_MAXJITTER] used to jitter OLSR packet transmission. -#define JITTER (Seconds (UniformVariable().GetValue (0, OLSR_MAXJITTER))) +#define JITTER (Seconds (UniformVariable ().GetValue (0, OLSR_MAXJITTER))) #define OLSR_PORT_NUMBER 698 @@ -320,7 +320,7 @@ void RoutingProtocol::DoStart () // Create a socket to listen only on this interface Ptr socket = Socket::CreateSocket (GetObject (), - UdpSocketFactory::GetTypeId()); + UdpSocketFactory::GetTypeId ()); socket->SetAllowBroadcast (true); InetSocketAddress inetAddr (m_ipv4->GetAddress (i, 0).GetLocal (), OLSR_PORT_NUMBER); socket->SetRecvCallback (MakeCallback (&RoutingProtocol::RecvOlsr, this)); @@ -393,9 +393,9 @@ RoutingProtocol::RecvOlsr (Ptr socket) sizeLeft -= messageHeader.GetSerializedSize (); NS_LOG_DEBUG ("Olsr Msg received with type " - << std::dec << int (messageHeader.GetMessageType ()) - << " TTL=" << int (messageHeader.GetTimeToLive ()) - << " origAddr=" << messageHeader.GetOriginatorAddress ()); + << std::dec << int (messageHeader.GetMessageType ()) + << " TTL=" << int (messageHeader.GetTimeToLive ()) + << " origAddr=" << messageHeader.GetOriginatorAddress ()); messages.push_back (messageHeader); } @@ -419,8 +419,8 @@ RoutingProtocol::RecvOlsr (Ptr socket) // If the message has been processed it must not be processed again bool do_forwarding = true; DuplicateTuple *duplicated = m_state.FindDuplicateTuple - (messageHeader.GetOriginatorAddress (), - messageHeader.GetMessageSequenceNumber ()); + (messageHeader.GetOriginatorAddress (), + messageHeader.GetMessageSequenceNumber ()); // Get main address of the peer, which may be different from the packet source address // const IfaceAssocTuple *ifaceAssoc = m_state.FindIfaceAssocTuple (inetSourceAddr.GetIpv4 ()); @@ -478,7 +478,7 @@ RoutingProtocol::RecvOlsr (Ptr socket) // If the message has been considered for forwarding, it should // not be retransmitted again for (std::vector::const_iterator it = duplicated->ifaceList.begin (); - it != duplicated->ifaceList.end(); it++) + it != duplicated->ifaceList.end (); it++) { if (*it == receiverIfaceAddr) { @@ -566,7 +566,7 @@ CoverTwoHopNeighbors (Ipv4Address neighborMainAddr, TwoHopNeighborSet & N2) /// \brief Computates MPR set of a node following RFC 3626 hints. /// void -RoutingProtocol::MprComputation() +RoutingProtocol::MprComputation () { NS_LOG_FUNCTION (this); @@ -578,7 +578,7 @@ RoutingProtocol::MprComputation() // N is the subset of neighbors of the node, which are // neighbor "of the interface I" NeighborSet N; - for (NeighborSet::const_iterator neighbor = m_state.GetNeighbors ().begin(); + for (NeighborSet::const_iterator neighbor = m_state.GetNeighbors ().begin (); neighbor != m_state.GetNeighbors ().end (); neighbor++) { if (neighbor->status == NeighborTuple::STATUS_SYM) // I think that we need this check @@ -765,7 +765,7 @@ RoutingProtocol::MprComputation() // through this 1-hop neighbor std::map > reachability; std::set rs; - for (NeighborSet::iterator it = N.begin(); it != N.end(); it++) + for (NeighborSet::iterator it = N.begin (); it != N.end (); it++) { NeighborTuple const &nb_tuple = *it; int r = 0; @@ -887,7 +887,7 @@ RoutingProtocol::RoutingTableComputation () // symmetric neighbors (h=1) as the destination nodes. const NeighborSet &neighborSet = m_state.GetNeighbors (); for (NeighborSet::const_iterator it = neighborSet.begin (); - it != neighborSet.end(); it++) + it != neighborSet.end (); it++) { NeighborTuple const &nb_tuple = *it; NS_LOG_DEBUG ("Looking at neighbor tuple: " << nb_tuple); @@ -896,8 +896,8 @@ RoutingProtocol::RoutingTableComputation () bool nb_main_addr = false; const LinkTuple *lt = NULL; const LinkSet &linkSet = m_state.GetLinks (); - for (LinkSet::const_iterator it2 = linkSet.begin(); - it2 != linkSet.end(); it2++) + for (LinkSet::const_iterator it2 = linkSet.begin (); + it2 != linkSet.end (); it2++) { LinkTuple const &link_tuple = *it2; NS_LOG_DEBUG ("Looking at link tuple: " << link_tuple @@ -939,10 +939,10 @@ RoutingProtocol::RoutingTableComputation () { NS_LOG_LOGIC ("no R_dest_addr is equal to the main address of the neighbor " "=> adding additional routing entry"); - AddEntry(nb_tuple.neighborMainAddr, - lt->neighborIfaceAddr, - lt->localIfaceAddr, - 1); + AddEntry (nb_tuple.neighborMainAddr, + lt->neighborIfaceAddr, + lt->localIfaceAddr, + 1); } } } @@ -978,7 +978,7 @@ RoutingProtocol::RoutingTableComputation () // neighbor node with willingness different of WILL_NEVER... bool nb2hopOk = false; for (NeighborSet::const_iterator neighbor = neighborSet.begin (); - neighbor != neighborSet.end(); neighbor++) + neighbor != neighborSet.end (); neighbor++) { if (neighbor->neighborMainAddr == nb2hop_tuple.neighborMainAddr && neighbor->willingness != OLSR_WILL_NEVER) @@ -1025,7 +1025,7 @@ RoutingProtocol::RoutingTableComputation () } } - for (uint32_t h = 2; ; h++) + for (uint32_t h = 2;; h++) { bool added = false; @@ -1130,7 +1130,7 @@ RoutingProtocol::RoutingTableComputation () if (localHnaAssoc.networkAddr == tuple.networkAddr && localHnaAssoc.netmask == tuple.netmask) { NS_LOG_DEBUG ("HNA association received from another GW is part of local HNA associations: no route added for network " - << tuple.networkAddr << "/" << tuple.netmask); + << tuple.networkAddr << "/" << tuple.netmask); goToNextAssociationTuple = true; } } @@ -1162,7 +1162,7 @@ RoutingProtocol::RoutingTableComputation () } else if(gatewayEntryExists && m_hnaRoutingTable->GetMetric (routeIndex) > gatewayEntry.distance) { - m_hnaRoutingTable->RemoveRoute(routeIndex); + m_hnaRoutingTable->RemoveRoute (routeIndex); addRoute = true; } @@ -1210,7 +1210,7 @@ RoutingProtocol::ProcessHello (const olsr::MessageHeader &msg, << "s ** BEGIN dump Link Set for OLSR Node " << m_mainAddress); for (LinkSet::const_iterator link = links.begin (); link != links.end (); link++) { - NS_LOG_DEBUG(*link); + NS_LOG_DEBUG (*link); } NS_LOG_DEBUG ("** END dump Link Set for OLSR Node " << m_mainAddress); @@ -1219,7 +1219,7 @@ RoutingProtocol::ProcessHello (const olsr::MessageHeader &msg, << "s ** BEGIN dump Neighbor Set for OLSR Node " << m_mainAddress); for (NeighborSet::const_iterator neighbor = neighbors.begin (); neighbor != neighbors.end (); neighbor++) { - NS_LOG_DEBUG(*neighbor); + NS_LOG_DEBUG (*neighbor); } NS_LOG_DEBUG ("** END dump Neighbor Set for OLSR Node " << m_mainAddress); } @@ -1236,7 +1236,7 @@ RoutingProtocol::ProcessHello (const olsr::MessageHeader &msg, for (TwoHopNeighborSet::const_iterator tuple = twoHopNeighbors.begin (); tuple != twoHopNeighbors.end (); tuple++) { - NS_LOG_DEBUG(*tuple); + NS_LOG_DEBUG (*tuple); } NS_LOG_DEBUG ("** END dump TwoHopNeighbor Set for OLSR Node " << m_mainAddress); } @@ -1376,8 +1376,8 @@ RoutingProtocol::ProcessMid (const olsr::MessageHeader &msg, { bool updated = false; IfaceAssocSet &ifaceAssoc = m_state.GetIfaceAssocSetMutable (); - for (IfaceAssocSet::iterator tuple = ifaceAssoc.begin(); - tuple != ifaceAssoc.end(); tuple++) + for (IfaceAssocSet::iterator tuple = ifaceAssoc.begin (); + tuple != ifaceAssoc.end (); tuple++) { if (tuple->ifaceAddr == *i && tuple->mainAddr == msg.GetOriginatorAddress ()) @@ -1405,14 +1405,14 @@ RoutingProtocol::ProcessMid (const olsr::MessageHeader &msg, // TwoHopNeighborTuples, update the neighbor addresses taking into account // the new MID information. NeighborSet &neighbors = m_state.GetNeighbors (); - for (NeighborSet::iterator neighbor = neighbors.begin (); neighbor != neighbors.end(); neighbor++) + for (NeighborSet::iterator neighbor = neighbors.begin (); neighbor != neighbors.end (); neighbor++) { neighbor->neighborMainAddr = GetMainAddress (neighbor->neighborMainAddr); } TwoHopNeighborSet &twoHopNeighbors = m_state.GetTwoHopNeighbors (); for (TwoHopNeighborSet::iterator twoHopNeighbor = twoHopNeighbors.begin (); - twoHopNeighbor != twoHopNeighbors.end(); twoHopNeighbor++) + twoHopNeighbor != twoHopNeighbors.end (); twoHopNeighbor++) { twoHopNeighbor->neighborMainAddr = GetMainAddress (twoHopNeighbor->neighborMainAddr); twoHopNeighbor->twoHopNeighborAddr = GetMainAddress (twoHopNeighbor->twoHopNeighborAddr); @@ -1446,10 +1446,10 @@ RoutingProtocol::ProcessHna (const olsr::MessageHeader &msg, // 2. Otherwise, for each (network address, netmask) pair in the // message: - for (std::vector::const_iterator it = hna.associations.begin(); - it != hna.associations.end() ; it++) + for (std::vector::const_iterator it = hna.associations.begin (); + it != hna.associations.end (); it++) { - AssociationTuple *tuple = m_state.FindAssociationTuple(msg.GetOriginatorAddress(),it->address,it->mask); + AssociationTuple *tuple = m_state.FindAssociationTuple (msg.GetOriginatorAddress (),it->address,it->mask); // 2.1 if an entry in the association set already exists, where: // A_gateway_addr == originator address @@ -1470,7 +1470,7 @@ RoutingProtocol::ProcessHna (const olsr::MessageHeader &msg, else { AssociationTuple assocTuple = { - msg.GetOriginatorAddress(), + msg.GetOriginatorAddress (), it->address, it->mask, now + msg.GetVTime () @@ -1745,14 +1745,14 @@ RoutingProtocol::SendHello () olsr::MessageHeader::Hello::LinkMessage linkMessage; linkMessage.linkCode = (link_type & 0x03) | ((nb_type << 2) & 0x0f); linkMessage.neighborInterfaceAddresses.push_back - (link_tuple->neighborIfaceAddr); + (link_tuple->neighborIfaceAddr); std::vector interfaces = m_state.FindNeighborInterfaces (link_tuple->neighborIfaceAddr); linkMessage.neighborInterfaceAddresses.insert - (linkMessage.neighborInterfaceAddresses.end (), - interfaces.begin (), interfaces.end ()); + (linkMessage.neighborInterfaceAddresses.end (), + interfaces.begin (), interfaces.end ()); linkMessages.push_back (linkMessage); } @@ -1780,8 +1780,8 @@ RoutingProtocol::SendTc () olsr::MessageHeader::Tc &tc = msg.GetTc (); tc.ansn = m_ansn; - for (MprSelectorSet::const_iterator mprsel_tuple = m_state.GetMprSelectors ().begin(); - mprsel_tuple != m_state.GetMprSelectors ().end(); mprsel_tuple++) + for (MprSelectorSet::const_iterator mprsel_tuple = m_state.GetMprSelectors ().begin (); + mprsel_tuple != m_state.GetMprSelectors ().end (); mprsel_tuple++) { tc.neighborAddresses.push_back (mprsel_tuple->mainAddr); } @@ -2091,7 +2091,7 @@ RoutingProtocol::LinkSensing (const olsr::MessageHeader &msg, } NS_LOG_DEBUG ("Link tuple updated: " << int (updated)); } - link_tuple->time = std::max(link_tuple->time, link_tuple->asymTime); + link_tuple->time = std::max (link_tuple->time, link_tuple->asymTime); if (updated) { @@ -2280,9 +2280,9 @@ RoutingProtocol::PopulateMprSelectorSet (const olsr::MessageHeader &msg, // Schedules mpr selector tuple deletion m_events.Track (Simulator::Schedule - (DELAY (mprsel_tuple.expirationTime), - &RoutingProtocol::MprSelTupleTimerExpire, this, - mprsel_tuple.mainAddr)); + (DELAY (mprsel_tuple.expirationTime), + &RoutingProtocol::MprSelTupleTimerExpire, this, + mprsel_tuple.mainAddr)); } else { @@ -2305,28 +2305,28 @@ RoutingProtocol::PopulateMprSelectorSet (const olsr::MessageHeader &msg, /// \param p the packet which couldn't be delivered by the MAC layer. /// void -OLSR::mac_failed(Ptr p) { +OLSR::mac_failed (Ptr p) { double now = Simulator::Now (); - struct hdr_ip* ih = HDR_IP(p); - struct hdr_cmn* ch = HDR_CMN(p); + struct hdr_ip* ih = HDR_IP (p); + struct hdr_cmn* ch = HDR_CMN (p); - debug("%f: Node %d MAC Layer detects a breakage on link to %d\n", - now, - OLSR::node_id(ra_addr()), - OLSR::node_id(ch->next_hop())); + debug ("%f: Node %d MAC Layer detects a breakage on link to %d\n", + now, + OLSR::node_id (ra_addr ()), + OLSR::node_id (ch->next_hop ())); - if ((u_int32_t)ih->daddr() == IP_BROADCAST) { - drop(p, DROP_RTR_MAC_CALLBACK); + if ((u_int32_t)ih->daddr () == IP_BROADCAST) { + drop (p, DROP_RTR_MAC_CALLBACK); return; } - OLSR_link_tuple* link_tuple = state_.find_link_tuple(ch->next_hop()); + OLSR_link_tuple* link_tuple = state_.find_link_tuple (ch->next_hop ()); if (link_tuple != NULL) { - link_tuple->lost_time() = now + OLSR_NEIGHB_HOLD_TIME; - link_tuple->time() = now + OLSR_NEIGHB_HOLD_TIME; - nb_loss(link_tuple); + link_tuple->lost_time () = now + OLSR_NEIGHB_HOLD_TIME; + link_tuple->time () = now + OLSR_NEIGHB_HOLD_TIME; + nb_loss (link_tuple); } - drop(p, DROP_RTR_MAC_CALLBACK); + drop (p, DROP_RTR_MAC_CALLBACK); } #endif @@ -2456,8 +2456,8 @@ RoutingProtocol::LinkTupleUpdated (const LinkTuple &tuple, uint8_t willingness) bool hasSymmetricLink = false; const LinkSet &linkSet = m_state.GetLinks (); - for (LinkSet::const_iterator it = linkSet.begin(); - it != linkSet.end(); it++) + for (LinkSet::const_iterator it = linkSet.begin (); + it != linkSet.end (); it++) { const LinkTuple &link_tuple = *it; if (GetMainAddress (link_tuple.neighborIfaceAddr) == nb_tuple->neighborMainAddr @@ -2616,7 +2616,7 @@ RoutingProtocol::AddTopologyTuple (const TopologyTuple &tuple) // OLSR::node_id(tuple->last_addr()), // tuple->seq()); - m_state.InsertTopologyTuple(tuple); + m_state.InsertTopologyTuple (tuple); } /// @@ -3031,7 +3031,7 @@ RoutingProtocol::FindSendEntry (RoutingTableEntry const &entry, outEntry = entry; while (outEntry.destAddr != outEntry.nextAddr) { - if (not Lookup(outEntry.nextAddr, outEntry)) + if (not Lookup (outEntry.nextAddr, outEntry)) return false; } return true; @@ -3040,7 +3040,7 @@ RoutingProtocol::FindSendEntry (RoutingTableEntry const &entry, Ptr RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, Ptr oif, Socket::SocketErrno &sockerr) { - NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject ()->GetId() << " " << header.GetDestination () << " " << oif); + NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject ()->GetId () << " " << header.GetDestination () << " " << oif); Ptr rtentry; RoutingTableEntry entry1, entry2; bool found = false; @@ -3088,7 +3088,7 @@ RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, Ptr nextHop=" << entry2.nextAddr << " interface=" << entry2.interface); - NS_LOG_DEBUG ("Found route to " << rtentry->GetDestination () << " via nh " << rtentry->GetGateway () << " with source addr " << rtentry->GetSource () << " and output dev " << rtentry->GetOutputDevice()); + NS_LOG_DEBUG ("Found route to " << rtentry->GetDestination () << " via nh " << rtentry->GetGateway () << " with source addr " << rtentry->GetSource () << " and output dev " << rtentry->GetOutputDevice ()); found = true; } else @@ -3098,7 +3098,7 @@ RoutingProtocol::RouteOutput (Ptr p, const Ipv4Header &header, PtrGetDestination () << " via nh " << rtentry->GetGateway () << " with source addr " << rtentry->GetSource () << " and output dev " << rtentry->GetOutputDevice()); + NS_LOG_DEBUG ("Found route to " << rtentry->GetDestination () << " via nh " << rtentry->GetGateway () << " with source addr " << rtentry->GetSource () << " and output dev " << rtentry->GetOutputDevice ()); } } @@ -3117,7 +3117,7 @@ bool RoutingProtocol::RouteInput (Ptr p, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) { - NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject ()->GetId() << " " << header.GetDestination ()); + NS_LOG_FUNCTION (this << " " << m_ipv4->GetObject ()->GetId () << " " << header.GetDestination ()); Ipv4Address dst = header.GetDestination (); Ipv4Address origin = header.GetSource (); diff --git a/src/olsr/model/olsr-routing-protocol.h b/src/olsr/model/olsr-routing-protocol.h index 68f410c83..485fb5a73 100644 --- a/src/olsr/model/olsr-routing-protocol.h +++ b/src/olsr/model/olsr-routing-protocol.h @@ -47,6 +47,10 @@ namespace ns3 { namespace olsr { +/// +/// \defgroup olsr OLSR Routing +/// This section documents the API of the ns-3 OLSR module. For a generic +/// functional description, please refer to the ns-3 manual. /// An %OLSR's routing table entry. struct RoutingTableEntry diff --git a/src/olsr/model/olsr-state.cc b/src/olsr/model/olsr-state.cc index 4b4f405d8..188866e47 100644 --- a/src/olsr/model/olsr-state.cc +++ b/src/olsr/model/olsr-state.cc @@ -210,7 +210,7 @@ OlsrState::EraseTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple) { if (*it == tuple) { - m_twoHopNeighborSet.erase(it); + m_twoHopNeighborSet.erase (it); break; } } @@ -284,7 +284,7 @@ DuplicateTuple* OlsrState::FindDuplicateTuple (Ipv4Address const &addr, uint16_t sequenceNumber) { for (DuplicateSet::iterator it = m_duplicateSet.begin (); - it != m_duplicateSet.end(); it++) + it != m_duplicateSet.end (); it++) { if (it->address == addr && it->sequenceNumber == sequenceNumber) return &(*it); @@ -392,7 +392,7 @@ OlsrState::FindNewerTopologyTuple (Ipv4Address const & lastAddr, uint16_t ansn) } void -OlsrState::EraseTopologyTuple(const TopologyTuple &tuple) +OlsrState::EraseTopologyTuple (const TopologyTuple &tuple) { for (TopologySet::iterator it = m_topologySet.begin (); it != m_topologySet.end (); it++) @@ -408,8 +408,8 @@ OlsrState::EraseTopologyTuple(const TopologyTuple &tuple) void OlsrState::EraseOlderTopologyTuples (const Ipv4Address &lastAddr, uint16_t ansn) { - for (TopologySet::iterator it = m_topologySet.begin(); - it != m_topologySet.end();) + for (TopologySet::iterator it = m_topologySet.begin (); + it != m_topologySet.end ();) { if (it->lastAddr == lastAddr && it->sequenceNumber < ansn) { @@ -540,7 +540,7 @@ OlsrState::EraseAssociation (const Association &tuple) void OlsrState::InsertAssociation (const Association &tuple) { - m_associations.push_back(tuple); + m_associations.push_back (tuple); } } // namespace ns3 diff --git a/src/olsr/test/bug780-test.cc b/src/olsr/test/bug780-test.cc index d0a908de0..11e016627 100644 --- a/src/olsr/test/bug780-test.cc +++ b/src/olsr/test/bug780-test.cc @@ -77,7 +77,7 @@ Bug780Test::~Bug780Test() void Bug780Test::DoRun () { - SeedManager::SetSeed(123); + SeedManager::SetSeed (123); CreateNodes (); Simulator::Stop (m_time); @@ -116,8 +116,8 @@ Bug780Test::CreateNodes (void) NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifi.SetStandard (WIFI_PHY_STANDARD_80211b); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode",StringValue(phyMode), - "ControlMode",StringValue(phyMode)); + "DataMode",StringValue (phyMode), + "ControlMode",StringValue (phyMode)); //set the tx range to 300 wifiPhy.Set ("TxPowerStart",DoubleValue (-0.1615)); @@ -143,24 +143,24 @@ Bug780Test::CreateNodes (void) Ptr positionAlloc_Adhoc = CreateObject(); double distance = 0.0; - for (uint32_t i = 0; i <= adhocNodes.GetN(); i++) + for (uint32_t i = 0; i <= adhocNodes.GetN (); i++) { - positionAlloc_Adhoc->Add(Vector(distance,0.0,0.0)); + positionAlloc_Adhoc->Add (Vector (distance,0.0,0.0)); distance += 250.0; } mobilityAdhoc.SetMobilityModel ("ns3::ConstantVelocityMobilityModel"); - mobilityAdhoc.SetPositionAllocator(positionAlloc_Adhoc); + mobilityAdhoc.SetPositionAllocator (positionAlloc_Adhoc); mobilityAdhoc.Install (adhocNodes); //At 50 sec node 3 moves towards node 2 - Simulator::Schedule (Seconds (50.0), &SetVelocity, adhocNodes.Get(2),Vector(-5.0,0.0,0.0)); + Simulator::Schedule (Seconds (50.0), &SetVelocity, adhocNodes.Get (2),Vector (-5.0,0.0,0.0)); //AT 100 sec set node 3 with zero velocity - Simulator::Schedule (Seconds (100.0), &SetVelocity, adhocNodes.Get(2),Vector(0.0,0.0,0.0)); + Simulator::Schedule (Seconds (100.0), &SetVelocity, adhocNodes.Get (2),Vector (0.0,0.0,0.0)); //Move node2 away from node 3 - Simulator::Schedule (Seconds (100.0), &SetVelocity, adhocNodes.Get(1),Vector(5.0,0.0,0.0)); + Simulator::Schedule (Seconds (100.0), &SetVelocity, adhocNodes.Get (1),Vector (5.0,0.0,0.0)); //AT 150 sec set node 2 with zero velocity - Simulator::Schedule (Seconds (150.0), &SetVelocity, adhocNodes.Get(1), Vector(0.0,0.0,0.0)); + Simulator::Schedule (Seconds (150.0), &SetVelocity, adhocNodes.Get (1), Vector (0.0,0.0,0.0)); // Ping 10.1.1.1 -> 10.1.1.2 @@ -169,7 +169,7 @@ Bug780Test::CreateNodes (void) ApplicationContainer p = ping.Install (adhocNodes.Get (0)); p.Start (Seconds (50)); - p.Stop (Seconds (SimTime) - Seconds(0.001)); + p.Stop (Seconds (SimTime) - Seconds (0.001)); // pcap std::string prefix = (WRITE_VECTORS ? NS_TEST_SOURCEDIR : GetTempDir ()) + PREFIX; @@ -186,9 +186,9 @@ Bug780Test::CheckResults () os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-0.pcap"; os2 << GetTempDir () << PREFIX << "-" << i << "-0.pcap"; - uint32_t sec(0), usec(0); - bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); - NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() + uint32_t sec (0), usec (0); + bool diff = PcapFile::Diff (os1.str (), os2.str (), sec, usec); + NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str () << " and " << os2.str () << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/olsr/test/hello-regression-test.cc b/src/olsr/test/hello-regression-test.cc index e2c352b5d..672ab9852 100644 --- a/src/olsr/test/hello-regression-test.cc +++ b/src/olsr/test/hello-regression-test.cc @@ -54,7 +54,7 @@ HelloRegressionTest::~HelloRegressionTest() void HelloRegressionTest::DoRun () { - SeedManager::SetSeed(12345); + SeedManager::SetSeed (12345); CreateNodes (); Simulator::Stop (m_time); @@ -99,9 +99,9 @@ HelloRegressionTest::CheckResults () os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap"; os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap"; - uint32_t sec(0), usec(0); - bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); - NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() + uint32_t sec (0), usec (0); + bool diff = PcapFile::Diff (os1.str (), os2.str (), sec, usec); + NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str () << " and " << os2.str () << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/olsr/test/olsr-header-test-suite.cc b/src/olsr/test/olsr-header-test-suite.cc index 4a1608bf8..9c0cac138 100644 --- a/src/olsr/test/olsr-header-test-suite.cc +++ b/src/olsr/test/olsr-header-test-suite.cc @@ -41,8 +41,8 @@ OlsrEmfTestCase::DoRun (void) { uint8_t emf = olsr::SecondsToEmf (time); double seconds = olsr::EmfToSeconds (emf); - NS_TEST_ASSERT_MSG_EQ((seconds < 0 || fabs (seconds - time) > 0.1), false, - "XXX"); + NS_TEST_ASSERT_MSG_EQ ((seconds < 0 || fabs (seconds - time) > 0.1), false, + "XXX"); } } @@ -128,7 +128,7 @@ OlsrMidTestCase::DoRun (void) NS_TEST_ASSERT_MSG_EQ (*mid1.interfaceAddresses.begin (), Ipv4Address ("1.2.3.4"), "XXX"); sizeLeft -= msg1.GetSerializedSize (); - NS_TEST_ASSERT_MSG_EQ((sizeLeft > 0), true, "XXX"); + NS_TEST_ASSERT_MSG_EQ ((sizeLeft > 0), true, "XXX"); } { // now read the second message @@ -303,13 +303,13 @@ public: } g_olsrTestSuite; OlsrTestSuite::OlsrTestSuite() - : TestSuite("routing-olsr-header", UNIT) + : TestSuite ("routing-olsr-header", UNIT) { - AddTestCase(new OlsrHnaTestCase()); - AddTestCase(new OlsrTcTestCase()); - AddTestCase(new OlsrHelloTestCase()); - AddTestCase(new OlsrMidTestCase()); - AddTestCase(new OlsrEmfTestCase()); + AddTestCase (new OlsrHnaTestCase ()); + AddTestCase (new OlsrTcTestCase ()); + AddTestCase (new OlsrHelloTestCase ()); + AddTestCase (new OlsrMidTestCase ()); + AddTestCase (new OlsrEmfTestCase ()); } } // namespace ns3 diff --git a/src/olsr/test/olsr-routing-protocol-test-suite.cc b/src/olsr/test/olsr-routing-protocol-test-suite.cc index 7fdea2474..c07a4d4d1 100644 --- a/src/olsr/test/olsr-routing-protocol-test-suite.cc +++ b/src/olsr/test/olsr-routing-protocol-test-suite.cc @@ -174,7 +174,7 @@ public: } g_olsrProtocolTestSuite; OlsrProtocolTestSuite::OlsrProtocolTestSuite() - : TestSuite("routing-olsr", UNIT) + : TestSuite ("routing-olsr", UNIT) { AddTestCase (new OlsrMprTestCase ()); } diff --git a/src/olsr/test/tc-regression-test.cc b/src/olsr/test/tc-regression-test.cc index 442bdece3..f3f7f6a1d 100644 --- a/src/olsr/test/tc-regression-test.cc +++ b/src/olsr/test/tc-regression-test.cc @@ -59,7 +59,7 @@ TcRegressionTest::~TcRegressionTest() void TcRegressionTest::DoRun () { - SeedManager::SetSeed(12345); + SeedManager::SetSeed (12345); CreateNodes (); Simulator::Stop (m_time); @@ -127,9 +127,9 @@ TcRegressionTest::CheckResults () os1 << NS_TEST_SOURCEDIR << PREFIX << "-" << i << "-1.pcap"; os2 << GetTempDir () << PREFIX << "-" << i << "-1.pcap"; - uint32_t sec(0), usec(0); - bool diff = PcapFile::Diff (os1.str(), os2.str(), sec, usec); - NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str() << " and " << os2.str() + uint32_t sec (0), usec (0); + bool diff = PcapFile::Diff (os1.str (), os2.str (), sec, usec); + NS_TEST_EXPECT_MSG_EQ (diff, false, "PCAP traces " << os1.str () << " and " << os2.str () << " differ starting from " << sec << " s " << usec << " us"); } } diff --git a/src/openflow/doc/openflow-switch.h b/src/openflow/doc/openflow-switch.h deleted file mode 100644 index 97dab7d27..000000000 --- a/src/openflow/doc/openflow-switch.h +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2011 Blake Hurd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA - * - * Author: Blake Hurd - */ - -/** - * \defgroup OpenFlowSwitchModel OpenFlow Switch Device - * - * \section OpenFlowSwitchModelOverview OpenFlow Switch Model Overview - * - * The ns-3 OpenFlowSwitch device models an OpenFlow-enabled switch. It is designed to - * express basic use of the OpenFlow protocol, with the maintaining of a virtual - * Flow Table and TCAM to provide OpenFlow-like results. - * - * The functionality comes down to the Controllers, which send messages to the - * switch that configure its flows, producing different effects. Controllers can - * be added by the user, under the ofi namespace extends ofi::Controller. To - * demonstrate this, a DropController, which creates flows for ignoring every single - * packet, and LearningController, which effectively makes the switch a more complicated - * BridgeNetDevice. A user versed in a standard OFSID, and/or OF protocol, can write - * virtual controllers to create switches of all kinds of types. - * - * \section OpenFlowSwitchModel OpenFlow Switch Model - * - * The OpenFlowSwitch device behaves somewhat according to the diagram setup as a classical OFSID - * switch, with a few modifications made for a proper simulation environment. - * - * Normal OF-enabled Switch - * ----------------------------------- - * | Secure Channel | <--OF Protocol--> | Controller is external | - * | Hardware or Software Flow Table | - * ----------------------------------- - * - * ns-3 OF-enabled Switch (module) - * ------------------------------------- - * | m_controller->ReceiveFromSwitch() | <--OF Protocol--> | Controller is internal | - * | Software Flow Table, virtual TCAM | - * ------------------------------------- - * - * In essence, there are two differences: - * # No SSL, Embedded Controller: Instead of a secure channel and connecting to an - * outside location for the Controller program/machine, we currently only allow a - * Controller extended from ofi::Controller, an extension of an ns3::Object. This - * means ns-3 programmers cannot model the SSL part of the interface or possibility - * of network failure. The connection to the OpenFlowSwitch is local and there aren't any - * reasons for the channel/connection to break down. <> - * - * # Virtual Flow Table, TCAM: Typical OF-enabled switches are implemented on a hardware - * TCAM. The OFSID we turn into a library includes a modelled software TCAM, that produces - * the same results as a hardware TCAM. We include an attribute FlowTableLookupDelay, which - * allows a simple delay of using the TCAM to be modelled. We don't endeavor to make this - * delay more complicated, based on the tasks we are running on the TCAM, that is a possible - * future improvement. - * - * \section OpenFlowSwitchNetDeviceModel OpenFlow Switch Net Device Model - * - * The OpenFlowSwitch network device is aimed to model an OpenFlow switch, with a TCAM and a connection - * to a controller program. With some tweaking, it can model every switch type, as per OpenFlow's - * extensibility. It outsources the complexity of the switch ports to NetDevices of the user's choosing. - * It should be noted that these NetDevices must behave like practical switch ports, i.e. a Mac Address - * is assigned, and nothing more. It also must support a SendFrom function so - * that the OpenFlowSwitch can forward across that port. - * - * The OpenFlowSwitchNetDevice provides following Attributes: - * - * - FlowTableLookUpDelay: This time gets run off the clock when making a lookup in our Flow Table. - * - Flags: OpenFlow specific configuration flags. They are defined in the ofp_config_flags enum. Choices include: - * OFPC_SEND_FLOW_EXP (OpenFlowSwitch notifies controller when a flow has expired), - * OFPC_FRAG_NORMAL (Match fragment against Flow table), - * OFPC_FRAG_DROP (Drop fragments), - * OFPC_FRAG_REASM (Reassemble only if OFPC_IP_REASM set, which is currently impossible, - * because switch implementation does not support IP reassembly) - * OFPC_FRAG_MASK (Mask Fragments) - * - FlowTableMissSendLength: When the packet doesn't match in our Flow Table, and we forward to the controller, - * this sets # of bytes forwarded (packet is not forwarded in its entirety, unless specified). - * - * \section OpenFlowSwitchModelSummary OpenFlow Switch Model Summary - * - * The ns-3 OpenFlowSwitch device models an OpenFlow-enabled switch. It is designed to - * express basic use of the OpenFlow protocol, with the maintaining of a virtual - * Flow Table and TCAM to provide OpenFlow-like results. - * - * The functionality comes down to the Controllers, which send messages to the - * switch that configure its flows, producing different effects. Controllers can - * be added by the user, under the ofi namespace extends ofi::Controller. To - * demonstrate this, a DropController, which creates flows for ignoring every single - * packet, and LearningController, which effectively makes the switch a more complicated - * BridgeNetDevice. A user versed in a standard OFSID, and/or OF protocol, can write - * virtual controllers to create switches of all kinds of types. - * - * In order to use the OpenFlowSwitch module, you must create and link the - * OFSID (OpenFlow Software Implementation Distribution) to ns-3. - * To do this: - * - * #1 Obtain the OFSID code. An ns-3 specific OFSID branch is provided - * to ensure operation with ns-3. The OFSID has several dependencies - * include libxml2, libdl, and the boost libraries. Use mercurial to - * download this branch and waf to build the library: - * - * $ hg clone http://code.nsnam.org/jpelkey3/openflow - * $ cd openflow - * $ ./waf configure - * $ ./waf build - * - * #2 Your OFSID is now built into a libopenflow.a library! To - * link to an ns-3 build with this switch module, run from the ns-3-dev - * (or whatever you have named your distribution): - * - * $ ./waf configure --with-openflow=path/to/openflow - * - * #3 Under "---- Summary of optional NS-3 features:", you should see - * "NS-3 OpenFlow Integration : enabled", indicating the library - * has been linked to ns-3. Run: - * - * $ ./waf build - * - * to build ns-3 and activate the OpenFlowSwitch module. - * - * Once set up, you have access to some tests: - * - * For a test suite for the switch module, run: - * - * $ ./test.py --suite=openflow - * - * For an example demonstrating its use in a simple learning controller/switch, run: - * - * $ ./waf --run openflow-switch - * - * To see it in detailed logging, run: - * - * $ ./waf --run "openflow-switch -v" - * - * If you have any questions, read the wiki - * first, and consider posting to the ns-3 developers mailing list , - * but feel free to reach me at - */ diff --git a/src/openflow/doc/openflow-switch.rst b/src/openflow/doc/openflow-switch.rst index fec813fe9..18d4d1011 100644 --- a/src/openflow/doc/openflow-switch.rst +++ b/src/openflow/doc/openflow-switch.rst @@ -134,7 +134,12 @@ To do this: #1 Obtain the OFSID code. An ns-3 specific OFSID branch is provided to ensure operation with ns-3. Use mercurial to download this branch and waf to build -the library. From the "openflow" directory, run::: +the library::: + + $ hg clone http://code.nsnam.org/jpelkey3/openflow + $ cd openflow + +From the "openflow" directory, run::: $ ./waf configure $ ./waf build diff --git a/src/openflow/examples/openflow-switch.cc b/src/openflow/examples/openflow-switch.cc index 3d2fb5bc6..72d83c407 100644 --- a/src/openflow/examples/openflow-switch.cc +++ b/src/openflow/examples/openflow-switch.cc @@ -89,8 +89,8 @@ main (int argc, char *argv[]) cmd.AddValue ("verbose", "Verbose (turns on logging).", MakeCallback (&SetVerbose)); cmd.AddValue ("d", "Use Drop Controller (Learning if not specified).", MakeCallback (&SetDrop)); cmd.AddValue ("drop", "Use Drop Controller (Learning if not specified).", MakeCallback (&SetDrop)); - cmd.AddValue ("t", "Learning Controller Timeout (has no effect if drop controller is specified).", MakeCallback( &SetTimeout)); - cmd.AddValue ("timeout", "Learning Controller Timeout (has no effect if drop controller is specified).", MakeCallback( &SetTimeout)); + cmd.AddValue ("t", "Learning Controller Timeout (has no effect if drop controller is specified).", MakeCallback ( &SetTimeout)); + cmd.AddValue ("timeout", "Learning Controller Timeout (has no effect if drop controller is specified).", MakeCallback ( &SetTimeout)); cmd.Parse (argc, argv); diff --git a/src/openflow/helper/openflow-switch-helper.h b/src/openflow/helper/openflow-switch-helper.h index fc54d32b1..cb73c2970 100644 --- a/src/openflow/helper/openflow-switch-helper.h +++ b/src/openflow/helper/openflow-switch-helper.h @@ -17,8 +17,6 @@ * * Author: Blake Hurd */ -#ifdef NS3_OPENFLOW - #ifndef OPENFLOW_SWITCH_HELPER_H #define OPENFLOW_SWITCH_HELPER_H @@ -101,5 +99,4 @@ private: } // namespace ns3 -#endif // NS3_OPENFLOW #endif /* OPENFLOW_SWITCH_HELPER_H */ diff --git a/src/openflow/model/openflow-interface.cc b/src/openflow/model/openflow-interface.cc index 1ef9601c4..1becf76bd 100644 --- a/src/openflow/model/openflow-interface.cc +++ b/src/openflow/model/openflow-interface.cc @@ -746,7 +746,7 @@ DropController::ReceiveFromSwitch (Ptr swtch, ofpbuf* b } // We have received any packet at this point, so we pull the header to figure out what type of packet we're handling. - uint8_t type = GetPacketType(buffer); + uint8_t type = GetPacketType (buffer); if (type == OFPT_PACKET_IN) // The switch didn't understand the packet it received, so it forwarded it to the controller. { @@ -766,7 +766,7 @@ DropController::ReceiveFromSwitch (Ptr swtch, ofpbuf* b TypeId LearningController::GetTypeId (void) { static TypeId tid = TypeId ("ns3::ofi::LearningController") - .SetParent (Controller::GetTypeId()) + .SetParent (Controller::GetTypeId ()) .AddConstructor () .AddAttribute ("ExpirationTime", "Time it takes for learned MAC state entry/created flow to expire.", @@ -787,7 +787,7 @@ LearningController::ReceiveFromSwitch (Ptr swtch, ofpbu } // We have received any packet at this point, so we pull the header to figure out what type of packet we're handling. - uint8_t type = GetPacketType(buffer); + uint8_t type = GetPacketType (buffer); if (type == OFPT_PACKET_IN) // The switch didn't understand the packet it received, so it forwarded it to the controller. { diff --git a/src/openflow/model/openflow-interface.h b/src/openflow/model/openflow-interface.h index bac3b5b59..165e4a124 100644 --- a/src/openflow/model/openflow-interface.h +++ b/src/openflow/model/openflow-interface.h @@ -18,8 +18,6 @@ #ifndef OPENFLOW_INTERFACE_H #define OPENFLOW_INTERFACE_H -#ifdef NS3_OPENFLOW - #include #include @@ -563,5 +561,4 @@ uint16_t ValidateVendor (const sw_flow_key *key, const ofp_action_header *ah, ui } -#endif // NS3_OPENFLOW #endif /* OPENFLOW_INTERFACE_H */ diff --git a/src/openflow/model/openflow-switch-net-device.cc b/src/openflow/model/openflow-switch-net-device.cc index 04b2e7625..d2d178161 100644 --- a/src/openflow/model/openflow-switch-net-device.cc +++ b/src/openflow/model/openflow-switch-net-device.cc @@ -647,7 +647,7 @@ OpenFlowSwitchNetDevice::ReceiveFromDevice (Ptr netdev, Ptr= Seconds (m_lastExecute.GetSeconds () + 1)) // If a second or more has passed from the simulation time, execute. { // If port status is modified in any way, notify the controller. diff --git a/src/openflow/model/openflow-switch-net-device.h b/src/openflow/model/openflow-switch-net-device.h index 63c2492bd..23812cbd6 100644 --- a/src/openflow/model/openflow-switch-net-device.h +++ b/src/openflow/model/openflow-switch-net-device.h @@ -15,7 +15,11 @@ * * Author: Blake Hurd */ -#ifdef NS3_OPENFLOW + +/** + * \defgroup openflow OpenFlow Switch Device + * This section documents the API of the ns-3 OpenFlow module. For a generic functional description, please refer to the ns-3 manual. + */ #ifndef OPENFLOW_SWITCH_NET_DEVICE_H #define OPENFLOW_SWITCH_NET_DEVICE_H @@ -47,8 +51,7 @@ namespace ns3 { /** - * \defgroup openflow OpenFlow - * + * \ingroup openflow * \brief A net device that switches multiple LAN segments via an OpenFlow-compatible flow table * * The OpenFlowSwitchNetDevice object aggregates multiple netdevices as ports @@ -77,7 +80,7 @@ namespace ns3 { */ /** - * \ingroup switch + * \ingroup openflow * \brief A net device that switches multiple LAN segments via an OpenFlow-compatible flow table */ class OpenFlowSwitchNetDevice : public NetDevice @@ -546,4 +549,3 @@ private: } // namespace ns3 #endif /* OPENFLOW_SWITCH_NET_DEVICE_H */ -#endif // NS3_OPENFLOW diff --git a/src/openflow/wscript b/src/openflow/wscript index f0bb673cb..1c3c3939c 100644 --- a/src/openflow/wscript +++ b/src/openflow/wscript @@ -25,6 +25,11 @@ def configure(conf): if not conf.env['BOOST']: conf.report_optional_feature("openflow", "NS-3 OpenFlow Integration", False, "Required boost libraries not found") + + # Add this module to the list of modules that won't be built + # if they are enabled. + conf.env['MODULES_NOT_BUILT'].append('openflow') + return if Options.options.with_openflow: @@ -41,6 +46,10 @@ def configure(conf): conf.check_message("OpenFlow location", '', False) conf.report_optional_feature("openflow", "NS-3 OpenFlow Integration", False, "OpenFlow not enabled (see option --with-openflow)") + # Add this module to the list of modules that won't be built + # if they are enabled. + conf.env['MODULES_NOT_BUILT'].append('openflow') + return test_code = ''' @@ -112,10 +121,18 @@ int main() conf.env.append_value('CXXDEFINES', 'NS3_OPENFLOW') conf.env.append_value('CPPPATH', conf.env['CPPPATH_OPENFLOW']) conf.env.append_value('LIBPATH', conf.env['LIBPATH_OPENFLOW']) + else: + # Add this module to the list of modules that won't be built + # if they are enabled. + conf.env['MODULES_NOT_BUILT'].append('openflow') def build(bld): + # Don't do anything for this module if openflow's not enabled. + if 'openflow' in bld.env['MODULES_NOT_BUILT']: + return + # Build the Switch module obj = bld.create_ns3_module('openflow', ['internet']) obj.source = [ diff --git a/src/point-to-point-layout/model/point-to-point-dumbbell.cc b/src/point-to-point-layout/model/point-to-point-dumbbell.cc index f19407067..7af216b46 100644 --- a/src/point-to-point-layout/model/point-to-point-dumbbell.cc +++ b/src/point-to-point-layout/model/point-to-point-dumbbell.cc @@ -30,7 +30,7 @@ #include "ns3/point-to-point-net-device.h" #include "ns3/vector.h" -NS_LOG_COMPONENT_DEFINE("PointToPointDumbbellHelper"); +NS_LOG_COMPONENT_DEFINE ("PointToPointDumbbellHelper"); namespace ns3 { @@ -54,7 +54,7 @@ PointToPointDumbbellHelper::PointToPointDumbbellHelper (uint32_t nLeftLeaf, NetDeviceContainer c = leftHelper.Install (m_routers.Get (0), m_leftLeaf.Get (i)); m_leftRouterDevices.Add (c.Get (0)); - m_leftLeafDevices.Add (c.Get(1)); + m_leftLeafDevices.Add (c.Get (1)); } // Add the right side links for (uint32_t i = 0; i < nRightLeaf; ++i) @@ -129,7 +129,7 @@ void PointToPointDumbbellHelper::AssignIpv4Addresses (Ipv4AddressHelper leftIp, NetDeviceContainer ndc; ndc.Add (m_leftLeafDevices.Get (i)); ndc.Add (m_leftRouterDevices.Get (i)); - Ipv4InterfaceContainer ifc = leftIp.Assign(ndc); + Ipv4InterfaceContainer ifc = leftIp.Assign (ndc); m_leftLeafInterfaces.Add (ifc.Get (0)); m_leftRouterInterfaces.Add (ifc.Get (1)); leftIp.NewNetwork (); diff --git a/src/point-to-point-layout/model/point-to-point-grid.cc b/src/point-to-point-layout/model/point-to-point-grid.cc index 321bd54c2..681a127ec 100644 --- a/src/point-to-point-layout/model/point-to-point-grid.cc +++ b/src/point-to-point-layout/model/point-to-point-grid.cc @@ -25,7 +25,7 @@ #include "ns3/vector.h" #include "ns3/log.h" -NS_LOG_COMPONENT_DEFINE("PointToPointGridHelper"); +NS_LOG_COMPONENT_DEFINE ("PointToPointGridHelper"); namespace ns3 { @@ -62,8 +62,8 @@ PointToPointGridHelper::PointToPointGridHelper (uint32_t nRows, // install vertical p2p links if (y > 0) { - colDevices.Add(pointToPoint. - Install ((m_nodes.at (y-1)).Get (x), rowNodes.Get (x))); + colDevices.Add (pointToPoint. + Install ((m_nodes.at (y-1)).Get (x), rowNodes.Get (x))); } } diff --git a/src/point-to-point-layout/model/point-to-point-star.cc b/src/point-to-point-layout/model/point-to-point-star.cc index 5d42f7103..0c2f1ade5 100644 --- a/src/point-to-point-layout/model/point-to-point-star.cc +++ b/src/point-to-point-layout/model/point-to-point-star.cc @@ -26,7 +26,7 @@ #include "ns3/point-to-point-net-device.h" #include "ns3/vector.h" -NS_LOG_COMPONENT_DEFINE("PointToPointStarHelper"); +NS_LOG_COMPONENT_DEFINE ("PointToPointStarHelper"); namespace ns3 { diff --git a/src/point-to-point/doc/point-to-point.h b/src/point-to-point/doc/point-to-point.h deleted file mode 100644 index 4073b8cce..000000000 --- a/src/point-to-point/doc/point-to-point.h +++ /dev/null @@ -1,132 +0,0 @@ -/** - * \defgroup PointToPointModel Point-to-Point Device - * - * \section PointToPointPointOverview Point-to-Point Model Overview - * - * The ns-3 point-to-point model is of a very simple point to point data link - * connecting exactly two ns3::PointToPointNetDevice devices over an - * ns3::PointToPointChannel. This can be viewed as equivalent to a full - * duplex RS-232 or RS-422 link with null modem and no handshaking. - * - * Data is encapsulated in the Point-to-Point Protocol (PPP -- RFC 1661), - * however the Link Control Protocol (LCP) and associated state machine is - * not implemented. The PPP link is assumed to be established and - * authenticated at all times. - * - * Data is not framed, therefore Address and Control fields will not be found. - * Since the data is not framed, there is no need to provide Flag Sequence and - * Control Escape octets, nor is a Frame Check Sequence appended. All that is - * required to implement non-framed PPP is to prepend the PPP protocol number - * for IP Version 4 which is the sixteen-bit number 0x21 (see - * http://www.iana.org/assignments/ppp-numbers). - * - * The PointToPointNetDevice provides following Attributes: - * - * - Address: The ns3::Mac48Address of the device (if desired); - * - DataRate: The data rate (ns3::DataRate) of the device; - * - TxQueue: The transmit queue (ns3::Queue) used by the device; - * - InterframeGap: The optional ns3::Time to wait between "frames"; - * - Rx: A trace source for received packets; - * - Drop: A trace source for dropped packets. - * - * The PointToPointNetDevice models a transmitter section that puts bits - * on a corresponding channel "wire." `The DataRate attribute specifies the - * number of bits per second that the device will simulate sending over the - * channel. In reality no bits are sent, but an event is scheduled for an - * elapsed time consistent with the number of bits in each packet and the - * specified DataRate. The implication here is that the receiving device - * models a receiver section that can receive any any data rate. Therefore - * there is no need, nor way to set a receive data rate in this model. By - * setting the DataRate on the transmitter of both devices connected to a - * given PointToPointChannel one can model a symmetric channel; or by - * setting different DataRates one can model an asymmetric channel (e.g., - * ADSL). - * - * The PointToPointNetDevice supports the assignment of a "receive error - * model." This is an ns3::ErrorModel object that is used to simulate data - * corruption on the link. - * - * \section PointToPointChannelModel Point-to-Point Channel Model - - * The point to point net devices are connected via an - * ns3::PointToPointChannel. This channel models two wires transmitting bits - * at the data rate specified by the source net device. There is no overhead - * beyond the eight bits per byte of the packet sent. That is, we do not - * model Flag Sequences, Frame Check Sequences nor do we "escape" any data. - * - * The PointToPointNetChannel provides following Attributes: - * - * - Delay: An ns3::Time specifying the speed of light transmission delay for - * the channel. - * - * \section PointToPointTracingModel Point-to-Point Tracing Model - * - * Like all ns-3 devices, the Point-to-Point Model provides a number of trace - * sources. These trace sources can be hooked using your own custom trace code, - * or you can use our helper functions to arrange for tracing to be enabled on - * devices you specify. - * - * \subsection PointToPointTracingModelUpperHooks Upper-Level (MAC) Hooks - * - * From the point of view of tracing in the net device, there are several - * interesting points to insert trace hooks. A convention inherited from other - * simulators is that packets destined for transmission onto attached networks - * pass through a single "transmit queue" in the net device. We provide trace - * hooks at this point in packet flow, which corresponds (abstractly) only to a - * transition from the network to data link layer, and call them collectively - * the device MAC hooks. - * - * When a packet is sent to the Point-to-Point net device for transmission it - * always passes through the transmit queue. The transmit queue in the - * PointToPointNetDevice inherits from Queue, and therefore inherits three - * trace sources: - * - * - An Enqueue operation source (see Queue::m_traceEnqueue); - * - A Dequeue operation source (see Queue::m_traceDequeue); - * - A Drop operation source (see Queue::m_traceDrop). - * - * The upper-level (MAC) trace hooks for the PointToPointNetDevice are, in fact, - * exactly these three trace sources on the single transmit queue of the device. - * - * The m_traceEnqueue event is triggered when a packet is placed on the transmit - * queue. This happens at the time that ns3::PointtoPointNetDevice::Send or - * ns3::PointToPointNetDevice::SendFrom is called by a higher layer to queue a - * packet for transmission. An Enqueue trace event firing should be interpreted - * as only indicating that a higher level protocol has sent a packet to the device. - * - * The m_traceDequeue event is triggered when a packet is removed from the - * transmit queue. Dequeues from the transmit queue can happen in two - * situations: 1) If the underlying channel is idle when - * PointToPointNetDevice::Send is called, a packet is dequeued from the transmit - * queue and immediately transmitted; 2) a packet may be dequeued and - * immediately transmitted in an internal TransmitCompleteEvent that functions - * much like a transmit complete interrupt service routine. An Dequeue trace - * event firing may be viewed as indicating that the PointToPointNetDevice has - * begun transmitting a packet. - * - * \subsection CsmaTracingModelUpperHooks Lower-Level (PHY) Hooks - * - * Similar to the upper level trace hooks, there are trace hooks available at - * the lower levels of the net device. We call these the PHY hooks. These - * events fire from the device methods that talk directly to the - * PointToPointChannel. - * - * The trace source m_dropTrace is called to indicate a packet that is dropped - * by the device. This happens when a packet is discarded as corrupt due to a - * receive error model indication (see ns3::ErrorModel and the associated - * attribute "ReceiveErrorModel"). - * - * The other low-level trace source fires on reception of a packet (see - * ns3::PointToPointNetDevice::m_rxTrace) from the PointToPointChannel. - * - * \section PointToPointModelSummary Point-To-Point Model Summary - * - * The ns3 Point-to-Point model is a simplistic model of a point to point - * serial line link. - * - * Ns-3 Attributes provide a mechanism for setting various parameters in the - * device and channel such as data rates, speed-of-light delays and error model - * selection. Trace hooks are provided in the usual manner with a set of - * upper level hooks corresponding to a transmit queue and used in ASCII - * tracing; and also a set of lower level hooks used in pcap tracing. - */ diff --git a/src/point-to-point/examples/main-attribute-value.cc b/src/point-to-point/examples/main-attribute-value.cc index 2fb0311ac..4d53fedab 100644 --- a/src/point-to-point/examples/main-attribute-value.cc +++ b/src/point-to-point/examples/main-attribute-value.cc @@ -68,7 +68,7 @@ main (int argc, char *argv[]) n0->AddDevice (net0); Ptr q = CreateObject (); - net0->SetQueue(q); + net0->SetQueue (q); // At this point, we have created a single node (Node 0) and a // single PointToPointNetDevice (NetDevice 0) and added a @@ -114,7 +114,7 @@ main (int argc, char *argv[]) NS_LOG_INFO ("2. txQueue limit: " << limit.Get () << " packets"); // Now, let's set it to another value (60 packets) - txQueue->SetAttribute("MaxPackets", UintegerValue (60)); + txQueue->SetAttribute ("MaxPackets", UintegerValue (60)); txQueue->GetAttribute ("MaxPackets", limit); NS_LOG_INFO ("3. txQueue limit changed: " << limit.Get () << " packets"); diff --git a/src/point-to-point/helper/point-to-point-helper.cc b/src/point-to-point/helper/point-to-point-helper.cc index 450648752..a4e1ac564 100644 --- a/src/point-to-point/helper/point-to-point-helper.cc +++ b/src/point-to-point/helper/point-to-point-helper.cc @@ -241,7 +241,7 @@ PointToPointHelper::Install (Ptr a, Ptr b) //use a normal p2p channel, otherwise use a remote channel bool useNormalChannel = true; Ptr channel = 0; - if (MpiInterface::IsEnabled()) + if (MpiInterface::IsEnabled ()) { uint32_t n1SystemId = a->GetSystemId (); uint32_t n2SystemId = b->GetSystemId (); diff --git a/src/point-to-point/model/point-to-point-channel.cc b/src/point-to-point/model/point-to-point-channel.cc index 38b6b62d4..d6a69386a 100644 --- a/src/point-to-point/model/point-to-point-channel.cc +++ b/src/point-to-point/model/point-to-point-channel.cc @@ -59,11 +59,11 @@ PointToPointChannel::PointToPointChannel() } void -PointToPointChannel::Attach(Ptr device) +PointToPointChannel::Attach (Ptr device) { NS_LOG_FUNCTION (this << device); - NS_ASSERT_MSG(m_nDevices < N_DEVICES, "Only two devices permitted"); - NS_ASSERT(device != 0); + NS_ASSERT_MSG (m_nDevices < N_DEVICES, "Only two devices permitted"); + NS_ASSERT (device != 0); m_link[m_nDevices++].m_src = device; // @@ -80,7 +80,7 @@ PointToPointChannel::Attach(Ptr device) } bool -PointToPointChannel::TransmitStart( +PointToPointChannel::TransmitStart ( Ptr p, Ptr src, Time txTime) @@ -88,8 +88,8 @@ PointToPointChannel::TransmitStart( NS_LOG_FUNCTION (this << p << src); NS_LOG_LOGIC ("UID is " << p->GetUid () << ")"); - NS_ASSERT(m_link[0].m_state != INITIALIZING); - NS_ASSERT(m_link[1].m_state != INITIALIZING); + NS_ASSERT (m_link[0].m_state != INITIALIZING); + NS_ASSERT (m_link[1].m_state != INITIALIZING); uint32_t wire = src == m_link[0].m_src ? 0 : 1; @@ -113,7 +113,7 @@ Ptr PointToPointChannel::GetPointToPointDevice (uint32_t i) const { NS_LOG_FUNCTION_NOARGS (); - NS_ASSERT(i < 2); + NS_ASSERT (i < 2); return m_link[i].m_src; } diff --git a/src/point-to-point/model/point-to-point-channel.h b/src/point-to-point/model/point-to-point-channel.h index bf7fa5655..4b0b7776e 100644 --- a/src/point-to-point/model/point-to-point-channel.h +++ b/src/point-to-point/model/point-to-point-channel.h @@ -32,6 +32,7 @@ class PointToPointNetDevice; class Packet; /** + * \ingroup point-to-point * \brief Simple Point To Point Channel. * * This class represents a very simple point to point channel. Think full diff --git a/src/point-to-point/model/point-to-point-net-device.cc b/src/point-to-point/model/point-to-point-net-device.cc index 85719b5ec..ca81c53de 100644 --- a/src/point-to-point/model/point-to-point-net-device.cc +++ b/src/point-to-point/model/point-to-point-net-device.cc @@ -160,26 +160,26 @@ PointToPointNetDevice::~PointToPointNetDevice () } void -PointToPointNetDevice::AddHeader(Ptr p, uint16_t protocolNumber) +PointToPointNetDevice::AddHeader (Ptr p, uint16_t protocolNumber) { NS_LOG_FUNCTION_NOARGS (); PppHeader ppp; - ppp.SetProtocol(EtherToPpp(protocolNumber)); + ppp.SetProtocol (EtherToPpp (protocolNumber)); p->AddHeader (ppp); } bool -PointToPointNetDevice::ProcessHeader(Ptr p, uint16_t& param) +PointToPointNetDevice::ProcessHeader (Ptr p, uint16_t& param) { NS_LOG_FUNCTION_NOARGS (); PppHeader ppp; p->RemoveHeader (ppp); - param = PppToEther(ppp.GetProtocol()); + param = PppToEther (ppp.GetProtocol ()); return true; } void -PointToPointNetDevice::DoDispose() +PointToPointNetDevice::DoDispose () { NS_LOG_FUNCTION_NOARGS (); m_node = 0; @@ -190,14 +190,14 @@ PointToPointNetDevice::DoDispose() } void -PointToPointNetDevice::SetDataRate(DataRate bps) +PointToPointNetDevice::SetDataRate (DataRate bps) { NS_LOG_FUNCTION_NOARGS (); m_bps = bps; } void -PointToPointNetDevice::SetInterframeGap(Time t) +PointToPointNetDevice::SetInterframeGap (Time t) { NS_LOG_FUNCTION_NOARGS (); m_tInterframeGap = t; @@ -214,18 +214,18 @@ PointToPointNetDevice::TransmitStart (Ptr p) // We need to tell the channel that we've started wiggling the wire and // schedule an event that will be executed when the transmission is complete. // - NS_ASSERT_MSG(m_txMachineState == READY, "Must be READY to transmit"); + NS_ASSERT_MSG (m_txMachineState == READY, "Must be READY to transmit"); m_txMachineState = BUSY; m_currentPkt = p; m_phyTxBeginTrace (m_currentPkt); - Time txTime = Seconds (m_bps.CalculateTxTime(p->GetSize())); + Time txTime = Seconds (m_bps.CalculateTxTime (p->GetSize ())); Time txCompleteTime = txTime + m_tInterframeGap; NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << txCompleteTime.GetSeconds () << "sec"); Simulator::Schedule (txCompleteTime, &PointToPointNetDevice::TransmitComplete, this); - bool result = m_channel->TransmitStart(p, this, txTime); + bool result = m_channel->TransmitStart (p, this, txTime); if (result == false) { m_phyTxDropTrace (p); @@ -244,7 +244,7 @@ PointToPointNetDevice::TransmitComplete (void) // is empty, we are done, otherwise we need to start transmitting the // next packet. // - NS_ASSERT_MSG(m_txMachineState == BUSY, "Must be BUSY if transmitting"); + NS_ASSERT_MSG (m_txMachineState == BUSY, "Must be BUSY if transmitting"); m_txMachineState = READY; NS_ASSERT_MSG (m_currentPkt != 0, "PointToPointNetDevice::TransmitComplete(): m_currentPkt zero"); @@ -266,7 +266,7 @@ PointToPointNetDevice::TransmitComplete (void) // m_snifferTrace (p); m_promiscSnifferTrace (p); - TransmitStart(p); + TransmitStart (p); } bool @@ -276,7 +276,7 @@ PointToPointNetDevice::Attach (Ptr ch) m_channel = ch; - m_channel->Attach(this); + m_channel->Attach (this); // // This device is up whenever it is attached to a channel. A better plan @@ -332,7 +332,7 @@ PointToPointNetDevice::Receive (Ptr packet) // there is no difference in what the promisc callback sees and what the // normal receive callback sees. // - ProcessHeader(packet, protocol); + ProcessHeader (packet, protocol); if (!m_promiscCallback.IsNull ()) { @@ -346,7 +346,7 @@ PointToPointNetDevice::Receive (Ptr packet) } Ptr -PointToPointNetDevice::GetQueue(void) const +PointToPointNetDevice::GetQueue (void) const { NS_LOG_FUNCTION_NOARGS (); return m_queue; @@ -360,13 +360,13 @@ PointToPointNetDevice::NotifyLinkUp (void) } void -PointToPointNetDevice::SetIfIndex(const uint32_t index) +PointToPointNetDevice::SetIfIndex (const uint32_t index) { m_ifIndex = index; } uint32_t -PointToPointNetDevice::GetIfIndex(void) const +PointToPointNetDevice::GetIfIndex (void) const { return m_ifIndex; } @@ -443,7 +443,7 @@ PointToPointNetDevice::GetMulticast (Ipv4Address multicastGroup) const Address PointToPointNetDevice::GetMulticast (Ipv6Address addr) const { - NS_LOG_FUNCTION(this << addr); + NS_LOG_FUNCTION (this << addr); return Mac48Address ("33:33:00:00:00:00"); } @@ -460,7 +460,7 @@ PointToPointNetDevice::IsBridge (void) const } bool -PointToPointNetDevice::Send( +PointToPointNetDevice::Send ( Ptr packet, const Address &dest, uint16_t protocolNumber) @@ -483,7 +483,7 @@ PointToPointNetDevice::Send( // Stick a point to point protocol header on the packet in preparation for // shoving it out the door. // - AddHeader(packet, protocolNumber); + AddHeader (packet, protocolNumber); m_macTxTrace (packet); @@ -513,7 +513,7 @@ PointToPointNetDevice::Send( } else { - return m_queue->Enqueue(packet); + return m_queue->Enqueue (packet); } } @@ -601,25 +601,25 @@ PointToPointNetDevice::GetMtu (void) const } uint16_t -PointToPointNetDevice::PppToEther(uint16_t proto) +PointToPointNetDevice::PppToEther (uint16_t proto) { switch(proto) { case 0x0021: return 0x0800; //IPv4 case 0x0057: return 0x86DD; //IPv6 - default: NS_ASSERT_MSG(false, "PPP Protocol number not defined!"); + default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!"); } return 0; } uint16_t -PointToPointNetDevice::EtherToPpp(uint16_t proto) +PointToPointNetDevice::EtherToPpp (uint16_t proto) { switch(proto) { case 0x0800: return 0x0021; //IPv4 case 0x86DD: return 0x0057; //IPv6 - default: NS_ASSERT_MSG(false, "PPP Protocol number not defined!"); + default: NS_ASSERT_MSG (false, "PPP Protocol number not defined!"); } return 0; } diff --git a/src/point-to-point/model/point-to-point-net-device.h b/src/point-to-point/model/point-to-point-net-device.h index 669b7bc67..0cf37d149 100644 --- a/src/point-to-point/model/point-to-point-net-device.h +++ b/src/point-to-point/model/point-to-point-net-device.h @@ -38,6 +38,12 @@ class PointToPointChannel; class ErrorModel; /** + * \defgroup point-to-point PointToPointNetDevice + * This section documents the API of the ns-3 point-to-point module. For a generic functional description, please refer to the ns-3 manual. + */ + +/** + * \ingroup point-to-point * \class PointToPointNetDevice * \brief A Device for a Point to Point Network Link. * @@ -112,7 +118,7 @@ public: * * @returns Ptr to the queue. */ - Ptr GetQueue(void) const; + Ptr GetQueue (void) const; /** * Attach a receive ErrorModel to the PointToPointNetDevice. @@ -123,7 +129,7 @@ public: * @see ErrorModel * @param em Ptr to the ErrorModel. */ - void SetReceiveErrorModel(Ptr em); + void SetReceiveErrorModel (Ptr em); /** * Receive a packet from a connected PointToPointChannel. @@ -140,8 +146,8 @@ public: // The remaining methods are documented in ns3::NetDevice* - virtual void SetIfIndex(const uint32_t index); - virtual uint32_t GetIfIndex(void) const; + virtual void SetIfIndex (const uint32_t index); + virtual uint32_t GetIfIndex (void) const; virtual Ptr GetChannel (void) const; @@ -164,8 +170,8 @@ public: virtual bool IsPointToPoint (void) const; virtual bool IsBridge (void) const; - virtual bool Send(Ptr packet, const Address &dest, uint16_t protocolNumber); - virtual bool SendFrom(Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber); + virtual bool Send (Ptr packet, const Address &dest, uint16_t protocolNumber); + virtual bool SendFrom (Ptr packet, const Address& source, const Address& dest, uint16_t protocolNumber); virtual Ptr GetNode (void) const; virtual void SetNode (Ptr node); @@ -203,7 +209,7 @@ private: * \param p packet * \param protocolNumber protocol number */ - void AddHeader(Ptr p, uint16_t protocolNumber); + void AddHeader (Ptr p, uint16_t protocolNumber); /** * Removes, from a packet of data, all headers and trailers that @@ -213,7 +219,7 @@ private: * \return Returns true if the packet should be forwarded up the * protocol stack. */ - bool ProcessHeader(Ptr p, uint16_t& param); + bool ProcessHeader (Ptr p, uint16_t& param); /** * Start Sending a Packet Down the Wire. @@ -238,7 +244,7 @@ private: * The TransmitComplete method is used internally to finish the process * of sending a packet out on the channel. */ - void TransmitComplete(void); + void TransmitComplete (void); void NotifyLinkUp (void); @@ -450,14 +456,14 @@ private: * \param protocol A PPP protocol number * \return The corresponding Ethernet protocol number */ - static uint16_t PppToEther(uint16_t protocol); + static uint16_t PppToEther (uint16_t protocol); /** * \brief Ethernet to PPP protocol number mapping * \param protocol An Ethernet protocol number * \return The corresponding PPP protocol number */ - static uint16_t EtherToPpp(uint16_t protocol); + static uint16_t EtherToPpp (uint16_t protocol); }; } // namespace ns3 diff --git a/src/point-to-point/model/point-to-point-remote-channel.h b/src/point-to-point/model/point-to-point-remote-channel.h index 709b94a79..450cd1553 100644 --- a/src/point-to-point/model/point-to-point-remote-channel.h +++ b/src/point-to-point/model/point-to-point-remote-channel.h @@ -29,6 +29,9 @@ namespace ns3 { +/** + * \ingroup point-to-point + */ class PointToPointRemoteChannel : public PointToPointChannel { public: diff --git a/src/point-to-point/model/ppp-header.cc b/src/point-to-point/model/ppp-header.cc index c34abdacd..d1b506ccd 100644 --- a/src/point-to-point/model/ppp-header.cc +++ b/src/point-to-point/model/ppp-header.cc @@ -67,7 +67,7 @@ PppHeader::Print (std::ostream &os) const proto = "IPv6 (0x0057)"; break; default: - NS_ASSERT_MSG(false, "PPP Protocol number not defined!"); + NS_ASSERT_MSG (false, "PPP Protocol number not defined!"); } os << "Point-to-Point Protocol: " << proto; } @@ -88,7 +88,7 @@ uint32_t PppHeader::Deserialize (Buffer::Iterator start) { m_protocol = start.ReadNtohU16 (); - return GetSerializedSize(); + return GetSerializedSize (); } void diff --git a/src/point-to-point/model/ppp-header.h b/src/point-to-point/model/ppp-header.h index 1224b0fca..160602171 100644 --- a/src/point-to-point/model/ppp-header.h +++ b/src/point-to-point/model/ppp-header.h @@ -24,6 +24,7 @@ namespace ns3 { /** + * \ingroup point-to-point * \brief Packet header for PPP * * This class can be used to add a header to PPP packet. Currently we do not @@ -72,7 +73,7 @@ public: * * \param protocol the protocol type being carried */ - void SetProtocol(uint16_t protocol); + void SetProtocol (uint16_t protocol); /** * \brief Get the protocol type carried by this PPP packet @@ -81,7 +82,7 @@ public: * * \return the protocol type being carried */ - uint16_t GetProtocol(void); + uint16_t GetProtocol (void); private: diff --git a/src/propagation/examples/main-propagation-loss.cc b/src/propagation/examples/main-propagation-loss.cc index 05130978e..e7cac50d8 100644 --- a/src/propagation/examples/main-propagation-loss.cc +++ b/src/propagation/examples/main-propagation-loss.cc @@ -35,16 +35,16 @@ using namespace ns3; /// Round a double number to the given precision. e.g. dround(0.234, 0.1) = 0.2 /// and dround(0.257, 0.1) = 0.3 -static double dround(double number, double precision) +static double dround (double number, double precision) { number /= precision; if (number >= 0) { - number = floor(number + 0.5); + number = floor (number + 0.5); } else { - number = ceil(number - 0.5); + number = ceil (number - 0.5); } number *= precision; return number; @@ -58,15 +58,15 @@ TestDeterministic (Ptr model) Gnuplot plot; - plot.AppendExtra("set xlabel 'Distance'"); - plot.AppendExtra("set ylabel 'rxPower (dBm)'"); - plot.AppendExtra("set key top right"); + plot.AppendExtra ("set xlabel 'Distance'"); + plot.AppendExtra ("set ylabel 'rxPower (dBm)'"); + plot.AppendExtra ("set key top right"); double txPowerDbm = +20; // dBm Gnuplot2dDataset dataset; - dataset.SetStyle(Gnuplot2dDataset::LINES); + dataset.SetStyle (Gnuplot2dDataset::LINES); { a->SetPosition (Vector (0.0, 0.0, 0.0)); @@ -78,7 +78,7 @@ TestDeterministic (Ptr model) // CalcRxPower() returns dBm. double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b); - dataset.Add(distance, rxPowerDbm); + dataset.Add (distance, rxPowerDbm); Simulator::Stop (Seconds (1.0)); Simulator::Run (); @@ -87,11 +87,11 @@ TestDeterministic (Ptr model) std::ostringstream os; os << "txPower " << txPowerDbm << "dBm"; - dataset.SetTitle(os.str()); + dataset.SetTitle (os.str ()); - plot.AddDataset(dataset); + plot.AddDataset (dataset); - plot.AddDataset( Gnuplot2dFunction("-94 dBm CSThreshold", "-94.0") ); + plot.AddDataset ( Gnuplot2dFunction ("-94 dBm CSThreshold", "-94.0") ); return plot; } @@ -104,23 +104,23 @@ TestProbabilistic (Ptr model, unsigned int samples = 10000 Gnuplot plot; - plot.AppendExtra("set xlabel 'Distance'"); - plot.AppendExtra("set ylabel 'rxPower (dBm)'"); - plot.AppendExtra("set zlabel 'Probability' offset 0,+10"); - plot.AppendExtra("set view 50, 120, 1.0, 1.0"); - plot.AppendExtra("set key top right"); + plot.AppendExtra ("set xlabel 'Distance'"); + plot.AppendExtra ("set ylabel 'rxPower (dBm)'"); + plot.AppendExtra ("set zlabel 'Probability' offset 0,+10"); + plot.AppendExtra ("set view 50, 120, 1.0, 1.0"); + plot.AppendExtra ("set key top right"); - plot.AppendExtra("set ticslevel 0"); - plot.AppendExtra("set xtics offset -0.5,0"); - plot.AppendExtra("set ytics offset 0,-0.5"); - plot.AppendExtra("set xrange [100:]"); + plot.AppendExtra ("set ticslevel 0"); + plot.AppendExtra ("set xtics offset -0.5,0"); + plot.AppendExtra ("set ytics offset 0,-0.5"); + plot.AppendExtra ("set xrange [100:]"); double txPowerDbm = +20; // dBm Gnuplot3dDataset dataset; - dataset.SetStyle("with linespoints"); - dataset.SetExtra("pointtype 3 pointsize 0.5"); + dataset.SetStyle ("with linespoints"); + dataset.SetExtra ("pointtype 3 pointsize 0.5"); typedef std::map rxPowerMapType; @@ -139,7 +139,7 @@ TestProbabilistic (Ptr model, unsigned int samples = 10000 { // CalcRxPower() returns dBm. double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b); - rxPowerDbm = dround(rxPowerDbm, 1.0); + rxPowerDbm = dround (rxPowerDbm, 1.0); rxPowerMap[ rxPowerDbm ]++; @@ -147,28 +147,28 @@ TestProbabilistic (Ptr model, unsigned int samples = 10000 Simulator::Run (); } - for (rxPowerMapType::const_iterator i = rxPowerMap.begin(); - i != rxPowerMap.end(); ++i) + for (rxPowerMapType::const_iterator i = rxPowerMap.begin (); + i != rxPowerMap.end (); ++i) { - dataset.Add(distance, i->first, (double)i->second / (double)samples); + dataset.Add (distance, i->first, (double)i->second / (double)samples); } - dataset.AddEmptyLine(); + dataset.AddEmptyLine (); } } std::ostringstream os; os << "txPower " << txPowerDbm << "dBm"; - dataset.SetTitle(os.str()); + dataset.SetTitle (os.str ()); - plot.AddDataset(dataset); + plot.AddDataset (dataset); return plot; } static Gnuplot TestDeterministicByTime (Ptr model, - Time timeStep = Seconds(0.001), - Time timeTotal = Seconds(1.0), + Time timeStep = Seconds (0.001), + Time timeTotal = Seconds (1.0), double distance = 100.0) { Ptr a = CreateObject (); @@ -176,28 +176,28 @@ TestDeterministicByTime (Ptr model, Gnuplot plot; - plot.AppendExtra("set xlabel 'Time (s)'"); - plot.AppendExtra("set ylabel 'rxPower (dBm)'"); - plot.AppendExtra("set key center right"); + plot.AppendExtra ("set xlabel 'Time (s)'"); + plot.AppendExtra ("set ylabel 'rxPower (dBm)'"); + plot.AppendExtra ("set key center right"); double txPowerDbm = +20; // dBm Gnuplot2dDataset dataset; - dataset.SetStyle(Gnuplot2dDataset::LINES); + dataset.SetStyle (Gnuplot2dDataset::LINES); { a->SetPosition (Vector (0.0, 0.0, 0.0)); b->SetPosition (Vector (distance, 0.0, 0.0)); - Time start = Simulator::Now(); - while( Simulator::Now() < start + timeTotal ) + Time start = Simulator::Now (); + while( Simulator::Now () < start + timeTotal ) { // CalcRxPower() returns dBm. double rxPowerDbm = model->CalcRxPower (txPowerDbm, a, b); - Time elapsed = Simulator::Now() - start; - dataset.Add(elapsed.GetSeconds(), rxPowerDbm); + Time elapsed = Simulator::Now () - start; + dataset.Add (elapsed.GetSeconds (), rxPowerDbm); Simulator::Stop (timeStep); Simulator::Run (); @@ -206,107 +206,107 @@ TestDeterministicByTime (Ptr model, std::ostringstream os; os << "txPower " << txPowerDbm << "dBm"; - dataset.SetTitle(os.str()); + dataset.SetTitle (os.str ()); - plot.AddDataset(dataset); + plot.AddDataset (dataset); - plot.AddDataset( Gnuplot2dFunction("-94 dBm CSThreshold", "-94.0") ); + plot.AddDataset ( Gnuplot2dFunction ("-94 dBm CSThreshold", "-94.0") ); return plot; } int main (int argc, char *argv[]) { - GnuplotCollection gnuplots("main-propagation-loss.pdf"); + GnuplotCollection gnuplots ("main-propagation-loss.pdf"); { Ptr friis = CreateObject (); - Gnuplot plot = TestDeterministic(friis); - plot.SetTitle("ns3::FriisPropagationLossModel (Default Parameters)"); - gnuplots.AddPlot(plot); + Gnuplot plot = TestDeterministic (friis); + plot.SetTitle ("ns3::FriisPropagationLossModel (Default Parameters)"); + gnuplots.AddPlot (plot); } { Ptr log = CreateObject (); - log->SetAttribute("Exponent", DoubleValue (2.5)); + log->SetAttribute ("Exponent", DoubleValue (2.5)); - Gnuplot plot = TestDeterministic(log); - plot.SetTitle("ns3::LogDistancePropagationLossModel (Exponent = 2.5)"); - gnuplots.AddPlot(plot); + Gnuplot plot = TestDeterministic (log); + plot.SetTitle ("ns3::LogDistancePropagationLossModel (Exponent = 2.5)"); + gnuplots.AddPlot (plot); } { Ptr random = CreateObject (); - random->SetAttribute("Variable", RandomVariableValue(ExponentialVariable(50.0))); + random->SetAttribute ("Variable", RandomVariableValue (ExponentialVariable (50.0))); - Gnuplot plot = TestDeterministic(random); - plot.SetTitle("ns3::RandomPropagationLossModel with Exponential Distribution"); - gnuplots.AddPlot(plot); + Gnuplot plot = TestDeterministic (random); + plot.SetTitle ("ns3::RandomPropagationLossModel with Exponential Distribution"); + gnuplots.AddPlot (plot); } { Ptr jakes = CreateObject (); // doppler frequency shift for 5.15 GHz at 100 km/h - jakes->SetAttribute("DopplerFreq", DoubleValue(477.9)); + jakes->SetAttribute ("DopplerFreq", DoubleValue (477.9)); - Gnuplot plot = TestDeterministicByTime (jakes, Seconds(0.001), Seconds(1.0)); - plot.SetTitle("ns3::JakesPropagationLossModel (with 477.9 Hz shift and 1 millisec resolution)"); - gnuplots.AddPlot(plot); + Gnuplot plot = TestDeterministicByTime (jakes, Seconds (0.001), Seconds (1.0)); + plot.SetTitle ("ns3::JakesPropagationLossModel (with 477.9 Hz shift and 1 millisec resolution)"); + gnuplots.AddPlot (plot); } { Ptr jakes = CreateObject (); // doppler frequency shift for 5.15 GHz at 100 km/h - jakes->SetAttribute("DopplerFreq", DoubleValue(477.9)); + jakes->SetAttribute ("DopplerFreq", DoubleValue (477.9)); - Gnuplot plot = TestDeterministicByTime (jakes, Seconds(0.0001), Seconds(0.1)); - plot.SetTitle("ns3::JakesPropagationLossModel (with 477.9 Hz shift and 0.1 millisec resolution)"); - gnuplots.AddPlot(plot); + Gnuplot plot = TestDeterministicByTime (jakes, Seconds (0.0001), Seconds (0.1)); + plot.SetTitle ("ns3::JakesPropagationLossModel (with 477.9 Hz shift and 0.1 millisec resolution)"); + gnuplots.AddPlot (plot); } { Ptr log3 = CreateObject (); - Gnuplot plot = TestDeterministic(log3); - plot.SetTitle("ns3::ThreeLogDistancePropagationLossModel (Defaults)"); - gnuplots.AddPlot(plot); + Gnuplot plot = TestDeterministic (log3); + plot.SetTitle ("ns3::ThreeLogDistancePropagationLossModel (Defaults)"); + gnuplots.AddPlot (plot); } { Ptr log3 = CreateObject (); // more prominent example values: - log3->SetAttribute("Exponent0", DoubleValue(1.0)); - log3->SetAttribute("Exponent1", DoubleValue(3.0)); - log3->SetAttribute("Exponent2", DoubleValue(10.0)); + log3->SetAttribute ("Exponent0", DoubleValue (1.0)); + log3->SetAttribute ("Exponent1", DoubleValue (3.0)); + log3->SetAttribute ("Exponent2", DoubleValue (10.0)); - Gnuplot plot = TestDeterministic(log3); - plot.SetTitle("ns3::ThreeLogDistancePropagationLossModel (Exponents 1.0, 3.0 and 10.0)"); - gnuplots.AddPlot(plot); + Gnuplot plot = TestDeterministic (log3); + plot.SetTitle ("ns3::ThreeLogDistancePropagationLossModel (Exponents 1.0, 3.0 and 10.0)"); + gnuplots.AddPlot (plot); } { Ptr nak = CreateObject (); - Gnuplot plot = TestProbabilistic(nak); - plot.SetTitle("ns3::NakagamiPropagationLossModel (Default Parameters)"); - gnuplots.AddPlot(plot); + Gnuplot plot = TestProbabilistic (nak); + plot.SetTitle ("ns3::NakagamiPropagationLossModel (Default Parameters)"); + gnuplots.AddPlot (plot); } { Ptr log3 = CreateObject (); Ptr nak = CreateObject (); - log3->SetNext(nak); + log3->SetNext (nak); - Gnuplot plot = TestProbabilistic(log3); - plot.SetTitle("ns3::ThreeLogDistancePropagationLossModel and ns3::NakagamiPropagationLossModel (Default Parameters)"); - gnuplots.AddPlot(plot); + Gnuplot plot = TestProbabilistic (log3); + plot.SetTitle ("ns3::ThreeLogDistancePropagationLossModel and ns3::NakagamiPropagationLossModel (Default Parameters)"); + gnuplots.AddPlot (plot); } - gnuplots.GenerateOutput(std::cout); + gnuplots.GenerateOutput (std::cout); // produce clean valgrind Simulator::Destroy (); diff --git a/src/propagation/model/jakes-propagation-loss-model.cc b/src/propagation/model/jakes-propagation-loss-model.cc index 863df503e..881bb5764 100644 --- a/src/propagation/model/jakes-propagation-loss-model.cc +++ b/src/propagation/model/jakes-propagation-loss-model.cc @@ -114,7 +114,7 @@ JakesPropagationLossModel::PathCoefficients::GetLoss (Ptrm_amp[j].real * cos (m_phases[i][j]); fading.imag += jakes->m_amp[j].imag * cos (m_phases[i][j]); - norm += sqrt(pow (jakes->m_amp[j].real, 2) + pow(jakes->m_amp[j].imag, 2)); + norm += sqrt (pow (jakes->m_amp[j].real, 2) + pow (jakes->m_amp[j].imag, 2)); } coef.real += fading.real; coef.imag += fading.imag; @@ -198,13 +198,13 @@ JakesPropagationLossModel::SetNOscillators (uint8_t nOscillators) delete [] m_amp; uint16_t N = 4 * m_nOscillators + 2; m_amp = new ComplexNumber[m_nOscillators + 1]; - m_amp[0].real = 2.0 * sqrt(2.0 / N) * cos (PI / 4.0); - m_amp[0].imag = 2.0 * sqrt(2.0 / N) * sin (PI / 4.0); + m_amp[0].real = 2.0 * sqrt (2.0 / N) * cos (PI / 4.0); + m_amp[0].imag = 2.0 * sqrt (2.0 / N) * sin (PI / 4.0); for (uint8_t i = 1; i <= m_nOscillators; i++) { double beta = PI * (double)i / m_nOscillators; - m_amp[i].real = 4.0 * cos (beta) / sqrt(N); - m_amp[i].imag = 4.0 * sin (beta) / sqrt(N); + m_amp[i].real = 4.0 * cos (beta) / sqrt (N); + m_amp[i].imag = 4.0 * sin (beta) / sqrt (N); } } diff --git a/src/propagation/model/propagation-loss-model.cc b/src/propagation/model/propagation-loss-model.cc index 06f90b229..11e57797f 100644 --- a/src/propagation/model/propagation-loss-model.cc +++ b/src/propagation/model/propagation-loss-model.cc @@ -182,7 +182,7 @@ FriisPropagationLossModel::GetLambda (void) const double FriisPropagationLossModel::DbmToW (double dbm) const { - double mw = pow(10.0,dbm/10.0); + double mw = pow (10.0,dbm/10.0); return mw / 1000.0; } @@ -551,7 +551,7 @@ ThreeLogDistancePropagationLossModel::DoCalcRxPower (double txPowerDbm, Ptr b) const { double distance = a->GetDistanceFrom (b); - NS_ASSERT(distance >= 0); + NS_ASSERT (distance >= 0); // See doxygen comments for the formula and explanation @@ -564,20 +564,20 @@ ThreeLogDistancePropagationLossModel::DoCalcRxPower (double txPowerDbm, else if (distance < m_distance1) { pathLossDb = m_referenceLoss - + 10 * m_exponent0 * log10(distance / m_distance0); + + 10 * m_exponent0 * log10 (distance / m_distance0); } else if (distance < m_distance2) { pathLossDb = m_referenceLoss - + 10 * m_exponent0 * log10(m_distance1 / m_distance0) - + 10 * m_exponent1 * log10(distance / m_distance1); + + 10 * m_exponent0 * log10 (m_distance1 / m_distance0) + + 10 * m_exponent1 * log10 (distance / m_distance1); } else { pathLossDb = m_referenceLoss - + 10 * m_exponent0 * log10(m_distance1 / m_distance0) - + 10 * m_exponent1 * log10(m_distance2 / m_distance1) - + 10 * m_exponent2 * log10(distance / m_distance2); + + 10 * m_exponent0 * log10 (m_distance1 / m_distance0) + + 10 * m_exponent1 * log10 (m_distance2 / m_distance1) + + 10 * m_exponent2 * log10 (distance / m_distance2); } NS_LOG_DEBUG ("ThreeLogDistance distance=" << distance << "m, " << @@ -638,7 +638,7 @@ NakagamiPropagationLossModel::DoCalcRxPower (double txPowerDbm, // select m parameter double distance = a->GetDistanceFrom (b); - NS_ASSERT(distance >= 0); + NS_ASSERT (distance >= 0); double m; if (distance < m_distance1) @@ -656,24 +656,24 @@ NakagamiPropagationLossModel::DoCalcRxPower (double txPowerDbm, // the current power unit is dBm, but Watt is put into the Nakagami / // Rayleigh distribution. - double powerW = pow(10, (txPowerDbm - 30) / 10); + double powerW = pow (10, (txPowerDbm - 30) / 10); double resultPowerW; // switch between Erlang- and Gamma distributions: this is only for // speed. (Gamma is equal to Erlang for any positive integer m.) - unsigned int int_m = static_cast(floor(m)); + unsigned int int_m = static_cast(floor (m)); if (int_m == m) { - resultPowerW = m_erlangRandomVariable.GetValue(int_m, powerW / m); + resultPowerW = m_erlangRandomVariable.GetValue (int_m, powerW / m); } else { - resultPowerW = m_gammaRandomVariable.GetValue(m, powerW / m); + resultPowerW = m_gammaRandomVariable.GetValue (m, powerW / m); } - double resultPowerDbm = 10 * log10(resultPowerW) + 30; + double resultPowerDbm = 10 * log10 (resultPowerW) + 30; NS_LOG_DEBUG ("Nakagami distance=" << distance << "m, " << "power=" << powerW <<"W, " << @@ -760,7 +760,7 @@ MatrixPropagationLossModel::SetLoss (Ptr ma, Ptr m { NS_ASSERT (ma != 0 && mb != 0); - MobilityPair p = std::make_pair(ma, mb); + MobilityPair p = std::make_pair (ma, mb); std::map::iterator i = m_loss.find (p); if (i == m_loss.end ()) diff --git a/src/spectrum/model/aloha-noack-net-device.cc b/src/spectrum/model/aloha-noack-net-device.cc index 0bc39b14f..fec88a508 100644 --- a/src/spectrum/model/aloha-noack-net-device.cc +++ b/src/spectrum/model/aloha-noack-net-device.cc @@ -42,13 +42,13 @@ std::ostream& operator<< (std::ostream& os, AlohaNoackNetDevice::State state) switch (state) { case AlohaNoackNetDevice::IDLE: - os << "IDLE" ; + os << "IDLE"; break; case AlohaNoackNetDevice::TX: - os << "TX" ; + os << "TX"; break; case AlohaNoackNetDevice::RX: - os << "RX" ; + os << "RX"; break; } return os; diff --git a/src/spectrum/model/spectrum-value.cc b/src/spectrum/model/spectrum-value.cc index 7273dd1ff..f98793205 100644 --- a/src/spectrum/model/spectrum-value.cc +++ b/src/spectrum/model/spectrum-value.cc @@ -403,7 +403,7 @@ operator << (std::ostream& os, const SpectrumValue& pvf) Values::const_iterator it1 = pvf.ConstValuesBegin (); while (it1 != pvf.ConstValuesEnd ()) { - os << *it1 << " " ; + os << *it1 << " "; ++it1; } return os; @@ -649,94 +649,6 @@ SpectrumValue:: operator= (double rhs) } -bool -SpectrumValue::operator== (const SpectrumValue& rhs) const -{ - Values::const_iterator it1 = this->m_values.begin (); - Values::const_iterator it2 = rhs.m_values.begin (); - - while ( it1 != this->m_values.end () && it2 != rhs.m_values.end () ) - { - if ( *it1 != *it2 ) - { - return false; - } - else - { - ++it1; - ++it2; - } - } - - if ( it1 == this->m_values.end () && it2 == rhs.m_values.end () ) - { - return true; - } - else - { - return false; - } -} - -bool -SpectrumValue::operator< (const SpectrumValue &rhs) const -{ - Values::const_iterator it1 = this->m_values.begin (); - Values::const_iterator it2 = rhs.m_values.begin (); - - while ( it1 != this->m_values.end () && it2 != rhs.m_values.end () ) - { - if ( *it1 >= *it2 ) - { - return false; - } - else - { - ++it1; - ++it2; - } - } - - if ( it1 == this->m_values.end () && it2 == rhs.m_values.end () ) - { - return true; - } - else - { - return false; - } -} - -bool -SpectrumValue::operator> (const SpectrumValue &rhs) const -{ - Values::const_iterator it1 = this->m_values.begin (); - Values::const_iterator it2 = rhs.m_values.begin (); - - while ( it1 != this->m_values.end () && it2 != rhs.m_values.end () ) - { - if ( *it1 <= *it2 ) - { - return false; - } - else - { - ++it1; - ++it2; - } - } - - if ( it1 == this->m_values.end () && it2 == rhs.m_values.end () ) - { - return true; - } - else - { - return false; - } -} - - SpectrumValue SpectrumValue:: operator<< (int n) const diff --git a/src/spectrum/model/spectrum-value.h b/src/spectrum/model/spectrum-value.h index 9f19bff07..45b378fe0 100644 --- a/src/spectrum/model/spectrum-value.h +++ b/src/spectrum/model/spectrum-value.h @@ -402,36 +402,6 @@ public: - /** - * Compare each component, one by one - * - * @param rhs Right Hand Side of the operator - * - * @return True if this == rhs - * False if this != rhs - */ - bool operator== (const SpectrumValue& rhs) const; - - /** - * Compare each component, one by one - * - * @param rhs Right Hand Side of the operator - * - * @return True if this < rhs - * False if this >= rhs - */ - bool operator< (const SpectrumValue &rhs) const; - - /** - * Compare each component, one by one - * - * @param rhs Right Hand Side of the operator - * - * @return True if this > rhs - * False if this <= rhs - */ - bool operator> (const SpectrumValue &rhs) const; - /** * * @param x the operand diff --git a/src/spectrum/test/spectrum-test.h b/src/spectrum/test/spectrum-test.h index d2033b8da..a2ee80dd4 100644 --- a/src/spectrum/test/spectrum-test.h +++ b/src/spectrum/test/spectrum-test.h @@ -56,7 +56,7 @@ || (i->fc > j->fc + (tol)) || (i->fc < j->fc - (tol)) \ || (i->fh > j->fh + (tol)) || (i->fh < j->fh - (tol))) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream indexStream; \ indexStream << "[" << k << "]"; \ std::ostringstream msgStream; \ @@ -117,7 +117,7 @@ { \ if ((*i) > (*j) + (tol) || (*i) < (*j) - (tol)) \ { \ - if (gBreakOnFailure) { *(int *)0 = 0;} \ + if (gBreakOnFailure) { *(int *)0 = 0; } \ std::ostringstream indexStream; \ indexStream << "[" << k << "]"; \ std::ostringstream msgStream; \ diff --git a/src/stats/doc/Stat-framework-arch.png b/src/stats/doc/Stat-framework-arch.png new file mode 100644 index 000000000..a01f662ed Binary files /dev/null and b/src/stats/doc/Stat-framework-arch.png differ diff --git a/src/stats/doc/Wifi-default.png b/src/stats/doc/Wifi-default.png new file mode 100644 index 000000000..3475f6a53 Binary files /dev/null and b/src/stats/doc/Wifi-default.png differ diff --git a/src/stats/doc/statistics.rst b/src/stats/doc/statistics.rst index 4441cc3f2..3685a9760 100644 --- a/src/stats/doc/statistics.rst +++ b/src/stats/doc/statistics.rst @@ -1,11 +1,359 @@ .. include:: replace.txt -Statistics ----------- +Statistical Framework +--------------------- + +This chapter outlines work on simulation data collection and the +statistical framework for ns-3. + +The source code for the statistical framework lives in the directory +``src/stats``. + +Goals +***** + +Primary objectives for this effort are the following: + +* Provide functionality to record, calculate, and present data and statistics for analysis of network simulations. +* Boost simulation performance by reducing the need to generate extensive trace logs in order to collect data. +* Enable simulation control via online statistics, e.g. terminating simulations or repeating trials. + +Derived sub-goals and other target features include the following: + +* Integration with the existing ns-3 tracing system as the basic instrumentation framework of the internal simulation engine, e.g. network stacks, net devices, and channels. +* Enabling users to utilize the statistics framework without requiring use of the tracing system. +* Helping users create, aggregate, and analyze data over multiple trials. +* Support for user created instrumentation, e.g. of application specific events and measures. +* Low memory and CPU overhead when the package is not in use. +* Leveraging existing analysis and output tools as much as possible. The framework may provide some basic statistics, but the focus is on collecting data and making it accessible for manipulation in established tools. +* Eventual support for distributing independent replications is important but not included in the first round of features. + +Overview +******** + +The statistics framework includes the following features: + +* The core framework and two basic data collectors: A counter, and a min/max/avg/total observer. +* Extensions of those to easily work with times and packets. +* Plaintext output formatted for omnetpp. +* Database output using sqlite3, a standalone, lightweight, high performance SQL engine. +* Mandatory and open ended metadata for describing and working with runs. +* An example based on the notional experiment of examining the properties of NS-3's default ad hoc WiFi performance. It incorporates the following: + + * Constructs of a two node ad hoc WiFi network, with the nodes a parameterized distance apart. + * UDP traffic source and sink applications with slightly different behavior and measurement hooks than the stock classes. + * Data collection from the NS-3 core via existing trace signals, in particular data on frames transmitted and received by the WiFi MAC objects. + * Instrumentation of custom applications by connecting new trace signals to the stat framework, as well as via direct updates. Information is recorded about total packets sent and received, bytes transmitted, and end-to-end delay. + * An example of using packet tags to track end-to-end delay. + * A simple control script which runs a number of trials of the experiment at varying distances and queries the resulting database to produce a graph using GNUPlot. + +To-Do +***** + +High priority items include: + +* Inclusion of online statistics code, e.g. for memory efficient confidence intervals. +* Provisions in the data collectors for terminating runs, i.e. when a threshold or confidence is met. +* Data collectors for logging samples over time, and output to the various formats. +* Demonstrate writing simple cyclic event glue to regularly poll some value. + +Each of those should prove straightforward to incorporate in the current framework. + +Approach +******** + +The framework is based around the following core principles: + +* One experiment trial is conducted by one instance of a simulation program, whether in parallel or serially. +* A control script executes instances of the simulation, varying parameters as necessary. +* Data is collected and stored for plotting and analysis using external scripts and existing tools. +* Measures within the ns-3 core are taken by connecting the stat framework to existing trace signals. +* Trace signals or direct manipulation of the framework may be used to instrument custom simulation code. + +Those basic components of the framework and their interactions are depicted in the following figure. + +.. image:: figures/Stat-framework-arch.png + + +Example +******* + +This section goes through the process of constructing an experiment in the framework and producing data for analysis (graphs) from it, demonstrating the structure and API along the way. + +Question +++++++++ + +''What is the (simulated) performance of ns-3's WiFi NetDevices (using the default settings)? How far apart can wireless nodes be in a simulation before they cannot communicate reliably?'' + +* Hypothesis: Based on knowledge of real life performance, the nodes should communicate reasonably well to at least 100m apart. Communication beyond 200m shouldn't be feasible. + +Although not a very common question in simulation contexts, this is an important property of which simulation developers should have a basic understanding. It is also a common study done on live hardware. + +Simulation Program +++++++++++++++++++ + +The first thing to do in implementing this experiment is developing the simulation program. The code for this example can be found in ``examples/stats/wifi-example-sim.cc``. It does the following main steps. + +* Declaring parameters and parsing the command line using ``ns3::CommandLine``. + + :: + + CommandLine cmd; + cmd.AddValue("distance", "Distance apart to place nodes (in meters).", + distance); + cmd.AddValue("format", "Format to use for data output.", + format); + cmd.AddValue("experiment", "Identifier for experiment.", + experiment); + cmd.AddValue("strategy", "Identifier for strategy.", + strategy); + cmd.AddValue("run", "Identifier for run.", + runID); + cmd.Parse (argc, argv); + +* Creating nodes and network stacks using ``ns3::NodeContainer``, ``ns3::WiFiHelper``, and ``ns3::InternetStackHelper``. + + :: + + NodeContainer nodes; + nodes.Create(2); + + WifiHelper wifi; + wifi.SetMac("ns3::AdhocWifiMac"); + wifi.SetPhy("ns3::WifiPhy"); + NetDeviceContainer nodeDevices = wifi.Install(nodes); + + InternetStackHelper internet; + internet.Install(nodes); + Ipv4AddressHelper ipAddrs; + ipAddrs.SetBase("192.168.0.0", "255.255.255.0"); + ipAddrs.Assign(nodeDevices); + +* Positioning the nodes using ``ns3::MobilityHelper``. By default the nodes have static mobility and won't move, but must be positioned the given distance apart. There are several ways to do this; it is done here using ``ns3::ListPositionAllocator``, which draws positions from a given list. + + :: + + MobilityHelper mobility; + Ptr positionAlloc = + CreateObject(); + positionAlloc->Add(Vector(0.0, 0.0, 0.0)); + positionAlloc->Add(Vector(0.0, distance, 0.0)); + mobility.SetPositionAllocator(positionAlloc); + mobility.Install(nodes); + +* Installing a traffic generator and a traffic sink. The stock ``Applications`` could be used, but the example includes custom objects in ``src/test/test02-apps.(cc|h)``. These have a simple behavior, generating a given number of packets spaced at a given interval. As there is only one of each they are installed manually; for a larger set the ``ns3::ApplicationHelper`` class could be used. The commented-out ``Config::Set`` line changes the destination of the packets, set to broadcast by default in this example. Note that in general WiFi may have different performance for broadcast and unicast frames due to different rate control and MAC retransmission policies. + + :: + + Ptr appSource = NodeList::GetNode(0); + Ptr sender = CreateObject(); + appSource->AddApplication(sender); + sender->Start(Seconds(1)); + + Ptr appSink = NodeList::GetNode(1); + Ptr receiver = CreateObject(); + appSink->AddApplication(receiver); + receiver->Start(Seconds(0)); + + // Config::Set("/NodeList/*/ApplicationList/*/$Sender/Destination", + // Ipv4AddressValue("192.168.0.2")); + +* Configuring the data and statistics to be collected. The basic paradigm is that an ``ns3::DataCollector`` object is created to hold information about this particular run, to which observers and calculators are attached to actually generate data. Importantly, run information includes labels for the ''experiment'', ''strategy'', ''input'', and ''run''. These are used to later identify and easily group data from multiple trials. + + * The experiment is the study of which this trial is a member. Here it is on WiFi performance and distance. + * The strategy is the code or parameters being examined in this trial. In this example it is fixed, but an obvious extension would be to investigate different WiFi bit rates, each of which would be a different strategy. + * The input is the particular problem given to this trial. Here it is simply the distance between the two nodes. + * The runID is a unique identifier for this trial with which it's information is tagged for identification in later analysis. If no run ID is given the example program makes a (weak) run ID using the current time. + + Those four pieces of metadata are required, but more may be desired. They may be added to the record using the ``ns3::DataCollector::AddMetadata()`` method. + + :: + + DataCollector data; + data.DescribeRun(experiment, + strategy, + input, + runID); + data.AddMetadata("author", "tjkopena"); + + Actual observation and calculating is done by ``ns3::DataCalculator`` objects, of which several different types exist. These are created by the simulation program, attached to reporting or sampling code, and then registered with the ``ns3::DataCollector`` so they will be queried later for their output. One easy observation mechanism is to use existing trace sources, for example to instrument objects in the ns-3 core without changing their code. Here a counter is attached directly to a trace signal in the WiFi MAC layer on the target node. + + :: + + Ptr totalRx = + CreateObject(); + totalRx->SetKey("wifi-rx-frames"); + Config::Connect("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Rx", + MakeCallback(&PacketCounterCalculator::FrameUpdate, + totalRx)); + data.AddDataCalculator(totalRx); + + Calculators may also be manipulated directly. In this example, a counter is created and passed to the traffic sink application to be updated when packets are received. + + :: + + Ptr > appRx = + CreateObject >(); + appRx->SetKey("receiver-rx-packets"); + receiver->SetCounter(appRx); + data.AddDataCalculator(appRx); + + To increment the count, the sink's packet processing code then calls one of the calculator's update methods. + + :: + + m_calc->Update(); + + The program includes several other examples as well, using both the primitive calculators such as ``ns3::CounterCalculator`` and those adapted for observing packets and times. In ``src/test/test02-apps.(cc|h)`` it also creates a simple custom tag which it uses to track end-to-end delay for generated packets, reporting results to a ``ns3::TimeMinMaxAvgTotalCalculator`` data calculator. + +* Running the simulation, which is very straightforward once constructed. + + :: + + Simulator::Run(); + +* Generating either omnetpp or sqlite output, depending on the command line arguments. To do this a ``ns3::DataOutputInterface`` object is created and configured. The specific type of this will determine the output format. This object is then given the ``ns3::DataCollector`` object which it interrogates to produce the output. + + :: + + Ptr output; + if (format == "omnet") { + NS_LOG_INFO("Creating omnet formatted data output."); + output = CreateObject(); + } else { + #ifdef STAT_USE_DB + NS_LOG_INFO("Creating sqlite formatted data output."); + output = CreateObject(); + #endif + } + + output->Output(data); + +* Freeing any memory used by the simulation. This should come at the end of the main function for the example. + + :: + + Simulator::Destroy(); + +Logging +======= + +To see what the example program, applications, and stat framework are doing in detail, set the ``NS_LOG`` variable appropriately. The following will provide copious output from all three. + +:: + + export NS_LOG=StatFramework:WiFiDistanceExperiment:WiFiDistanceApps + +Note that this slows down the simulation extraordinarily. + +Sample Output +============= + +Compiling and simply running the test program will append omnet++ formatted output such as the following to ``data.sca``. + +:: + + run run-1212239121 + + attr experiment "wifi-distance-test" + attr strategy "wifi-default" + attr input "50" + attr description "" + + attr "author" "tjkopena" + + scalar wifi-tx-frames count 30 + scalar wifi-rx-frames count 30 + scalar sender-tx-packets count 30 + scalar receiver-rx-packets count 30 + scalar tx-pkt-size count 30 + scalar tx-pkt-size total 1920 + scalar tx-pkt-size average 64 + scalar tx-pkt-size max 64 + scalar tx-pkt-size min 64 + scalar delay count 30 + scalar delay total 5884980ns + scalar delay average 196166ns + scalar delay max 196166ns + scalar delay min 196166ns + +Control Script +++++++++++++++ + +In order to automate data collection at a variety of inputs (distances), a simple Bash script is used to execute a series of simulations. It can be found at ``examples/stats/wifi-example-db.sh``. The script runs through a set of distances, collecting the results into an sqlite3 database. At each distance five trials are conducted to give a better picture of expected performance. The entire experiment takes only a few dozen seconds to run on a low end machine as there is no output during the simulation and little traffic is generated. + +:: + + #!/bin/sh + + DISTANCES="25 50 75 100 125 145 147 150 152 155 157 160 162 165 167 170 172 175 177 180" + TRIALS="1 2 3 4 5" + + echo WiFi Experiment Example + + if [ -e data.db ] + then + echo Kill data.db? + read ANS + if [ "$ANS" = "yes" -o "$ANS" = "y" ] + then + echo Deleting database + rm data.db + fi + fi + + for trial in $TRIALS + do + for distance in $DISTANCES + do + echo Trial $trial, distance $distance + ./bin/test02 --format=db --distance=$distance --run=run-$distance-$trial + done + done + +Analysis and Conclusion ++++++++++++++++++++++++ + +Once all trials have been conducted, the script executes a simple SQL query over the database using the sqlite3 command line program. The query computes average packet loss in each set of trials associated with each distance. It does not take into account different strategies, but the information is present in the database to make some simple extensions and do so. The collected data is then passed to GNUPlot for graphing. + +:: + + CMD="select exp.input,avg(100-((rx.value*100)/tx.value)) \ + from Singletons rx, Singletons tx, Experiments exp \ + where rx.run = tx.run AND \ + rx.run = exp.run AND \ + rx.name='receiver-rx-packets' AND \ + tx.name='sender-tx-packets' \ + group by exp.input \ + order by abs(exp.input) ASC;" + + sqlite3 -noheader data.db "$CMD" > wifi-default.data + sed -i "s/|/ /" wifi-default.data + gnuplot wifi-example.gnuplot + +The GNUPlot script found at ``examples/stats/wifi-example.gnuplot`` simply defines the output format and some basic formatting for the graph. + +:: + + set terminal postscript portrait enhanced lw 2 "Helvetica" 14 + + set size 1.0, 0.66 + + #------------------------------------------------------- + set out "wifi-default.eps" + #set title "Packet Loss Over Distance" + set xlabel "Distance (m) --- average of 5 trials per point" + set xrange [0:200] + set ylabel "% Packet Loss" + set yrange [0:110] + + plot "wifi-default.data" with lines title "WiFi Defaults" + +End Result +========== + +The resulting graph provides no evidence that the default WiFi model's performance is necessarily unreasonable and lends some confidence to an at least token faithfulness to reality. More importantly, this simple investigation has been carried all the way through using the statistical framework. Success! + +.. image:: figures/Wifi-default.png -*Placeholder chapter* -This wiki page: `This wiki page -`_ -contains information about the proposed statistical framework that is located in -``src/stats`` directory. diff --git a/src/stats/model/basic-data-calculators.h b/src/stats/model/basic-data-calculators.h index 09c2e63a3..5d028e991 100644 --- a/src/stats/model/basic-data-calculators.h +++ b/src/stats/model/basic-data-calculators.h @@ -40,24 +40,35 @@ public: MinMaxAvgTotalCalculator(); virtual ~MinMaxAvgTotalCalculator(); - void Update(const T i); + void Update (const T i); - virtual void Output(DataOutputCallback &callback) const; + virtual void Output (DataOutputCallback &callback) const; - long getCount() const { return m_count; } - double getSum() const { return m_total; } - double getMin() const { return m_min; } - double getMax() const { return m_max; } - double getMean() const { return m_total / (double)m_count; } - double getStddev() const { return sqrt (getVariance ()); } - double getVariance() const { return ( m_count * m_totalSquare - m_total * m_total ) / (double) (m_count * (m_count - 1) ); } - double getSqrSum() const { return m_totalSquare; } + long getCount () const { return m_count; } + double getSum () const { return m_total; } + double getMin () const { return m_min; } + double getMax () const { return m_max; } + double getMean () const { return m_meanCurr; } + double getStddev () const { return sqrt (m_varianceCurr); } + double getVariance () const { return m_varianceCurr; } + double getSqrSum () const { return m_squareTotal; } protected: - virtual void DoDispose(void); + virtual void DoDispose (void); uint32_t m_count; - T m_total, m_min, m_max, m_totalSquare; + + T m_total; + T m_squareTotal; + T m_min; + T m_max; + + double m_meanCurr; + double m_sCurr; + double m_varianceCurr; + + double m_meanPrev; + double m_sPrev; // end MinMaxAvgTotalCalculator }; @@ -67,10 +78,16 @@ template MinMaxAvgTotalCalculator::MinMaxAvgTotalCalculator() { m_count = 0; - m_total = 0; - m_totalSquare = 0; - m_min = ~0; - m_max = 0; + + m_total = 0; + m_squareTotal = 0; + + m_meanCurr = NaN; + m_sCurr = NaN; + m_varianceCurr = NaN; + + m_meanPrev = NaN; + m_sPrev = NaN; } template @@ -79,36 +96,83 @@ MinMaxAvgTotalCalculator::~MinMaxAvgTotalCalculator() } template void -MinMaxAvgTotalCalculator::DoDispose(void) +MinMaxAvgTotalCalculator::DoDispose (void) { - DataCalculator::DoDispose(); + DataCalculator::DoDispose (); // MinMaxAvgTotalCalculator::DoDispose } template void -MinMaxAvgTotalCalculator::Update(const T i) +MinMaxAvgTotalCalculator::Update (const T i) { if (m_enabled) { - m_total += i; - m_totalSquare += i*i; - - if (i < m_min) - m_min = i; - - if (i > m_max) - m_max = i; - m_count++; + + m_total += i; + m_squareTotal += i*i; + + if (m_count == 1) + { + m_min = i; + m_max = i; + } + else + { + if (i < m_min) + { + m_min = i; + } + if (i > m_max) + { + m_max = i; + } + } + + // Calculate the variance based on equations (15) and (16) on + // page 216 of "The Art of Computer Programming, Volume 2", + // Second Edition. Donald E. Knuth. Addison-Wesley + // Publishing Company, 1973. + // + // The relationships between the variance, standard deviation, + // and s are as follows + // + // s + // variance = ----------- + // count - 1 + // + // ------------- + // / + // standard_deviation = / variance + // \/ + // + if (m_count == 1) + { + // Set the very first values. + m_meanCurr = i; + m_sCurr = 0; + m_varianceCurr = m_sCurr; + } + else + { + // Save the previous values. + m_meanPrev = m_meanCurr; + m_sPrev = m_sCurr; + + // Update the current values. + m_meanCurr = m_meanPrev + (i - m_meanPrev) / m_count; + m_sCurr = m_sPrev + (i - m_meanPrev) * (i - m_meanCurr); + m_varianceCurr = m_sCurr / (m_count - 1); + } } // end MinMaxAvgTotalCalculator::Update } template void -MinMaxAvgTotalCalculator::Output(DataOutputCallback &callback) const +MinMaxAvgTotalCalculator::Output (DataOutputCallback &callback) const { - callback.OutputStatistic(m_context, m_key, this); + callback.OutputStatistic (m_context, m_key, this); } @@ -124,15 +188,15 @@ public: CounterCalculator(); virtual ~CounterCalculator(); - void Update(); - void Update(const T i); + void Update (); + void Update (const T i); - T GetCount() const; + T GetCount () const; - virtual void Output(DataOutputCallback &callback) const; + virtual void Output (DataOutputCallback &callback) const; protected: - virtual void DoDispose(void); + virtual void DoDispose (void); T m_count; @@ -143,7 +207,7 @@ protected: //-------------------------------------------- template CounterCalculator::CounterCalculator() : - m_count(0) + m_count (0) { } @@ -153,15 +217,15 @@ CounterCalculator::~CounterCalculator() } template void -CounterCalculator::DoDispose(void) +CounterCalculator::DoDispose (void) { - DataCalculator::DoDispose(); + DataCalculator::DoDispose (); // CounterCalculator::DoDispose } template void -CounterCalculator::Update() +CounterCalculator::Update () { if (m_enabled) { m_count++; @@ -171,7 +235,7 @@ CounterCalculator::Update() template void -CounterCalculator::Update(const T i) +CounterCalculator::Update (const T i) { if (m_enabled) { m_count += i; @@ -181,7 +245,7 @@ CounterCalculator::Update(const T i) template T -CounterCalculator::GetCount() const +CounterCalculator::GetCount () const { return m_count; // end CounterCalculator::GetCount @@ -189,9 +253,9 @@ CounterCalculator::GetCount() const template void -CounterCalculator::Output(DataOutputCallback &callback) const +CounterCalculator::Output (DataOutputCallback &callback) const { - callback.OutputSingleton(m_context, m_key, m_count); + callback.OutputSingleton (m_context, m_key, m_count); // end CounterCalculator::Output } diff --git a/src/stats/model/data-calculator.cc b/src/stats/model/data-calculator.cc index d473f92b9..cd8ceee8d 100644 --- a/src/stats/model/data-calculator.cc +++ b/src/stats/model/data-calculator.cc @@ -25,7 +25,7 @@ using namespace ns3; -NS_LOG_COMPONENT_DEFINE("DataCalculator"); +NS_LOG_COMPONENT_DEFINE ("DataCalculator"); static double zero = 0; const double ns3::NaN = zero / zero; @@ -33,38 +33,38 @@ const double ns3::NaN = zero / zero; //-------------------------------------------------------------- //---------------------------------------------- DataCalculator::DataCalculator() : - m_enabled(true) + m_enabled (true) { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } DataCalculator::~DataCalculator() { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } void -DataCalculator::DoDispose(void) +DataCalculator::DoDispose (void) { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); - Simulator::Cancel(m_startEvent); - Simulator::Cancel(m_stopEvent); + Simulator::Cancel (m_startEvent); + Simulator::Cancel (m_stopEvent); - Object::DoDispose(); + Object::DoDispose (); // DataCalculator::DoDispose } //---------------------------------------------- void -DataCalculator::SetKey(const std::string key) +DataCalculator::SetKey (const std::string key) { m_key = key; // end DataCalculator::SetKey } std::string -DataCalculator::GetKey() const +DataCalculator::GetKey () const { return m_key; // end DataCalculator::GetKey @@ -72,35 +72,35 @@ DataCalculator::GetKey() const //---------------------------------------------- void -DataCalculator::SetContext(const std::string context) +DataCalculator::SetContext (const std::string context) { m_context = context; // end DataCalculator::SetContext } std::string -DataCalculator::GetContext() const +DataCalculator::GetContext () const { return m_context; // end DataCalculator::GetContext } //---------------------------------------------- void -DataCalculator::Enable() +DataCalculator::Enable () { m_enabled = true; // end DataCalculator::Enable } void -DataCalculator::Disable() +DataCalculator::Disable () { m_enabled = false; // end DataCalculator::Disable } bool -DataCalculator::GetEnabled() const +DataCalculator::GetEnabled () const { return m_enabled; // end DataCalculator::GetEnabled @@ -108,19 +108,19 @@ DataCalculator::GetEnabled() const //---------------------------------------------- void -DataCalculator::Start(const Time& startTime) +DataCalculator::Start (const Time& startTime) { - m_startEvent = Simulator::Schedule(startTime, - &DataCalculator::Enable, this); + m_startEvent = Simulator::Schedule (startTime, + &DataCalculator::Enable, this); // end DataCalculator::Start } void -DataCalculator::Stop(const Time& stopTime) +DataCalculator::Stop (const Time& stopTime) { - m_stopEvent = Simulator::Schedule(stopTime, - &DataCalculator::Disable, this); + m_stopEvent = Simulator::Schedule (stopTime, + &DataCalculator::Disable, this); // end DataCalculator::Stop } diff --git a/src/stats/model/data-calculator.h b/src/stats/model/data-calculator.h index d064ee095..155d390cf 100644 --- a/src/stats/model/data-calculator.h +++ b/src/stats/model/data-calculator.h @@ -27,7 +27,7 @@ namespace ns3 { extern const double NaN; -inline bool isNaN(double x) { return x != x; } +inline bool isNaN (double x) { return x != x; } class DataOutputCallback; @@ -42,44 +42,44 @@ public: /** * Returns the number of the observations. */ - virtual long getCount() const = 0; + virtual long getCount () const = 0; /** * Returns the sum of the values. * @see getWeightedSum() */ - virtual double getSum() const = 0; + virtual double getSum () const = 0; /** * Returns the sum of the squared values. * @see getWeightedSqrSum() */ - virtual double getSqrSum() const = 0; + virtual double getSqrSum () const = 0; /** * Returns the minimum of the values. */ - virtual double getMin() const = 0; + virtual double getMin () const = 0; /** * Returns the maximum of the values. */ - virtual double getMax() const = 0; + virtual double getMax () const = 0; /** * Returns the mean of the (weighted) observations. */ - virtual double getMean() const = 0; + virtual double getMean () const = 0; /** * Returns the standard deviation of the (weighted) observations. */ - virtual double getStddev() const = 0; + virtual double getStddev () const = 0; /** * Returns the variance of the (weighted) observations. */ - virtual double getVariance() const = 0; + virtual double getVariance () const = 0; }; //------------------------------------------------------------ @@ -89,20 +89,20 @@ public: DataCalculator(); virtual ~DataCalculator(); - bool GetEnabled() const; - void Enable(); - void Disable(); + bool GetEnabled () const; + void Enable (); + void Disable (); - void SetKey(const std::string key); - std::string GetKey() const; + void SetKey (const std::string key); + std::string GetKey () const; - void SetContext(const std::string context); - std::string GetContext() const; + void SetContext (const std::string context); + std::string GetContext () const; - virtual void Start(const Time& startTime); - virtual void Stop(const Time& stopTime); + virtual void Start (const Time& startTime); + virtual void Stop (const Time& stopTime); - virtual void Output(DataOutputCallback &callback) const = 0; + virtual void Output (DataOutputCallback &callback) const = 0; protected: bool m_enabled; // Descendant classes *must* check & respect m_enabled! @@ -110,7 +110,7 @@ protected: std::string m_key; std::string m_context; - virtual void DoDispose(void); + virtual void DoDispose (void); private: EventId m_startEvent; diff --git a/src/stats/model/data-collector.cc b/src/stats/model/data-collector.cc index 7dd635db5..1825240b0 100644 --- a/src/stats/model/data-collector.cc +++ b/src/stats/model/data-collector.cc @@ -26,36 +26,36 @@ using namespace ns3; -NS_LOG_COMPONENT_DEFINE("DataCollector"); +NS_LOG_COMPONENT_DEFINE ("DataCollector"); //-------------------------------------------------------------- //---------------------------------------------- DataCollector::DataCollector() { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); // end DataCollector::DataCollector } DataCollector::~DataCollector() { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); // end DataCollector::~DataCollector } -void DataCollector::DoDispose() { - NS_LOG_FUNCTION_NOARGS(); +void DataCollector::DoDispose () { + NS_LOG_FUNCTION_NOARGS (); - m_calcList.clear(); - m_metadata.clear(); + m_calcList.clear (); + m_metadata.clear (); - Object::DoDispose(); + Object::DoDispose (); // end DataCollector::DoDispose } void -DataCollector::DescribeRun(std::string experiment, - std::string strategy, - std::string input, - std::string runID, - std::string description) +DataCollector::DescribeRun (std::string experiment, + std::string strategy, + std::string input, + std::string runID, + std::string description) { m_experimentLabel = experiment; @@ -68,64 +68,64 @@ DataCollector::DescribeRun(std::string experiment, } void -DataCollector::AddDataCalculator(Ptr datac) +DataCollector::AddDataCalculator (Ptr datac) { - m_calcList.push_back(datac); + m_calcList.push_back (datac); // end DataCollector::AddDataCalculator } DataCalculatorList::iterator -DataCollector::DataCalculatorBegin() +DataCollector::DataCalculatorBegin () { - return m_calcList.begin(); + return m_calcList.begin (); // end DataCollector::DataCalculatorBegin } DataCalculatorList::iterator -DataCollector::DataCalculatorEnd() +DataCollector::DataCalculatorEnd () { - return m_calcList.end(); + return m_calcList.end (); // end DataCollector::DataCalculatorEnd } void -DataCollector::AddMetadata(std::string key, std::string value) +DataCollector::AddMetadata (std::string key, std::string value) { - std::pair blob(key, value); - m_metadata.push_back(blob); + std::pair blob (key, value); + m_metadata.push_back (blob); // end DataCollector::AddMetadata } void -DataCollector::AddMetadata(std::string key, uint32_t value) +DataCollector::AddMetadata (std::string key, uint32_t value) { std::stringstream st; st << value; - std::pair blob(key, st.str()); - m_metadata.push_back(blob); + std::pair blob (key, st.str ()); + m_metadata.push_back (blob); // end DataCollector::AddMetadata } void -DataCollector::AddMetadata(std::string key, double value) +DataCollector::AddMetadata (std::string key, double value) { std::stringstream st; st << value; - std::pair blob(key, st.str()); - m_metadata.push_back(blob); + std::pair blob (key, st.str ()); + m_metadata.push_back (blob); // end DataCollector::AddMetadata } MetadataList::iterator -DataCollector::MetadataBegin() +DataCollector::MetadataBegin () { - return m_metadata.begin(); + return m_metadata.begin (); // end DataCollector::MetadataBegin } MetadataList::iterator -DataCollector::MetadataEnd() +DataCollector::MetadataEnd () { - return m_metadata.end(); + return m_metadata.end (); // end DataCollector::MetadataEnd } diff --git a/src/stats/model/data-collector.h b/src/stats/model/data-collector.h index 58640e28a..f53124300 100644 --- a/src/stats/model/data-collector.h +++ b/src/stats/model/data-collector.h @@ -48,30 +48,30 @@ public: DataCollector(); virtual ~DataCollector(); - void DescribeRun(std::string experiment, - std::string strategy, - std::string input, - std::string runID, - std::string description = ""); + void DescribeRun (std::string experiment, + std::string strategy, + std::string input, + std::string runID, + std::string description = ""); - std::string GetExperimentLabel() const { return m_experimentLabel; } - std::string GetStrategyLabel() const { return m_strategyLabel; } - std::string GetInputLabel() const { return m_inputLabel; } - std::string GetRunLabel() const { return m_runLabel; } - std::string GetDescription() const { return m_description; } + std::string GetExperimentLabel () const { return m_experimentLabel; } + std::string GetStrategyLabel () const { return m_strategyLabel; } + std::string GetInputLabel () const { return m_inputLabel; } + std::string GetRunLabel () const { return m_runLabel; } + std::string GetDescription () const { return m_description; } - void AddMetadata(std::string key, std::string value); - void AddMetadata(std::string key, double value); - void AddMetadata(std::string key, uint32_t value); - MetadataList::iterator MetadataBegin(); - MetadataList::iterator MetadataEnd(); + void AddMetadata (std::string key, std::string value); + void AddMetadata (std::string key, double value); + void AddMetadata (std::string key, uint32_t value); + MetadataList::iterator MetadataBegin (); + MetadataList::iterator MetadataEnd (); - void AddDataCalculator(Ptr datac); - DataCalculatorList::iterator DataCalculatorBegin(); - DataCalculatorList::iterator DataCalculatorEnd(); + void AddDataCalculator (Ptr datac); + DataCalculatorList::iterator DataCalculatorBegin (); + DataCalculatorList::iterator DataCalculatorEnd (); protected: - virtual void DoDispose(); + virtual void DoDispose (); private: std::string m_experimentLabel; diff --git a/src/stats/model/data-output-interface.cc b/src/stats/model/data-output-interface.cc index dd89ff55b..99f0b0451 100644 --- a/src/stats/model/data-output-interface.cc +++ b/src/stats/model/data-output-interface.cc @@ -24,36 +24,36 @@ using namespace ns3; -NS_LOG_COMPONENT_DEFINE("DataOutputInterface"); +NS_LOG_COMPONENT_DEFINE ("DataOutputInterface"); //-------------------------------------------------------------- //---------------------------------------------- DataOutputInterface::DataOutputInterface() { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } DataOutputInterface::~DataOutputInterface() { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } void -DataOutputInterface::DoDispose() +DataOutputInterface::DoDispose () { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); - Object::DoDispose(); + Object::DoDispose (); // end DataOutputInterface::DoDispose } void -DataOutputInterface::SetFilePrefix(const std::string prefix) +DataOutputInterface::SetFilePrefix (const std::string prefix) { m_filePrefix = prefix; } std::string -DataOutputInterface::GetFilePrefix() const +DataOutputInterface::GetFilePrefix () const { return m_filePrefix; } diff --git a/src/stats/model/data-output-interface.h b/src/stats/model/data-output-interface.h index 109e5c996..256fe6188 100644 --- a/src/stats/model/data-output-interface.h +++ b/src/stats/model/data-output-interface.h @@ -40,13 +40,13 @@ public: DataOutputInterface(); virtual ~DataOutputInterface(); - virtual void Output(DataCollector &dc) = 0; + virtual void Output (DataCollector &dc) = 0; - void SetFilePrefix(const std::string prefix); - std::string GetFilePrefix() const; + void SetFilePrefix (const std::string prefix); + std::string GetFilePrefix () const; protected: - virtual void DoDispose(); + virtual void DoDispose (); std::string m_filePrefix; @@ -61,29 +61,29 @@ class DataOutputCallback { public: virtual ~DataOutputCallback() {} - virtual void OutputStatistic(std::string key, - std::string variable, - const StatisticalSummary *statSum) = 0; + virtual void OutputStatistic (std::string key, + std::string variable, + const StatisticalSummary *statSum) = 0; - virtual void OutputSingleton(std::string key, - std::string variable, - int val) = 0; + virtual void OutputSingleton (std::string key, + std::string variable, + int val) = 0; - virtual void OutputSingleton(std::string key, - std::string variable, - uint32_t val) = 0; + virtual void OutputSingleton (std::string key, + std::string variable, + uint32_t val) = 0; - virtual void OutputSingleton(std::string key, - std::string variable, - double val) = 0; + virtual void OutputSingleton (std::string key, + std::string variable, + double val) = 0; - virtual void OutputSingleton(std::string key, - std::string variable, - std::string val) = 0; + virtual void OutputSingleton (std::string key, + std::string variable, + std::string val) = 0; - virtual void OutputSingleton(std::string key, - std::string variable, - Time val) = 0; + virtual void OutputSingleton (std::string key, + std::string variable, + Time val) = 0; // end class DataOutputCallback }; diff --git a/src/stats/model/omnet-data-output.cc b/src/stats/model/omnet-data-output.cc index 6b14b52ee..e686624e7 100644 --- a/src/stats/model/omnet-data-output.cc +++ b/src/stats/model/omnet-data-output.cc @@ -30,7 +30,7 @@ using namespace ns3; -NS_LOG_COMPONENT_DEFINE("OmnetDataOutput"); +NS_LOG_COMPONENT_DEFINE ("OmnetDataOutput"); //-------------------------------------------------------------- @@ -39,24 +39,24 @@ OmnetDataOutput::OmnetDataOutput() { m_filePrefix = "data"; - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } OmnetDataOutput::~OmnetDataOutput() { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } void -OmnetDataOutput::DoDispose() +OmnetDataOutput::DoDispose () { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); - DataOutputInterface::DoDispose(); + DataOutputInterface::DoDispose (); // end OmnetDataOutput::DoDispose } //---------------------------------------------- -inline bool isNumeric(const std::string& s) { +inline bool isNumeric (const std::string& s) { bool decimalPtSeen = false; bool exponentSeen = false; char last = '\0'; @@ -83,94 +83,94 @@ inline bool isNumeric(const std::string& s) { } void -OmnetDataOutput::Output(DataCollector &dc) +OmnetDataOutput::Output (DataCollector &dc) { std::ofstream scalarFile; - std::string fn = m_filePrefix +"-"+dc.GetRunLabel()+ ".sca"; - scalarFile.open(fn.c_str(), std::ios_base::out); + std::string fn = m_filePrefix +"-"+dc.GetRunLabel ()+ ".sca"; + scalarFile.open (fn.c_str (), std::ios_base::out); // TODO add timestamp to the runlevel - scalarFile << "run " << dc.GetRunLabel() << std::endl; - scalarFile << "attr experiment \"" << dc.GetExperimentLabel() + scalarFile << "run " << dc.GetRunLabel () << std::endl; + scalarFile << "attr experiment \"" << dc.GetExperimentLabel () << "\"" << std::endl; - scalarFile << "attr strategy \"" << dc.GetStrategyLabel() + scalarFile << "attr strategy \"" << dc.GetStrategyLabel () << "\"" << std::endl; - scalarFile << "attr measurement \"" << dc.GetInputLabel() + scalarFile << "attr measurement \"" << dc.GetInputLabel () << "\"" << std::endl; - scalarFile << "attr description \"" << dc.GetDescription() + scalarFile << "attr description \"" << dc.GetDescription () << "\"" << std::endl; - for (MetadataList::iterator i = dc.MetadataBegin(); - i != dc.MetadataEnd(); i++) { + for (MetadataList::iterator i = dc.MetadataBegin (); + i != dc.MetadataEnd (); i++) { std::pair blob = (*i); scalarFile << "attr \"" << blob.first << "\" \"" << blob.second << "\"" << std::endl; } scalarFile << std::endl; - if (isNumeric(dc.GetInputLabel())) { - scalarFile << "scalar . measurement \"" << dc.GetInputLabel() + if (isNumeric (dc.GetInputLabel ())) { + scalarFile << "scalar . measurement \"" << dc.GetInputLabel () << "\"" << std::endl; } - for (MetadataList::iterator i = dc.MetadataBegin(); - i != dc.MetadataEnd(); i++) { + for (MetadataList::iterator i = dc.MetadataBegin (); + i != dc.MetadataEnd (); i++) { std::pair blob = (*i); - if (isNumeric(blob.second)) { + if (isNumeric (blob.second)) { scalarFile << "scalar . \"" << blob.first << "\" \"" << blob.second << "\"" << std::endl; } } - OmnetOutputCallback callback(&scalarFile); + OmnetOutputCallback callback (&scalarFile); - for (DataCalculatorList::iterator i = dc.DataCalculatorBegin(); - i != dc.DataCalculatorEnd(); i++) { - (*i)->Output(callback); + for (DataCalculatorList::iterator i = dc.DataCalculatorBegin (); + i != dc.DataCalculatorEnd (); i++) { + (*i)->Output (callback); } scalarFile << std::endl << std::endl; - scalarFile.close(); + scalarFile.close (); // end OmnetDataOutput::Output } OmnetDataOutput::OmnetOutputCallback::OmnetOutputCallback - (std::ostream *scalar) : - m_scalar(scalar) + (std::ostream *scalar) : + m_scalar (scalar) { } void -OmnetDataOutput::OmnetOutputCallback::OutputStatistic(std::string context, - std::string name, - const StatisticalSummary *statSum) +OmnetDataOutput::OmnetOutputCallback::OutputStatistic (std::string context, + std::string name, + const StatisticalSummary *statSum) { if (context == "") context = "."; if (name == "") name = "\"\""; (*m_scalar) << "statistic " << context << " " << name << std::endl; - if (!isNaN(statSum->getCount())) - (*m_scalar) << "field count " << statSum->getCount() << std::endl; - if (!isNaN(statSum->getSum())) - (*m_scalar) << "field sum " << statSum->getSum() << std::endl; - if (!isNaN(statSum->getMean())) - (*m_scalar) << "field mean " << statSum->getMean() << std::endl; - if (!isNaN(statSum->getMin())) - (*m_scalar) << "field min " << statSum->getMin() << std::endl; - if (!isNaN(statSum->getMax())) - (*m_scalar) << "field max " << statSum->getMax() << std::endl; - if (!isNaN(statSum->getSqrSum())) - (*m_scalar) << "field sqrsum " << statSum->getSqrSum() << std::endl; - if (!isNaN(statSum->getStddev())) - (*m_scalar) << "field stddev " << statSum->getStddev() << std::endl; + if (!isNaN (statSum->getCount ())) + (*m_scalar) << "field count " << statSum->getCount () << std::endl; + if (!isNaN (statSum->getSum ())) + (*m_scalar) << "field sum " << statSum->getSum () << std::endl; + if (!isNaN (statSum->getMean ())) + (*m_scalar) << "field mean " << statSum->getMean () << std::endl; + if (!isNaN (statSum->getMin ())) + (*m_scalar) << "field min " << statSum->getMin () << std::endl; + if (!isNaN (statSum->getMax ())) + (*m_scalar) << "field max " << statSum->getMax () << std::endl; + if (!isNaN (statSum->getSqrSum ())) + (*m_scalar) << "field sqrsum " << statSum->getSqrSum () << std::endl; + if (!isNaN (statSum->getStddev ())) + (*m_scalar) << "field stddev " << statSum->getStddev () << std::endl; } void -OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, - std::string name, - int val) +OmnetDataOutput::OmnetOutputCallback::OutputSingleton (std::string context, + std::string name, + int val) { if (context == "") context = "."; @@ -181,9 +181,9 @@ OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, } void -OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, - std::string name, - uint32_t val) +OmnetDataOutput::OmnetOutputCallback::OutputSingleton (std::string context, + std::string name, + uint32_t val) { if (context == "") context = "."; @@ -194,9 +194,9 @@ OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, } void -OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, - std::string name, - double val) +OmnetDataOutput::OmnetOutputCallback::OutputSingleton (std::string context, + std::string name, + double val) { if (context == "") context = "."; @@ -207,9 +207,9 @@ OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, } void -OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, - std::string name, - std::string val) +OmnetDataOutput::OmnetOutputCallback::OutputSingleton (std::string context, + std::string name, + std::string val) { if (context == "") context = "."; @@ -220,14 +220,14 @@ OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, } void -OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context, - std::string name, - Time val) +OmnetDataOutput::OmnetOutputCallback::OutputSingleton (std::string context, + std::string name, + Time val) { if (context == "") context = "."; if (name == "") name = "\"\""; - (*m_scalar) << "scalar " << context << " " << name << " " << val.GetTimeStep() << std::endl; + (*m_scalar) << "scalar " << context << " " << name << " " << val.GetTimeStep () << std::endl; // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton } diff --git a/src/stats/model/omnet-data-output.h b/src/stats/model/omnet-data-output.h index d3f058b96..4cf2b4d8c 100644 --- a/src/stats/model/omnet-data-output.h +++ b/src/stats/model/omnet-data-output.h @@ -39,39 +39,39 @@ public: OmnetDataOutput(); virtual ~OmnetDataOutput(); - virtual void Output(DataCollector &dc); + virtual void Output (DataCollector &dc); protected: - virtual void DoDispose(); + virtual void DoDispose (); private: class OmnetOutputCallback : public DataOutputCallback { public: OmnetOutputCallback(std::ostream *scalar); - void OutputStatistic(std::string context, - std::string name, - const StatisticalSummary *statSum); + void OutputStatistic (std::string context, + std::string name, + const StatisticalSummary *statSum); - void OutputSingleton(std::string context, - std::string name, - int val); + void OutputSingleton (std::string context, + std::string name, + int val); - void OutputSingleton(std::string context, - std::string name, - uint32_t val); + void OutputSingleton (std::string context, + std::string name, + uint32_t val); - void OutputSingleton(std::string context, - std::string name, - double val); + void OutputSingleton (std::string context, + std::string name, + double val); - void OutputSingleton(std::string context, - std::string name, - std::string val); + void OutputSingleton (std::string context, + std::string name, + std::string val); - void OutputSingleton(std::string context, - std::string name, - Time val); + void OutputSingleton (std::string context, + std::string name, + Time val); private: std::ostream *m_scalar; diff --git a/src/stats/model/packet-data-calculators.cc b/src/stats/model/packet-data-calculators.cc index a13985e85..d30dbca52 100644 --- a/src/stats/model/packet-data-calculators.cc +++ b/src/stats/model/packet-data-calculators.cc @@ -27,47 +27,47 @@ using namespace ns3; -NS_LOG_COMPONENT_DEFINE("PacketDataCalculators"); +NS_LOG_COMPONENT_DEFINE ("PacketDataCalculators"); //-------------------------------------------------------------- //---------------------------------------------- PacketCounterCalculator::PacketCounterCalculator() { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } PacketCounterCalculator::~PacketCounterCalculator() { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } void -PacketCounterCalculator::DoDispose(void) +PacketCounterCalculator::DoDispose (void) { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); - CounterCalculator::DoDispose(); + CounterCalculator::DoDispose (); // PacketCounterCalculator::DoDispose } void -PacketCounterCalculator::PacketUpdate(std::string path, - Ptr packet) +PacketCounterCalculator::PacketUpdate (std::string path, + Ptr packet) { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); - CounterCalculator::Update(); + CounterCalculator::Update (); // PacketCounterCalculator::Update } void -PacketCounterCalculator::FrameUpdate(std::string path, - Ptr packet, - Mac48Address realto) +PacketCounterCalculator::FrameUpdate (std::string path, + Ptr packet, + Mac48Address realto) { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); - CounterCalculator::Update(); + CounterCalculator::Update (); // PacketCounterCalculator::Update } @@ -79,40 +79,40 @@ PacketCounterCalculator::FrameUpdate(std::string path, //---------------------------------------------- PacketSizeMinMaxAvgTotalCalculator::PacketSizeMinMaxAvgTotalCalculator() { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } PacketSizeMinMaxAvgTotalCalculator::~PacketSizeMinMaxAvgTotalCalculator() { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } void -PacketSizeMinMaxAvgTotalCalculator::DoDispose(void) +PacketSizeMinMaxAvgTotalCalculator::DoDispose (void) { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); - MinMaxAvgTotalCalculator::DoDispose(); + MinMaxAvgTotalCalculator::DoDispose (); // end PacketSizeMinMaxAvgTotalCalculator::DoDispose } void -PacketSizeMinMaxAvgTotalCalculator::PacketUpdate(std::string path, - Ptr packet) +PacketSizeMinMaxAvgTotalCalculator::PacketUpdate (std::string path, + Ptr packet) { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); - MinMaxAvgTotalCalculator::Update(packet->GetSize()); + MinMaxAvgTotalCalculator::Update (packet->GetSize ()); // end PacketSizeMinMaxAvgTotalCalculator::Update } void -PacketSizeMinMaxAvgTotalCalculator::FrameUpdate(std::string path, - Ptr packet, - Mac48Address realto) +PacketSizeMinMaxAvgTotalCalculator::FrameUpdate (std::string path, + Ptr packet, + Mac48Address realto) { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); - MinMaxAvgTotalCalculator::Update(packet->GetSize()); + MinMaxAvgTotalCalculator::Update (packet->GetSize ()); // end PacketSizeMinMaxAvgTotalCalculator::Update } diff --git a/src/stats/model/packet-data-calculators.h b/src/stats/model/packet-data-calculators.h index b877440b6..9874f0b6a 100644 --- a/src/stats/model/packet-data-calculators.h +++ b/src/stats/model/packet-data-calculators.h @@ -37,12 +37,12 @@ public: PacketCounterCalculator(); virtual ~PacketCounterCalculator(); - void PacketUpdate(std::string path, Ptr packet); - void FrameUpdate(std::string path, Ptr packet, - Mac48Address realto); + void PacketUpdate (std::string path, Ptr packet); + void FrameUpdate (std::string path, Ptr packet, + Mac48Address realto); protected: - virtual void DoDispose(void); + virtual void DoDispose (void); // end class PacketCounterCalculator }; @@ -58,12 +58,12 @@ public: PacketSizeMinMaxAvgTotalCalculator(); virtual ~PacketSizeMinMaxAvgTotalCalculator(); - void PacketUpdate(std::string path, Ptr packet); - void FrameUpdate(std::string path, Ptr packet, - Mac48Address realto); + void PacketUpdate (std::string path, Ptr packet); + void FrameUpdate (std::string path, Ptr packet, + Mac48Address realto); protected: - virtual void DoDispose(void); + virtual void DoDispose (void); // end class PacketSizeMinMaxAvgTotalCalculator }; diff --git a/src/stats/model/sqlite-data-output.cc b/src/stats/model/sqlite-data-output.cc index d65d43a4d..b456319f5 100644 --- a/src/stats/model/sqlite-data-output.cc +++ b/src/stats/model/sqlite-data-output.cc @@ -31,44 +31,44 @@ using namespace ns3; -NS_LOG_COMPONENT_DEFINE("SqliteDataOutput"); +NS_LOG_COMPONENT_DEFINE ("SqliteDataOutput"); //-------------------------------------------------------------- //---------------------------------------------- SqliteDataOutput::SqliteDataOutput() { m_filePrefix = "data"; - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } SqliteDataOutput::~SqliteDataOutput() { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); } void -SqliteDataOutput::DoDispose() +SqliteDataOutput::DoDispose () { - NS_LOG_FUNCTION_NOARGS(); + NS_LOG_FUNCTION_NOARGS (); - DataOutputInterface::DoDispose(); + DataOutputInterface::DoDispose (); // end SqliteDataOutput::DoDispose } int -SqliteDataOutput::Exec(std::string exe) { +SqliteDataOutput::Exec (std::string exe) { int res; char **result; int nrows, ncols; char *errMsg = 0; - NS_LOG_INFO("executing '" << exe << "'"); + NS_LOG_INFO ("executing '" << exe << "'"); - res = sqlite3_get_table(m_db, - exe.c_str(), - &result, &nrows, &ncols, - &errMsg); + res = sqlite3_get_table (m_db, + exe.c_str (), + &result, &nrows, &ncols, + &errMsg); if (res != SQLITE_OK) { - NS_LOG_ERROR("sqlite3 error: \"" << errMsg << "\""); + NS_LOG_ERROR ("sqlite3 error: \"" << errMsg << "\""); /* } else { // std::cout << "nrows " << nrows << " ncols " << ncols << std::endl; @@ -90,7 +90,7 @@ SqliteDataOutput::Exec(std::string exe) { */ } - sqlite3_free_table(result); + sqlite3_free_table (result); return res; // end SqliteDataOutput::Exec @@ -98,86 +98,86 @@ SqliteDataOutput::Exec(std::string exe) { //---------------------------------------------- void -SqliteDataOutput::Output(DataCollector &dc) +SqliteDataOutput::Output (DataCollector &dc) { std::string m_dbFile = m_filePrefix + ".db"; - if (sqlite3_open(m_dbFile.c_str(), &m_db)) { - NS_LOG_ERROR("Could not open sqlite3 database \"" << m_dbFile << "\""); - NS_LOG_ERROR("sqlite3 error \"" << sqlite3_errmsg(m_db) << "\""); - sqlite3_close(m_db); + if (sqlite3_open (m_dbFile.c_str (), &m_db)) { + NS_LOG_ERROR ("Could not open sqlite3 database \"" << m_dbFile << "\""); + NS_LOG_ERROR ("sqlite3 error \"" << sqlite3_errmsg (m_db) << "\""); + sqlite3_close (m_db); // TODO: Better error reporting, management! return; } - std::string run = dc.GetRunLabel(); + std::string run = dc.GetRunLabel (); - Exec("create table if not exists Experiments (run, experiment, strategy, input, description text)"); - Exec("insert into Experiments (run,experiment,strategy,input,description) values ('" + - run + "', '" + - dc.GetExperimentLabel() + "', '" + - dc.GetStrategyLabel() + "', '" + - dc.GetInputLabel() + "', '" + - dc.GetDescription() + "')"); + Exec ("create table if not exists Experiments (run, experiment, strategy, input, description text)"); + Exec ("insert into Experiments (run,experiment,strategy,input,description) values ('" + + run + "', '" + + dc.GetExperimentLabel () + "', '" + + dc.GetStrategyLabel () + "', '" + + dc.GetInputLabel () + "', '" + + dc.GetDescription () + "')"); - Exec("create table if not exists Metadata ( run text, key text, value)"); + Exec ("create table if not exists Metadata ( run text, key text, value)"); - for (MetadataList::iterator i = dc.MetadataBegin(); - i != dc.MetadataEnd(); i++) { + for (MetadataList::iterator i = dc.MetadataBegin (); + i != dc.MetadataEnd (); i++) { std::pair blob = (*i); - Exec("insert into Metadata (run,key,value) values ('" + - run + "', '" + - blob.first + "', '" + - blob.second + "')"); + Exec ("insert into Metadata (run,key,value) values ('" + + run + "', '" + + blob.first + "', '" + + blob.second + "')"); } - Exec("BEGIN"); - SqliteOutputCallback callback(this, run); - for (DataCalculatorList::iterator i = dc.DataCalculatorBegin(); - i != dc.DataCalculatorEnd(); i++) { - (*i)->Output(callback); + Exec ("BEGIN"); + SqliteOutputCallback callback (this, run); + for (DataCalculatorList::iterator i = dc.DataCalculatorBegin (); + i != dc.DataCalculatorEnd (); i++) { + (*i)->Output (callback); } - Exec("COMMIT"); + Exec ("COMMIT"); - sqlite3_close(m_db); + sqlite3_close (m_db); // end SqliteDataOutput::Output } SqliteDataOutput::SqliteOutputCallback::SqliteOutputCallback - (Ptr owner, std::string run) : - m_owner(owner), - m_runLabel(run) + (Ptr owner, std::string run) : + m_owner (owner), + m_runLabel (run) { - m_owner->Exec("create table if not exists Singletons ( run text, name text, variable text, value )"); + m_owner->Exec ("create table if not exists Singletons ( run text, name text, variable text, value )"); // end SqliteDataOutput::SqliteOutputCallback::SqliteOutputCallback } void -SqliteDataOutput::SqliteOutputCallback::OutputStatistic(std::string key, - std::string variable, - const StatisticalSummary *statSum) +SqliteDataOutput::SqliteOutputCallback::OutputStatistic (std::string key, + std::string variable, + const StatisticalSummary *statSum) { - OutputSingleton(key,variable+"-count", (double)statSum->getCount()); - if (!isNaN(statSum->getSum())) - OutputSingleton(key,variable+"-total", statSum->getSum()); - if (!isNaN(statSum->getMax())) - OutputSingleton(key,variable+"-max", statSum->getMax()); - if (!isNaN(statSum->getMin())) - OutputSingleton(key,variable+"-min", statSum->getMin()); - if (!isNaN(statSum->getSqrSum())) - OutputSingleton(key,variable+"-sqrsum", statSum->getSqrSum()); - if (!isNaN(statSum->getStddev())) - OutputSingleton(key,variable+"-stddev", statSum->getStddev()); + OutputSingleton (key,variable+"-count", (double)statSum->getCount ()); + if (!isNaN (statSum->getSum ())) + OutputSingleton (key,variable+"-total", statSum->getSum ()); + if (!isNaN (statSum->getMax ())) + OutputSingleton (key,variable+"-max", statSum->getMax ()); + if (!isNaN (statSum->getMin ())) + OutputSingleton (key,variable+"-min", statSum->getMin ()); + if (!isNaN (statSum->getSqrSum ())) + OutputSingleton (key,variable+"-sqrsum", statSum->getSqrSum ()); + if (!isNaN (statSum->getStddev ())) + OutputSingleton (key,variable+"-stddev", statSum->getStddev ()); } void -SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key, - std::string variable, - int val) +SqliteDataOutput::SqliteOutputCallback::OutputSingleton (std::string key, + std::string variable, + int val) { std::stringstream sstr; @@ -186,14 +186,14 @@ SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key, key << "', '" << variable << "', " << val << ")"; - m_owner->Exec(sstr.str()); + m_owner->Exec (sstr.str ()); // end SqliteDataOutput::SqliteOutputCallback::OutputSingleton } void -SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key, - std::string variable, - uint32_t val) +SqliteDataOutput::SqliteOutputCallback::OutputSingleton (std::string key, + std::string variable, + uint32_t val) { std::stringstream sstr; sstr << "insert into Singletons (run,name,variable,value) values ('" << @@ -201,13 +201,13 @@ SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key, key << "', '" << variable << "', " << val << ")"; - m_owner->Exec(sstr.str()); + m_owner->Exec (sstr.str ()); // end SqliteDataOutput::SqliteOutputCallback::OutputSingleton } void -SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key, - std::string variable, - double val) +SqliteDataOutput::SqliteOutputCallback::OutputSingleton (std::string key, + std::string variable, + double val) { std::stringstream sstr; sstr << "insert into Singletons (run,name,variable,value) values ('" << @@ -215,13 +215,13 @@ SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key, key << "', '" << variable << "', " << val << ")"; - m_owner->Exec(sstr.str()); + m_owner->Exec (sstr.str ()); // end SqliteDataOutput::SqliteOutputCallback::OutputSingleton } void -SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key, - std::string variable, - std::string val) +SqliteDataOutput::SqliteOutputCallback::OutputSingleton (std::string key, + std::string variable, + std::string val) { std::stringstream sstr; sstr << "insert into Singletons (run,name,variable,value) values ('" << @@ -229,20 +229,20 @@ SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key, key << "', '" << variable << "', '" << val << "')"; - m_owner->Exec(sstr.str()); + m_owner->Exec (sstr.str ()); // end SqliteDataOutput::SqliteOutputCallback::OutputSingleton } void -SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key, - std::string variable, - Time val) +SqliteDataOutput::SqliteOutputCallback::OutputSingleton (std::string key, + std::string variable, + Time val) { std::stringstream sstr; sstr << "insert into Singletons (run,name,variable,value) values ('" << m_runLabel << "', '" << key << "', '" << variable << "', " << - val.GetTimeStep() << ")"; - m_owner->Exec(sstr.str()); + val.GetTimeStep () << ")"; + m_owner->Exec (sstr.str ()); // end SqliteDataOutput::SqliteOutputCallback::OutputSingleton } diff --git a/src/stats/model/sqlite-data-output.h b/src/stats/model/sqlite-data-output.h index fb3274170..8aa106af3 100644 --- a/src/stats/model/sqlite-data-output.h +++ b/src/stats/model/sqlite-data-output.h @@ -42,39 +42,39 @@ public: SqliteDataOutput(); virtual ~SqliteDataOutput(); - virtual void Output(DataCollector &dc); + virtual void Output (DataCollector &dc); protected: - virtual void DoDispose(); + virtual void DoDispose (); private: class SqliteOutputCallback : public DataOutputCallback { public: SqliteOutputCallback(Ptr owner, std::string run); - void OutputStatistic(std::string key, - std::string variable, - const StatisticalSummary *statSum); + void OutputStatistic (std::string key, + std::string variable, + const StatisticalSummary *statSum); - void OutputSingleton(std::string key, - std::string variable, - int val); + void OutputSingleton (std::string key, + std::string variable, + int val); - void OutputSingleton(std::string key, - std::string variable, - uint32_t val); + void OutputSingleton (std::string key, + std::string variable, + uint32_t val); - void OutputSingleton(std::string key, - std::string variable, - double val); + void OutputSingleton (std::string key, + std::string variable, + double val); - void OutputSingleton(std::string key, - std::string variable, - std::string val); + void OutputSingleton (std::string key, + std::string variable, + std::string val); - void OutputSingleton(std::string key, - std::string variable, - Time val); + void OutputSingleton (std::string key, + std::string variable, + Time val); private: Ptr m_owner; @@ -85,7 +85,7 @@ private: sqlite3 *m_db; - int Exec(std::string exe); + int Exec (std::string exe); // end class SqliteDataOutput }; diff --git a/src/stats/model/time-data-calculators.cc b/src/stats/model/time-data-calculators.cc index eb09d175f..f0dcd4c0a 100644 --- a/src/stats/model/time-data-calculators.cc +++ b/src/stats/model/time-data-calculators.cc @@ -25,7 +25,7 @@ using namespace ns3; -NS_LOG_COMPONENT_DEFINE("TimeDataCalculators"); +NS_LOG_COMPONENT_DEFINE ("TimeDataCalculators"); //-------------------------------------------------------------- @@ -38,14 +38,14 @@ TimeMinMaxAvgTotalCalculator::~TimeMinMaxAvgTotalCalculator() { } void -TimeMinMaxAvgTotalCalculator::DoDispose(void) +TimeMinMaxAvgTotalCalculator::DoDispose (void) { - DataCalculator::DoDispose(); + DataCalculator::DoDispose (); // TimeMinMaxAvgTotalCalculator::DoDispose } void -TimeMinMaxAvgTotalCalculator::Update(const Time i) +TimeMinMaxAvgTotalCalculator::Update (const Time i) { if (m_enabled) { if (m_count) { @@ -68,14 +68,14 @@ TimeMinMaxAvgTotalCalculator::Update(const Time i) // end TimeMinMaxAvgTotalCalculator::Update } void -TimeMinMaxAvgTotalCalculator::Output(DataOutputCallback &callback) const +TimeMinMaxAvgTotalCalculator::Output (DataOutputCallback &callback) const { - callback.OutputSingleton(m_context, m_key + "-count", m_count); + callback.OutputSingleton (m_context, m_key + "-count", m_count); if (m_count > 0) { - callback.OutputSingleton(m_context, m_key + "-total", m_total); - callback.OutputSingleton(m_context, m_key + "-average", Time (m_total / m_count)); - callback.OutputSingleton(m_context, m_key + "-max", m_max); - callback.OutputSingleton(m_context, m_key + "-min", m_min); + callback.OutputSingleton (m_context, m_key + "-total", m_total); + callback.OutputSingleton (m_context, m_key + "-average", Time (m_total / m_count)); + callback.OutputSingleton (m_context, m_key + "-max", m_max); + callback.OutputSingleton (m_context, m_key + "-min", m_min); } // end TimeMinMaxAvgTotalCalculator::Output } diff --git a/src/stats/model/time-data-calculators.h b/src/stats/model/time-data-calculators.h index ddccf9d00..74f6de236 100644 --- a/src/stats/model/time-data-calculators.h +++ b/src/stats/model/time-data-calculators.h @@ -44,12 +44,12 @@ public: TimeMinMaxAvgTotalCalculator(); virtual ~TimeMinMaxAvgTotalCalculator(); - void Update(const Time i); + void Update (const Time i); - virtual void Output(DataOutputCallback &callback) const; + virtual void Output (DataOutputCallback &callback) const; protected: - virtual void DoDispose(void); + virtual void DoDispose (void); uint32_t m_count; Time m_total, m_min, m_max; diff --git a/src/stats/test/basic-data-calculators-test-suite.cc b/src/stats/test/basic-data-calculators-test-suite.cc new file mode 100644 index 000000000..09b3dc010 --- /dev/null +++ b/src/stats/test/basic-data-calculators-test-suite.cc @@ -0,0 +1,277 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011 University of Washington + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mitch Watrous (watrous@u.washington.edu) + */ + +#include + +#include "ns3/test.h" +#include "ns3/basic-data-calculators.h" + +using namespace ns3; + + +// =========================================================================== +// Test case for a single integer. +// =========================================================================== + +class OneIntegerTestCase : public TestCase +{ +public: + OneIntegerTestCase (); + virtual ~OneIntegerTestCase (); + +private: + virtual void DoRun (void); +}; + +OneIntegerTestCase::OneIntegerTestCase () + : TestCase ("Basic Statistical Functions using One Integer") + +{ +} + +OneIntegerTestCase::~OneIntegerTestCase () +{ +} + +void +OneIntegerTestCase::DoRun (void) +{ + MinMaxAvgTotalCalculator calculator; + + long count = 1; + + double sum = 0; + double sqrSum = 0; + double min; + double max; + double mean; + double stddev; + double variance; + + // Put all of the values into the calculator. + int multiple = 5; + int value; + for (long i = 0; i < count; i++) + { + value = multiple * (i + 1); + + calculator.Update (value); + + sum += value; + sqrSum += value * value; + } + + // Calculate the expected values for the statistical functions. + min = multiple; + max = multiple * count; + mean = sum / count; + if (count == 1) + { + variance = 0; + } + else + { + variance = (count * sqrSum - sum * sum) / (count * (count - 1)); + } + stddev = sqrt (variance); + + // Test the calculator. + NS_TEST_ASSERT_MSG_EQ (calculator.getCount(), count, "Count value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getSum(), sum, "Sum value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getMin(), min, "Min value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getMax(), max, "Max value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getMean(), mean, "Mean value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getStddev(), stddev, "Stddev value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getVariance(), variance, "Variance value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getSqrSum(), sqrSum, "SqrSum value wrong"); +} + + +// =========================================================================== +// Test case for five integers. +// =========================================================================== + +class FiveIntegersTestCase : public TestCase +{ +public: + FiveIntegersTestCase (); + virtual ~FiveIntegersTestCase (); + +private: + virtual void DoRun (void); +}; + +FiveIntegersTestCase::FiveIntegersTestCase () + : TestCase ("Basic Statistical Functions using Five Integers") + +{ +} + +FiveIntegersTestCase::~FiveIntegersTestCase () +{ +} + +void +FiveIntegersTestCase::DoRun (void) +{ + MinMaxAvgTotalCalculator calculator; + + long count = 5; + + double sum = 0; + double sqrSum = 0; + double min; + double max; + double mean; + double stddev; + double variance; + + // Put all of the values into the calculator. + int multiple = 5; + int value; + for (long i = 0; i < count; i++) + { + value = multiple * (i + 1); + + calculator.Update (value); + + sum += value; + sqrSum += value * value; + } + + // Calculate the expected values for the statistical functions. + min = multiple; + max = multiple * count; + mean = sum / count; + if (count == 1) + { + variance = 0; + } + else + { + variance = (count * sqrSum - sum * sum) / (count * (count - 1)); + } + stddev = sqrt (variance); + + // Test the calculator. + NS_TEST_ASSERT_MSG_EQ (calculator.getCount(), count, "Count value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getSum(), sum, "Sum value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getMin(), min, "Min value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getMax(), max, "Max value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getMean(), mean, "Mean value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getStddev(), stddev, "Stddev value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getVariance(), variance, "Variance value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getSqrSum(), sqrSum, "SqrSum value wrong"); +} + + +// =========================================================================== +// Test case for five double values. +// =========================================================================== + +class FiveDoublesTestCase : public TestCase +{ +public: + FiveDoublesTestCase (); + virtual ~FiveDoublesTestCase (); + +private: + virtual void DoRun (void); +}; + +FiveDoublesTestCase::FiveDoublesTestCase () + : TestCase ("Basic Statistical Functions using Five Double Values") + +{ +} + +FiveDoublesTestCase::~FiveDoublesTestCase () +{ +} + +void +FiveDoublesTestCase::DoRun (void) +{ + MinMaxAvgTotalCalculator calculator; + + long count = 5; + + double sum = 0; + double sqrSum = 0; + double min; + double max; + double mean; + double stddev; + double variance; + + // Put all of the values into the calculator. + double multiple = 3.14; + double value; + for (long i = 0; i < count; i++) + { + value = multiple * (i + 1); + + calculator.Update (value); + + sum += value; + sqrSum += value * value; + } + + // Calculate the expected values for the statistical functions. + min = multiple; + max = multiple * count; + mean = sum / count; + if (count == 1) + { + variance = 0; + } + else + { + variance = (count * sqrSum - sum * sum) / (count * (count - 1)); + } + stddev = sqrt (variance); + + // Test the calculator. + NS_TEST_ASSERT_MSG_EQ (calculator.getCount(), count, "Count value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getSum(), sum, "Sum value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getMin(), min, "Min value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getMax(), max, "Max value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getMean(), mean, "Mean value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getStddev(), stddev, "Stddev value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getVariance(), variance, "Variance value wrong"); + NS_TEST_ASSERT_MSG_EQ (calculator.getSqrSum(), sqrSum, "SqrSum value wrong"); +} + + +class BasicDataCalculatorsTestSuite : public TestSuite +{ +public: + BasicDataCalculatorsTestSuite (); +}; + +BasicDataCalculatorsTestSuite::BasicDataCalculatorsTestSuite () + : TestSuite ("basic-data-calculators", UNIT) +{ + AddTestCase (new OneIntegerTestCase); + AddTestCase (new FiveIntegersTestCase); + AddTestCase (new FiveDoublesTestCase); +} + +static BasicDataCalculatorsTestSuite basicDataCalculatorsTestSuite; diff --git a/src/stats/wscript b/src/stats/wscript index ecfd0674d..a4d4c5085 100644 --- a/src/stats/wscript +++ b/src/stats/wscript @@ -17,6 +17,12 @@ def build(bld): 'model/omnet-data-output.cc', 'model/data-collector.cc', ] + + module_test = bld.create_ns3_module_test_library('stats') + module_test.source = [ + 'test/basic-data-calculators-test-suite.cc', + ] + headers = bld.new_task_gen('ns3header') headers.module = 'stats' headers.source = [ diff --git a/src/tap-bridge/doc/tap.h b/src/tap-bridge/doc/tap.h index fa2c3ed21..cf4ce8fd2 100644 --- a/src/tap-bridge/doc/tap.h +++ b/src/tap-bridge/doc/tap.h @@ -1,405 +1,6 @@ /** - * \defgroup TapBridgeModel Tap Bridge Device + * \defgroup tap-bridge Tap Bridge Device * - * \section TapBridgeModelOverview TapBridge Model Overview - * - * The Tap Bridge is designed to integrate "real" internet hosts (or more - * precisely, hosts that support Tun/Tap devices) into ns-3 simulations. The - * goal is to make it appear to a "real" host node in that it has an ns-3 net - * device as a local device. The concept of a "real host" is a bit slippery - * since the "real host" may actually be virtualized using readily available - * technologies such as VMware, VirtualBox or OpenVZ. - * - * Since we are, in essence, connecting the inputs and outputs of an ns-3 net - * device to the inputs and outputs of a Linux Tap net device, we call this - * arrangement a Tap Bridge. - * - * There are three basic operating modes of this device available to users. - * Basic functionality is essentially identical, but the modes are different - * in details regarding how the arrangement is created and configured; - * and what devices can live on which side of the bridge. - * - * We call these three modes the ConfigureLocal, UseLocal and UseBridge modes. - * The first "word" in the camel case mode identifier indicates who has the - * responsibility for creating and configuring the taps. For example, - * the "Configure" in ConfigureLocal mode indicates that it is the TapBridge - * that has responsibility for configuring the tap. In UseLocal mode and - * UseBridge modes, the "Use" prefix indicates that the TapBridge is asked to - * "Use" an existing configuration. - * - * In other words, in ConfigureLocal mode, the TapBridge has the responsibility - * for creating and configuring the TAP devices. In UseBridge or UseLocal - * modes, the user provides a configuration and the TapBridge adapts to that - * configuration. - * - * \subsection TapBridgeConfigureLocalMode TapBridge ConfigureLocal Mode - * - * In the ConfigureLocal mode, the configuration of the tap device is ns-3 - * configuration-centric. Configuration information is taken from a device - * in the ns-3 simulation and a tap device matching the ns-3 attributes is - * automatically created. In this case, a Linux computer is made to appear as - * if it was directly connected to a simulated ns-3 network. - * - * This is illustrated below: - * - * \verbatim - * +--------+ - * | Linux | - * | host | +----------+ - * | ------ | | ghost | - * | apps | | node | - * | ------ | | -------- | - * | stack | | IP | +----------+ - * | ------ | | stack | | node | - * | TAP | |==========| | -------- | - * | device | <----- IPC ------> | tap | | IP | - * +--------+ | bridge | | stack | - * | -------- | | -------- | - * | ns-3 | | ns-3 | - * | net | | net | - * | device | | device | - * +----------+ +----------+ - * || || - * +---------------------------+ - * | ns-3 channel | - * +---------------------------+ - * \endverbatim - * - * In this case, the "ns-3 net device" in the "ghost node" appears as if it - * were actually replacing the TAP device in the Linux host. The ns-3 - * simulation creates the TAP device on the underlying Linux OS and configures - * the IP and MAC addresses of the TAP device to match the values assigned to - * the simulated ns-3 net device. The "IPC" link shown above is the network - * tap mechanism in the underlying OS. The whole arrangement acts as a - * conventional bridge; but a bridge between devices that happen to have the - * same shared MAC and IP addresses. - * - * Here, the user is not required to provide any configuration information - * specific to the tap. A tap device will be created and configured by ns-3 - * according to its defaults, and the tap device will have its name assigned - * by the underlying operating system according to its defaults. - * - * If the user has a requirement to access the created tap device, he or she - * may optionally provide a "DeviceName" attribute. In this case, the created - * OS tap device will be named accordingly. - * - * The ConfigureLocal mode is the default operating mode of the Tap Bridge. - * - * \subsection TapBridgeUseLocalMode TapBridge UseLocal Mode - * - * The UseLocal mode is quite similar to the ConfigureLocal mode. The - * significant difference is, as the mode name implies, the TapBridge is - * going to "Use" an existing tap device previously created and configured - * by the user. This mode is particularly useful when a virtualization - * scheme automatically creates tap devices and ns-3 is used to provide - * simulated networks for those devices. - * - * \verbatim - * +--------+ - * | Linux | - * | host | +----------+ - * | ------ | | ghost | - * | apps | | node | - * | ------ | | -------- | - * | stack | | IP | +----------+ - * | ------ | | stack | | node | - * | TAP | |==========| | -------- | - * | device | <----- IPC ------> | tap | | IP | - * | MAC X | | bridge | | stack | - * +--------+ | -------- | | -------- | - * | ns-3 | | ns-3 | - * | net | | net | - * | device | | device | - * | MAC Y | | MAC Z | - * +----------+ +----------+ - * || || - * +---------------------------+ - * | ns-3 channel | - * +---------------------------+ - *\endverbatim - * - * In this case, the pre-configured MAC address of the "Tap device" (MAC X) - * will not be the same as that of the bridged "ns-3 net device" (MAC Y) shown - * in the illustration above. In order to bridge to ns-3 net devices which do - * not support SendFrom() (especially wireless STA nodes) we impose a requirement - * that only one Linux device (with one unique MAC address -- here X) generates - * traffic that flows across the IPC link. This is because the MAC addresses of - * traffic across the IPC link will be "spoofed" or changed to make it appear to - * Linux and ns-3 that they have the same address. That is, traffic moving from - * the Linux host to the ns-3 ghost node will have its MAC address changed from - * X to Y and traffic from the ghost node to the Linux host will have its MAC - * address changed from Y to X. Since there is a one-to-one correspondence - * between devices, there may only be one MAC source flowing from the Linux side. - * This means that Linux bridges with more than one net device added are - * incompatible with UseLocal mode. - * - * In UseLocal mode, the user is expected to create and configure a tap device - * completely outside the scope of the ns-3 simulation using something like: - * - * \verbatim - * sudo tunctl -t tap0 - * sudo ifconfig tap0 hw ether 08:00:2e:00:00:01 - * sudo ifconfig tap0 10.1.1.1 netmask 255.255.255.0 up - * \endverbatim - * - * To tell the TapBridge what is going on, the user will set either directly - * into the TapBridge or via the TapBridgeHelper, the "DeviceName" attribute. - * In the case of the configuration above, the "DeviceName" attribute would be - * set to "tap0" and the "Mode" attribute would be set to "UseLocal". - * - * One particular use case for this mode is in the OpenVZ environment. There it - * is possible to create a Tap device on the "Hardware Node" and move it into a - * Virtual Private Server. If the TapBridge is able to use an existing tap device - * it is then possible to avoid the overhead of an OS bridge in that environment. - * - * \subsection TapBridgeUseBridgeMode TapBridge UseBridge Mode - * - * The simplest mode for those familiar with Linux networking is the UseBridge - * mode. Again, the "Use" prefix indicates that the TapBridge is going to Use - * an existing configuration. In this case, the TapBridge is going to logically - * extend a Linux bridge into ns-3. - * - * This is illustrated below: - * - * \verbatim - * +---------+ - * | Linux | +----------+ - * | ------- | | ghost | - * | apps | | node | - * | ------- | | -------- | - * | stack | | IP | +----------+ - * | ------- | +--------+ | stack | | node | - * | Virtual | | TAP | |==========| | -------- | - * | Device | | Device | <---- IPC -----> | tap | | IP | - * +---------+ +--------+ | bridge | | stack | - * || || | -------- | | -------- | - * +--------------------+ | ns-3 | | ns-3 | - * | OS (brctl) Bridge | | net | | net | - * +--------------------+ | device | | device | - * +----------+ +----------+ - * || || - * +---------------------------+ - * | ns-3 channel | - * +---------------------------+ - * \endverbatim - * - * In this case, a computer running Linux applications, protocols, etc., is - * connected to a ns-3 simulated network in such a way as to make it appear - * to the Linux host that the TAP device is a real network device participating - * in the Linux bridge. - * - * In the ns-3 simulation, a TapBridge is created to match each TAP Device. - * The name of the TAP Device is assigned to the Tap Bridge using the - * "DeviceName" attribute. The TapBridge then logically extends the OS bridge - * to encompass the ns-3 net device. - * - * Since this mode logically extends an OS bridge, there may be many Linux net - * devices on the non-ns-3 side of the bridge. Therefore, like a net device on - * any bridge, the ns-3 net device must deal with the possibly of many source - * addresses. Thus, ns-3 devices must support SendFrom() - * (NetDevice::SupportsSendFrom() must return true) in order to be configured - * for use in UseBridge mode. - * - * It is expected that the user will do something like the following to - * configure the bridge and tap completely outside ns-3: - * - * \verbatim - * sudo brctl addbr mybridge - * sudo tunctl -t mytap - * sudo ifconfig mytap hw ether 00:00:00:00:00:01 - * sudo ifconfig mytap 0.0.0.0 up - * sudo brctl addif mybridge mytap - * sudo brctl addif mybridge ... - * sudo ifconfig mybridge 10.1.1.1 netmask 255.255.255.0 up - * \endverbatim - * - * To tell the TapBridge what is going on, the user will set either directly - * into the TapBridge or via the TapBridgeHelper, the "DeviceName" attribute. - * In the case of the configuration above, the "DeviceName" attribute would be - * set to "mytap" and the "Mode" attribute would be set to "UseBridge". - * - * This mode is especially useful in the case of virtualization where the - * configuration of the virtual hosts may be dictated by another system and - * not be changable to suit ns-3. For example, a particular VM scheme may create - * virtual "vethx" or "vmnetx" devices that appear local to virtual hosts. In - * order to connect to such systems, one would need to manually create TAP devices - * on the host system and brigde these TAP devices to the existing (VM) virtual - * devices. The job of the Tap Bridge in this case is to extend the bridge to - * join a ns-3 net device. - * - * \subsection TapBridgeConfigureLocalOperation TapBridge ConfigureLocal Operation - * - * In ConfigureLocal mode, the TapBridge and therefore its associated ns-3 net - * device appears to the Linux host computer as a network device just like any - * arbitrary "eth0" or "ath0" might appear. The creation and configuration - * of the TAP device is done by the ns-3 simulation and no manual configuration - * is required by the user. The IP addresses, MAC addresses, gateways, etc., - * for created TAP devices are extracted from the simulation itself by querying - * the configuration of the ns-3 device and the TapBridge Attributes. - * - * Since the MAC addresses are identical on the Linux side and the ns-3 side, - * we can use Send() on the ns-3 device which is available on all ns-3 net devices. - * Since the MAC addresses are identical there is no requirement to hook the - * promiscuous callback on the receive side. Therefore there are no restrictions - * on the kinds of net device that are usable in ConfigureLocal mode. - - * The TapBridge appears to an ns-3 simulation as a channel-less net device. - * This device must not have an IP address associated with it, but the bridged - * (ns-3) net device must have an IP address. Be aware that this is the inverse - * of an ns-3 BridgeNetDevice (or a conventional bridge in general) which - * demands that its bridge ports not have IP addresses, but allows the bridge - * device itself to have an IP address. - * - * The host computer will appear in a simulation as a "ghost" node that contains - * one TapBridge for each NetDevice that is being bridged. From the perspective - * of a simulation, the only difference between a ghost node and any other node - * will be the presence of the TapBridge devices. Note however, that the - * presence of the TapBridge does affect the connectivity of the net device to - * the IP stack of the ghost node. - * - * Configuration of address information and the ns-3 devices is not changed in - * any way if a TapBridge is present. A TapBridge will pick up the addressing - * information from the ns-3 net device to which it is connected (its "bridged" - * net device) and use that information to create and configure the TAP device - * on the real host. - * - * The end result of this is a situation where one can, for example, use the - * standard ping utility on a real host to ping a simulated ns-3 node. If - * correct routes are added to the internet host (this is expected to be done - * automatically in future ns-3 releases), the routing systems in ns-3 will - * enable correct routing of the packets across simulated ns-3 networks. - * For an example of this, see the example program, tap-wifi-dumbbell.cc in - * the ns-3 distribution. - * - * The Tap Bridge lives in a kind of a gray world somewhere between a Linux host - * and an ns-3 bridge device. From the Linux perspective, this code appears as - * the user mode handler for a TAP net device. In ConfigureLocal mode, this Tap - * device is automatically created by the ns-3 simulation. When the Linux host - * writes to one of these automatically created /dev/tap devices, the write is - * redirected into the TapBridge that lives in the ns-3 world; and from this - * perspective, the packet write on Linux becomes a packet read in the Tap Bridge. - * In other words, a Linux process writes a packet to a tap device and this packet - * is redirected by the network tap mechanism toan ns-3 process where it is - * received by the TapBridge as a result of a read operation there. The TapBridge - * then writes the packet to the ns-3 net device to which it is bridged; and - * therefore it appears as if the Linux host sent a packet directly through an - * ns-3 net device onto an ns-3 network. - * - * In the other direction, a packet received by the ns-3 net device connected to - * the Tap Bridge is sent via a receive callback to the TapBridge. The - * TapBridge then takes that packet and writes it back to the host using the - * network tap mechanism. This write to the device will appear to the Linux - * host as if a packet has arrived on a net device; and therefore as if a packet - * received by the ns-3 net device during a simulation has appeared on a real - * Linux net device. - * - * The upshot is that the Tap Bridge appears to bridge a tap device on a - * Linux host in the "real world" to an ns-3 net device in the simulation. - * Because the TAP device and the bridged ns-3 net device have the same MAC - * address and the network tap IPC link is not externalized, this particular - * kind of bridge makes it appear that a ns-3 net device is actually installed - * in the Linux host. - * - * In order to implement this on the ns-3 side, we need a "ghost node" in the - * simulation to hold the bridged ns-3 net device and the TapBridge. This node - * should not actually do anything else in the simulation since its job is - * simply to make the net device appear in Linux. This is not just arbitrary - * policy, it is because: - * - * - Bits sent to the TapBridge from higher layers in the ghost node (using - * the TapBridge Send method) are completely ignored. The TapBridge is - * not, itself, connected to any network, neither in Linux nor in ns-3. You - * can never send nor receive data over a TapBridge from the ghost node. - * - * - The bridged ns-3 net device has its receive callback disconnected - * from the ns-3 node and reconnected to the Tap Bridge. All data received - * by a bridged device will then be sent to the Linux host and will not be - * received by the node. From the perspective of the ghost node, you can - * send over this device but you cannot ever receive. - * - * Of course, if you understand all of the issues you can take control of - * your own destiny and do whatever you want -- we do not actively - * prevent you from using the ghost node for anything you decide. You - * will be able to perform typical ns-3 operations on the ghost node if - * you so desire. The internet stack, for example, must be there and - * functional on that node in order to participate in IP address - * assignment and global routing. However, as mentioned above, - * interfaces talking to any TapBridge or associated bridged net devices - * will not work completely. If you understand exactly what you are - * doing, you can set up other interfaces and devices on the ghost node - * and use them; or take advantage of the operational send side of the - * bridged devices to create traffic generators. We generally recommend - * that you treat this node as a ghost of the Linux host and leave it to - * itself, though. - * - * \subsection TapBridgeUseLocalOperation TapBridge UseLocal Mode Operation - * - * As described in above, the TapBridge acts like a bridge from the "real" world - * into the simulated ns-3 world. In the case of the ConfigureLocal mode, - * life is easy since the IP address of the Tap device matches the IP address of - * the ns-3 device and the MAC address of the Tap device matches the MAC address - * of the ns-3 device; and there is a one-to-one relationship between the - * devices. - * - * Things are slightly complicated when a Tap device is externally configured - * with a different MAC address than the ns-3 net device. The conventional way - * to deal with this kind of difference is to use promiscuous mode in the - * bridged device to receive packets destined for the different MAC address and - * forward them off to Linux. In order to move packets the other way, the - * conventional solution is SendFrom() which allows a caller to "spoof" or change - * the source MAC address to match the different Linux MAC address. - * - * We do have a specific requirement to be able to bridge Linux Virtual Machines - * onto wireless STA nodes. Unfortunately, the 802.11 spec doesn't provide a - * good way to implement SendFrom(), so we have to work around that problem. - * - * To this end, we provided the UseLocal mode of the Tap Bridge. This mode allows - * you approach the problem as if you were creating a bridge with a single net - * device. A single allowed address on the Linux side is remembered in the - * TapBridge, and all packets coming from the Linux side are repeated out the - * ns-3 side using the ns-3 device MAC source address. All packets coming in - * from the ns-3 side are repeated out the Linux side using the remembered MAC - * address. This allows us to use Send() on the ns-3 device side which is - * available on all ns-3 net devices. - * - * UseLocal mode is identical to the ConfigureLocal mode except for the creation - * and configuration of the tap device and the MAC address spoofing. - * - * \subsection TapBridgeUseBridgeOperation TapBridge UseBridge Operation - * - * As described in the ConfigureLocal mode section, when the Linux host writes to - * one of the /dev/tap devices, the write is redirected into the TapBridge - * that lives in the ns-3 world. In the case of the UseBridge mode, these - * packets will need to be sent out on the ns-3 network as if they were sent on - * a device participating in the Linux bridge. This means calling the - * SendFrom() method on the bridged device and providing the source MAC address - * found in the packet. - * - * In the other direction, a packet received by an ns-3 net device is hooked - * via callback to the TapBridge. This must be done in promiscuous mode since - * the goal is to bridge the ns-3 net device onto the OS (brctl) bridge of - * which the TAP device is a part. - * - * For these reasons, only ns-3 net devices that support SendFrom() and have a - * hookable promiscuous receive callback are allowed to participate in UseBridge - * mode TapBridge configurations. - * - * \section TapBridgeChannelModel Tap Bridge Channel Model - * - * There is no channel model associated with the Tap Bridge. In fact, the - * intention is make it appear that the real internet host is connected to - * the channel of the bridged net device. - * - * \section TapBridgeTracingModel Tap Bridge Tracing Model - * - * Unlike most ns-3 devices, the TapBridge does not provide any standard trace - * sources. This is because the bridge is an intermediary that is essentially - * one function call away from the bridged device. We expect that the trace - * hooks in the bridged device will be sufficient for most users, - * - * \section TapBridgeUsage Using the TapBridge - * - * We expect that most users will interact with the TapBridge device through - * the TapBridgeHelper. Users of other helper classes, such as CSMA or Wifi, - * should be comfortable with the idioms used there. + * This section documents the API of the ns-3 tap-bridge module. For a + * generic functional description, please refer to the ns-3 manual. */ diff --git a/src/tap-bridge/doc/tap.rst b/src/tap-bridge/doc/tap.rst index 9e94d35f4..2b865e3db 100644 --- a/src/tap-bridge/doc/tap.rst +++ b/src/tap-bridge/doc/tap.rst @@ -3,8 +3,408 @@ Tap NetDevice ------------- -*Placeholder chapter* - The Tap NetDevice can be used to allow a host system or virtual machines to -interact with a simulation. See ``examples/tap/tap-wifi-dumbbell.cc`` for an -example. +interact with a simulation. + +TapBridge Model Overview +************************ + +The Tap Bridge is designed to integrate "real" internet hosts (or more +precisely, hosts that support Tun/Tap devices) into ns-3 simulations. The +goal is to make it appear to a "real" host node in that it has an ns-3 net +device as a local device. The concept of a "real host" is a bit slippery +since the "real host" may actually be virtualized using readily available +technologies such as VMware, VirtualBox or OpenVZ. + +Since we are, in essence, connecting the inputs and outputs of an ns-3 net +device to the inputs and outputs of a Linux Tap net device, we call this +arrangement a Tap Bridge. + +There are three basic operating modes of this device available to users. +Basic functionality is essentially identical, but the modes are different +in details regarding how the arrangement is created and configured; +and what devices can live on which side of the bridge. + +We call these three modes the ConfigureLocal, UseLocal and UseBridge modes. +The first "word" in the camel case mode identifier indicates who has the +responsibility for creating and configuring the taps. For example, +the "Configure" in ConfigureLocal mode indicates that it is the TapBridge +that has responsibility for configuring the tap. In UseLocal mode and +UseBridge modes, the "Use" prefix indicates that the TapBridge is asked to +"Use" an existing configuration. + +In other words, in ConfigureLocal mode, the TapBridge has the responsibility +for creating and configuring the TAP devices. In UseBridge or UseLocal +modes, the user provides a configuration and the TapBridge adapts to that +configuration. + +TapBridge ConfigureLocal Mode ++++++++++++++++++++++++++++++ + +In the ConfigureLocal mode, the configuration of the tap device is ns-3 +configuration-centric. Configuration information is taken from a device +in the ns-3 simulation and a tap device matching the ns-3 attributes is +automatically created. In this case, a Linux computer is made to appear as +if it was directly connected to a simulated ns-3 network. + +This is illustrated below: :: + + +--------+ + | Linux | + | host | +----------+ + | ------ | | ghost | + | apps | | node | + | ------ | | -------- | + | stack | | IP | +----------+ + | ------ | | stack | | node | + | TAP | |==========| | -------- | + | device | <----- IPC ------> | tap | | IP | + +--------+ | bridge | | stack | + | -------- | | -------- | + | ns-3 | | ns-3 | + | net | | net | + | device | | device | + +----------+ +----------+ + || || + +---------------------------+ + | ns-3 channel | + +---------------------------+ + + +In this case, the "ns-3 net device" in the "ghost node" appears as if it +were actually replacing the TAP device in the Linux host. The ns-3 +simulation creates the TAP device on the underlying Linux OS and configures +the IP and MAC addresses of the TAP device to match the values assigned to +the simulated ns-3 net device. The "IPC" link shown above is the network +tap mechanism in the underlying OS. The whole arrangement acts as a +conventional bridge; but a bridge between devices that happen to have the +same shared MAC and IP addresses. + +Here, the user is not required to provide any configuration information +specific to the tap. A tap device will be created and configured by ns-3 +according to its defaults, and the tap device will have its name assigned +by the underlying operating system according to its defaults. + +If the user has a requirement to access the created tap device, he or she +may optionally provide a "DeviceName" attribute. In this case, the created +OS tap device will be named accordingly. + +The ConfigureLocal mode is the default operating mode of the Tap Bridge. + +TapBridge UseLocal Mode ++++++++++++++++++++++++ + +The UseLocal mode is quite similar to the ConfigureLocal mode. The +significant difference is, as the mode name implies, the TapBridge is +going to "Use" an existing tap device previously created and configured +by the user. This mode is particularly useful when a virtualization +scheme automatically creates tap devices and ns-3 is used to provide +simulated networks for those devices. :: + + +--------+ + | Linux | + | host | +----------+ + | ------ | | ghost | + | apps | | node | + | ------ | | -------- | + | stack | | IP | +----------+ + | ------ | | stack | | node | + | TAP | |==========| | -------- | + | device | <----- IPC ------> | tap | | IP | + | MAC X | | bridge | | stack | + +--------+ | -------- | | -------- | + | ns-3 | | ns-3 | + | net | | net | + | device | | device | + | MAC Y | | MAC Z | + +----------+ +----------+ + || || + +---------------------------+ + | ns-3 channel | + +---------------------------+ + +In this case, the pre-configured MAC address of the "Tap device" (MAC X) +will not be the same as that of the bridged "ns-3 net device" (MAC Y) shown +in the illustration above. In order to bridge to ns-3 net devices which do +not support SendFrom() (especially wireless STA nodes) we impose a requirement +that only one Linux device (with one unique MAC address -- here X) generates +traffic that flows across the IPC link. This is because the MAC addresses of +traffic across the IPC link will be "spoofed" or changed to make it appear to +Linux and ns-3 that they have the same address. That is, traffic moving from +the Linux host to the ns-3 ghost node will have its MAC address changed from +X to Y and traffic from the ghost node to the Linux host will have its MAC +address changed from Y to X. Since there is a one-to-one correspondence +between devices, there may only be one MAC source flowing from the Linux side. +This means that Linux bridges with more than one net device added are +incompatible with UseLocal mode. + +In UseLocal mode, the user is expected to create and configure a tap device +completely outside the scope of the ns-3 simulation using something like: :: + + sudo tunctl -t tap0 + sudo ifconfig tap0 hw ether 08:00:2e:00:00:01 + sudo ifconfig tap0 10.1.1.1 netmask 255.255.255.0 up + +To tell the TapBridge what is going on, the user will set either directly +into the TapBridge or via the TapBridgeHelper, the "DeviceName" attribute. +In the case of the configuration above, the "DeviceName" attribute would be +set to "tap0" and the "Mode" attribute would be set to "UseLocal". + +One particular use case for this mode is in the OpenVZ environment. There it +is possible to create a Tap device on the "Hardware Node" and move it into a +Virtual Private Server. If the TapBridge is able to use an existing tap device +it is then possible to avoid the overhead of an OS bridge in that environment. + +TapBridge UseBridge Mode +++++++++++++++++++++++++ + +The simplest mode for those familiar with Linux networking is the UseBridge +mode. Again, the "Use" prefix indicates that the TapBridge is going to Use +an existing configuration. In this case, the TapBridge is going to logically +extend a Linux bridge into ns-3. + +This is illustrated below: :: + + +---------+ + | Linux | +----------+ + | ------- | | ghost | + | apps | | node | + | ------- | | -------- | + | stack | | IP | +----------+ + | ------- | +--------+ | stack | | node | + | Virtual | | TAP | |==========| | -------- | + | Device | | Device | <---- IPC -----> | tap | | IP | + +---------+ +--------+ | bridge | | stack | + || || | -------- | | -------- | + +--------------------+ | ns-3 | | ns-3 | + | OS (brctl) Bridge | | net | | net | + +--------------------+ | device | | device | + +----------+ +----------+ + || || + +---------------------------+ + | ns-3 channel | + +---------------------------+ + +In this case, a computer running Linux applications, protocols, etc., is +connected to a ns-3 simulated network in such a way as to make it appear +to the Linux host that the TAP device is a real network device participating +in the Linux bridge. + +In the ns-3 simulation, a TapBridge is created to match each TAP Device. +The name of the TAP Device is assigned to the Tap Bridge using the +"DeviceName" attribute. The TapBridge then logically extends the OS bridge +to encompass the ns-3 net device. + +Since this mode logically extends an OS bridge, there may be many Linux net +devices on the non-ns-3 side of the bridge. Therefore, like a net device on +any bridge, the ns-3 net device must deal with the possibly of many source +addresses. Thus, ns-3 devices must support SendFrom() +(NetDevice::SupportsSendFrom() must return true) in order to be configured +for use in UseBridge mode. + +It is expected that the user will do something like the following to +configure the bridge and tap completely outside ns-3: :: + + sudo brctl addbr mybridge + sudo tunctl -t mytap + sudo ifconfig mytap hw ether 00:00:00:00:00:01 + sudo ifconfig mytap 0.0.0.0 up + sudo brctl addif mybridge mytap + sudo brctl addif mybridge ... + sudo ifconfig mybridge 10.1.1.1 netmask 255.255.255.0 up + +To tell the TapBridge what is going on, the user will set either directly +into the TapBridge or via the TapBridgeHelper, the "DeviceName" attribute. +In the case of the configuration above, the "DeviceName" attribute would be +set to "mytap" and the "Mode" attribute would be set to "UseBridge". + +This mode is especially useful in the case of virtualization where the +configuration of the virtual hosts may be dictated by another system and +not be changable to suit ns-3. For example, a particular VM scheme may create +virtual "vethx" or "vmnetx" devices that appear local to virtual hosts. In +order to connect to such systems, one would need to manually create TAP devices +on the host system and brigde these TAP devices to the existing (VM) virtual +devices. The job of the Tap Bridge in this case is to extend the bridge to +join a ns-3 net device. + +TapBridge ConfigureLocal Operation +++++++++++++++++++++++++++++++++++ + +In ConfigureLocal mode, the TapBridge and therefore its associated ns-3 net +device appears to the Linux host computer as a network device just like any +arbitrary "eth0" or "ath0" might appear. The creation and configuration +of the TAP device is done by the ns-3 simulation and no manual configuration +is required by the user. The IP addresses, MAC addresses, gateways, etc., +for created TAP devices are extracted from the simulation itself by querying +the configuration of the ns-3 device and the TapBridge Attributes. + +Since the MAC addresses are identical on the Linux side and the ns-3 side, +we can use Send() on the ns-3 device which is available on all ns-3 net devices. +Since the MAC addresses are identical there is no requirement to hook the +promiscuous callback on the receive side. Therefore there are no restrictions +on the kinds of net device that are usable in ConfigureLocal mode. + +The TapBridge appears to an ns-3 simulation as a channel-less net device. +This device must not have an IP address associated with it, but the bridged +(ns-3) net device must have an IP address. Be aware that this is the inverse +of an ns-3 BridgeNetDevice (or a conventional bridge in general) which +demands that its bridge ports not have IP addresses, but allows the bridge +device itself to have an IP address. + +The host computer will appear in a simulation as a "ghost" node that contains +one TapBridge for each NetDevice that is being bridged. From the perspective +of a simulation, the only difference between a ghost node and any other node +will be the presence of the TapBridge devices. Note however, that the +presence of the TapBridge does affect the connectivity of the net device to +the IP stack of the ghost node. + +Configuration of address information and the ns-3 devices is not changed in +any way if a TapBridge is present. A TapBridge will pick up the addressing +information from the ns-3 net device to which it is connected (its "bridged" +net device) and use that information to create and configure the TAP device +on the real host. + +The end result of this is a situation where one can, for example, use the +standard ping utility on a real host to ping a simulated ns-3 node. If +correct routes are added to the internet host (this is expected to be done +automatically in future ns-3 releases), the routing systems in ns-3 will +enable correct routing of the packets across simulated ns-3 networks. +For an example of this, see the example program, tap-wifi-dumbbell.cc in +the ns-3 distribution. + +The Tap Bridge lives in a kind of a gray world somewhere between a Linux host +and an ns-3 bridge device. From the Linux perspective, this code appears as +the user mode handler for a TAP net device. In ConfigureLocal mode, this Tap +device is automatically created by the ns-3 simulation. When the Linux host +writes to one of these automatically created /dev/tap devices, the write is +redirected into the TapBridge that lives in the ns-3 world; and from this +perspective, the packet write on Linux becomes a packet read in the Tap Bridge. +In other words, a Linux process writes a packet to a tap device and this packet +is redirected by the network tap mechanism toan ns-3 process where it is +received by the TapBridge as a result of a read operation there. The TapBridge +then writes the packet to the ns-3 net device to which it is bridged; and +therefore it appears as if the Linux host sent a packet directly through an +ns-3 net device onto an ns-3 network. + +In the other direction, a packet received by the ns-3 net device connected to +the Tap Bridge is sent via a receive callback to the TapBridge. The +TapBridge then takes that packet and writes it back to the host using the +network tap mechanism. This write to the device will appear to the Linux +host as if a packet has arrived on a net device; and therefore as if a packet +received by the ns-3 net device during a simulation has appeared on a real +Linux net device. + +The upshot is that the Tap Bridge appears to bridge a tap device on a +Linux host in the "real world" to an ns-3 net device in the simulation. +Because the TAP device and the bridged ns-3 net device have the same MAC +address and the network tap IPC link is not externalized, this particular +kind of bridge makes it appear that a ns-3 net device is actually installed +in the Linux host. + +In order to implement this on the ns-3 side, we need a "ghost node" in the +simulation to hold the bridged ns-3 net device and the TapBridge. This node +should not actually do anything else in the simulation since its job is +simply to make the net device appear in Linux. This is not just arbitrary +policy, it is because: + +- Bits sent to the TapBridge from higher layers in the ghost node (using + the TapBridge Send method) are completely ignored. The TapBridge is + not, itself, connected to any network, neither in Linux nor in ns-3. You + can never send nor receive data over a TapBridge from the ghost node. + +- The bridged ns-3 net device has its receive callback disconnected + from the ns-3 node and reconnected to the Tap Bridge. All data received + by a bridged device will then be sent to the Linux host and will not be + received by the node. From the perspective of the ghost node, you can + send over this device but you cannot ever receive. + +Of course, if you understand all of the issues you can take control of +your own destiny and do whatever you want -- we do not actively +prevent you from using the ghost node for anything you decide. You +will be able to perform typical ns-3 operations on the ghost node if +you so desire. The internet stack, for example, must be there and +functional on that node in order to participate in IP address +assignment and global routing. However, as mentioned above, +interfaces talking to any TapBridge or associated bridged net devices +will not work completely. If you understand exactly what you are +doing, you can set up other interfaces and devices on the ghost node +and use them; or take advantage of the operational send side of the +bridged devices to create traffic generators. We generally recommend +that you treat this node as a ghost of the Linux host and leave it to +itself, though. + +TapBridge UseLocal Mode Operation ++++++++++++++++++++++++++++++++++ + +As described in above, the TapBridge acts like a bridge from the "real" world +into the simulated ns-3 world. In the case of the ConfigureLocal mode, +life is easy since the IP address of the Tap device matches the IP address of +the ns-3 device and the MAC address of the Tap device matches the MAC address +of the ns-3 device; and there is a one-to-one relationship between the +devices. + +Things are slightly complicated when a Tap device is externally configured +with a different MAC address than the ns-3 net device. The conventional way +to deal with this kind of difference is to use promiscuous mode in the +bridged device to receive packets destined for the different MAC address and +forward them off to Linux. In order to move packets the other way, the +conventional solution is SendFrom() which allows a caller to "spoof" or change +the source MAC address to match the different Linux MAC address. + +We do have a specific requirement to be able to bridge Linux Virtual Machines +onto wireless STA nodes. Unfortunately, the 802.11 spec doesn't provide a +good way to implement SendFrom(), so we have to work around that problem. + +To this end, we provided the UseLocal mode of the Tap Bridge. This mode allows +you approach the problem as if you were creating a bridge with a single net +device. A single allowed address on the Linux side is remembered in the +TapBridge, and all packets coming from the Linux side are repeated out the +ns-3 side using the ns-3 device MAC source address. All packets coming in +from the ns-3 side are repeated out the Linux side using the remembered MAC +address. This allows us to use Send() on the ns-3 device side which is +available on all ns-3 net devices. + +UseLocal mode is identical to the ConfigureLocal mode except for the creation +and configuration of the tap device and the MAC address spoofing. + +TapBridge UseBridge Operation ++++++++++++++++++++++++++++++ + +As described in the ConfigureLocal mode section, when the Linux host writes to +one of the /dev/tap devices, the write is redirected into the TapBridge +that lives in the ns-3 world. In the case of the UseBridge mode, these +packets will need to be sent out on the ns-3 network as if they were sent on +a device participating in the Linux bridge. This means calling the +SendFrom() method on the bridged device and providing the source MAC address +found in the packet. + +In the other direction, a packet received by an ns-3 net device is hooked +via callback to the TapBridge. This must be done in promiscuous mode since +the goal is to bridge the ns-3 net device onto the OS (brctl) bridge of +which the TAP device is a part. + +For these reasons, only ns-3 net devices that support SendFrom() and have a +hookable promiscuous receive callback are allowed to participate in UseBridge +mode TapBridge configurations. + +Tap Bridge Channel Model +************************ + +There is no channel model associated with the Tap Bridge. In fact, the +intention is make it appear that the real internet host is connected to +the channel of the bridged net device. + +Tap Bridge Tracing Model +************************ + +Unlike most ns-3 devices, the TapBridge does not provide any standard trace +sources. This is because the bridge is an intermediary that is essentially +one function call away from the bridged device. We expect that the trace +hooks in the bridged device will be sufficient for most users, + +Using the TapBridge +******************* + +We expect that most users will interact with the TapBridge device through +the TapBridgeHelper. Users of other helper classes, such as CSMA or Wifi, +should be comfortable with the idioms used there. diff --git a/src/tap-bridge/examples/tap-csma.cc b/src/tap-bridge/examples/tap-csma.cc index 111a137de..81b2fb14a 100644 --- a/src/tap-bridge/examples/tap-csma.cc +++ b/src/tap-bridge/examples/tap-csma.cc @@ -76,8 +76,8 @@ main (int argc, char *argv[]) std::string tapName = "thetap"; CommandLine cmd; - cmd.AddValue("mode", "Mode setting of TapBridge", mode); - cmd.AddValue("tapName", "Name of the OS tap device", tapName); + cmd.AddValue ("mode", "Mode setting of TapBridge", mode); + cmd.AddValue ("tapName", "Name of the OS tap device", tapName); cmd.Parse (argc, argv); GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl")); diff --git a/src/tap-bridge/examples/tap-wifi-dumbbell.cc b/src/tap-bridge/examples/tap-wifi-dumbbell.cc index 712e896e9..cda61c9b2 100644 --- a/src/tap-bridge/examples/tap-wifi-dumbbell.cc +++ b/src/tap-bridge/examples/tap-wifi-dumbbell.cc @@ -121,8 +121,8 @@ main (int argc, char *argv[]) std::string tapName = "thetap"; CommandLine cmd; - cmd.AddValue("mode", "Mode setting of TapBridge", mode); - cmd.AddValue("tapName", "Name of the OS tap device", tapName); + cmd.AddValue ("mode", "Mode setting of TapBridge", mode); + cmd.AddValue ("tapName", "Name of the OS tap device", tapName); cmd.Parse (argc, argv); GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl")); @@ -195,7 +195,7 @@ main (int argc, char *argv[]) p2p.SetDeviceAttribute ("DataRate", StringValue ("512kbps")); p2p.SetChannelAttribute ("Delay", StringValue ("10ms")); - NodeContainer nodes = NodeContainer (nodesLeft.Get(3), nodesRight.Get (0)); + NodeContainer nodes = NodeContainer (nodesLeft.Get (3), nodesRight.Get (0)); NetDeviceContainer devices = p2p.Install (nodes); Ipv4AddressHelper ipv4; diff --git a/src/tap-bridge/helper/tap-bridge-helper.cc b/src/tap-bridge/helper/tap-bridge-helper.cc index 9f2330768..3e27dde77 100644 --- a/src/tap-bridge/helper/tap-bridge-helper.cc +++ b/src/tap-bridge/helper/tap-bridge-helper.cc @@ -38,7 +38,7 @@ TapBridgeHelper::TapBridgeHelper (Ipv4Address gateway) NS_LOG_FUNCTION_NOARGS (); m_deviceFactory.SetTypeId ("ns3::TapBridge"); SetAttribute ("Gateway", Ipv4AddressValue (gateway)); - SetAttribute ("Mode", EnumValue(TapBridge::CONFIGURE_LOCAL)); + SetAttribute ("Mode", EnumValue (TapBridge::CONFIGURE_LOCAL)); } void diff --git a/src/tap-bridge/model/tap-bridge.cc b/src/tap-bridge/model/tap-bridge.cc index 041643ee4..4a0ea6326 100644 --- a/src/tap-bridge/model/tap-bridge.cc +++ b/src/tap-bridge/model/tap-bridge.cc @@ -366,7 +366,7 @@ TapBridge::CreateTap (void) // // Now encode that socket name (family and path) as a string of hex digits // - std::string path = TapBufferToString((uint8_t *)&un, len); + std::string path = TapBufferToString ((uint8_t *)&un, len); NS_LOG_INFO ("Encoded Unix socket as \"" << path << "\""); // @@ -599,7 +599,7 @@ TapBridge::CreateTap (void) // so we call it "control." // size_t msg_size = sizeof(int); - char control[CMSG_SPACE(msg_size)]; + char control[CMSG_SPACE (msg_size)]; // // There is a msghdr that is used to minimize the number of parameters @@ -633,7 +633,7 @@ TapBridge::CreateTap (void) // one we're interested in. // struct cmsghdr *cmsg; - for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) + for (cmsg = CMSG_FIRSTHDR (&msg); cmsg != NULL; cmsg = CMSG_NXTHDR (&msg, cmsg)) { if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) @@ -996,14 +996,14 @@ TapBridge::ReceiveFromBridgedDevice ( } void -TapBridge::SetIfIndex(const uint32_t index) +TapBridge::SetIfIndex (const uint32_t index) { NS_LOG_FUNCTION_NOARGS (); m_ifIndex = index; } uint32_t -TapBridge::GetIfIndex(void) const +TapBridge::GetIfIndex (void) const { NS_LOG_FUNCTION_NOARGS (); return m_ifIndex; diff --git a/src/tap-bridge/model/tap-bridge.h b/src/tap-bridge/model/tap-bridge.h index 1b8d227a5..2bfdc0198 100644 --- a/src/tap-bridge/model/tap-bridge.h +++ b/src/tap-bridge/model/tap-bridge.h @@ -184,8 +184,8 @@ public: // The following methods are inherited from NetDevice base class and are // documented there. // - virtual void SetIfIndex(const uint32_t index); - virtual uint32_t GetIfIndex(void) const; + virtual void SetIfIndex (const uint32_t index); + virtual uint32_t GetIfIndex (void) const; virtual Ptr GetChannel (void) const; virtual void SetAddress (Address address); virtual Address GetAddress (void) const; diff --git a/src/tap-bridge/model/tap-creator.cc b/src/tap-bridge/model/tap-creator.cc index 124326b93..fd5abe13c 100644 --- a/src/tap-bridge/model/tap-creator.cc +++ b/src/tap-bridge/model/tap-creator.cc @@ -58,7 +58,7 @@ static int gVerbose = 0; // Set to true to turn on logging messages. #define ABORT_IF(cond, msg, printErrno) \ if (cond) \ { \ - ABORT(msg, printErrno); \ + ABORT (msg, printErrno); \ } // @@ -213,7 +213,7 @@ SendSocket (const char *path, int fd) // so we call it "control." // size_t msg_size = sizeof(int); - char control[CMSG_SPACE(msg_size)]; + char control[CMSG_SPACE (msg_size)]; // // There is a msghdr that is used to minimize the number of parameters @@ -247,10 +247,10 @@ SendSocket (const char *path, int fd) // the whole package we're sending. // struct cmsghdr *cmsg; - cmsg = CMSG_FIRSTHDR(&msg); + cmsg = CMSG_FIRSTHDR (&msg); cmsg->cmsg_level = SOL_SOCKET; cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(msg_size); + cmsg->cmsg_len = CMSG_LEN (msg_size); // // We also have to update the controllen in case other stuff is actually // in there we may not be aware of (due to macros). @@ -261,13 +261,13 @@ SendSocket (const char *path, int fd) // Finally, we get a pointer to the start of the ancillary data array and // put our file descriptor in. // - int *fdptr = (int*)(CMSG_DATA(cmsg)); + int *fdptr = (int*)(CMSG_DATA (cmsg)); *fdptr = fd; // // // Actually send the file descriptor back to the tap bridge. // - ssize_t len = sendmsg(sock, &msg, 0); + ssize_t len = sendmsg (sock, &msg, 0); ABORT_IF (len == -1, "Could not send socket back to tap bridge", 1); LOG ("sendmsg complete"); diff --git a/src/tap-bridge/model/tap-encode-decode.cc b/src/tap-bridge/model/tap-encode-decode.cc index 0f2529451..c5ff84f29 100644 --- a/src/tap-bridge/model/tap-encode-decode.cc +++ b/src/tap-bridge/model/tap-encode-decode.cc @@ -41,7 +41,7 @@ TapBufferToString (uint8_t *buffer, uint32_t len) // Tell the stream to make hex characters, zero-filled // oss.setf (std::ios::hex, std::ios::basefield); - oss.fill('0'); + oss.fill ('0'); // // Loop through the buffer, separating the two-digit-wide hex bytes diff --git a/src/tap-bridge/wscript b/src/tap-bridge/wscript index a341474c6..4ee038ab5 100644 --- a/src/tap-bridge/wscript +++ b/src/tap-bridge/wscript @@ -16,33 +16,32 @@ def configure(conf): if conf.env['ENABLE_TAP']: blddir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant())) - tapcreatordir = os.path.abspath(os.path.join(blddir, "src/devices/tap-bridge")) + tapcreatordir = os.path.abspath(os.path.join(blddir, "src/tap-bridge")) conf.env.append_value('NS3_EXECUTABLE_PATH', tapcreatordir) + else: + # Add this module to the list of modules that won't be built + # if they are enabled. + conf.env['MODULES_NOT_BUILT'].append('tap-bridge') def build(bld): + # Don't do anything for this module if tap-bridge's not enabled. + if not bld.env['ENABLE_TAP']: + return + module = bld.create_ns3_module('tap-bridge', ['network', 'internet']) module.source = [ + 'model/tap-bridge.cc', + 'model/tap-encode-decode.cc', + 'helper/tap-bridge-helper.cc', ] headers = bld.new_task_gen('ns3header') headers.module = 'tap-bridge' headers.source = [ + 'model/tap-bridge.h', + 'helper/tap-bridge-helper.h', 'doc/tap.h', ] - if not bld.env['ENABLE_TAP']: - return - - module.source.extend([ - 'model/tap-bridge.cc', - 'model/tap-encode-decode.cc', - 'helper/tap-bridge-helper.cc', - ]) - headers.source.extend([ - 'model/tap-bridge.h', - 'helper/tap-bridge-helper.h', - ]) - - if not bld.env['PLATFORM'].startswith('freebsd'): obj = bld.create_suid_program('tap-creator') obj.source = [ diff --git a/src/template/test/sample-test-suite.cc b/src/template/test/sample-test-suite.cc new file mode 100644 index 000000000..45e1be737 --- /dev/null +++ b/src/template/test/sample-test-suite.cc @@ -0,0 +1,63 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ + +// An essential include is test.h +#include "ns3/test.h" + +// Do not put your test classes in namespace ns3. You may find it useful +// to use the using directive to access the ns3 namespace directly +using namespace ns3; + +// This is an example TestCase. +class SampleTestCase1 : public TestCase +{ +public: + SampleTestCase1 (); + virtual ~SampleTestCase1 (); + +private: + virtual void DoRun (void); +}; + +// Add some help text to this case to describe what it is intended to test +SampleTestCase1::SampleTestCase1 () + : TestCase ("Sample test case (does nothing)") +{ +} + +// This destructor does nothing but we include it as a reminder that +// the test case should clean up after itself +SampleTestCase1::~SampleTestCase1 () +{ +} + +// +// This method is the pure virtual method from class TestCase that every +// TestCase must implement +// +void +SampleTestCase1::DoRun (void) +{ + // A wide variety of test macros are available in src/core/test.h + NS_TEST_ASSERT_MSG_EQ (true, true, "true doesn't equal true for some reason"); + // Use this one for floating point comparisons + NS_TEST_ASSERT_MSG_EQ_TOL (0.01, 0.01, 0.001, "Numbers are not equal within tolerance"); +} + +// The TestSuite class names the TestSuite, identifies what type of TestSuite, +// and enables the TestCases to be run. Typically, only the constructor for +// this class must be defined +// +class SampleTestSuite : public TestSuite +{ +public: + SampleTestSuite (); +}; + +SampleTestSuite::SampleTestSuite () + : TestSuite ("sample", UNIT) +{ + AddTestCase (new SampleTestCase1); +} + +// Do not forget to allocate an instance of this TestSuite +static SampleTestSuite sampleTestSuite; diff --git a/src/test/csma-system-test-suite.cc b/src/test/csma-system-test-suite.cc index 450dc2567..11af617d4 100644 --- a/src/test/csma-system-test-suite.cc +++ b/src/test/csma-system-test-suite.cc @@ -223,8 +223,8 @@ CsmaBroadcastTestCase::DoRun (void) NodeContainer c1 = NodeContainer (c.Get (0), c.Get (2)); CsmaHelper csma; - csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate(5000000))); - csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds(2))); + csma.SetChannelAttribute ("DataRate", DataRateValue (DataRate (5000000))); + csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2))); NetDeviceContainer n0 = csma.Install (c0); NetDeviceContainer n1 = csma.Install (c1); @@ -391,7 +391,7 @@ CsmaMulticastTestCase::DoRun (void) // 2) Set up a default multicast route on the sender n0 Ptr sender = c.Get (0); - Ptr senderIf = nd0.Get(0); + Ptr senderIf = nd0.Get (0); multicast.SetDefaultMulticastRoute (sender, senderIf); // @@ -416,12 +416,12 @@ CsmaMulticastTestCase::DoRun (void) // // Tell the application when to start and stop. // - srcC.Start(Seconds(1.)); - srcC.Stop (Seconds(10.)); + srcC.Start (Seconds (1.)); + srcC.Stop (Seconds (10.)); // Create an optional packet sink to receive these packets PacketSinkHelper sink ("ns3::UdpSocketFactory", - InetSocketAddress (Ipv4Address::GetAny(), multicastPort)); + InetSocketAddress (Ipv4Address::GetAny (), multicastPort)); ApplicationContainer sinkC = sink.Install (c1.Get (2)); // Node n4 // Start the sink @@ -550,7 +550,7 @@ CsmaOneSubnetTestCase::DoRun (void) onoff.SetAttribute ("Remote", AddressValue (InetSocketAddress (interfaces.GetAddress (0), port))); app = onoff.Install (nodes.Get (3)); - app.Start(Seconds (1.1)); + app.Start (Seconds (1.1)); app.Stop (Seconds (10.0)); app = sink.Install (nodes.Get (0)); @@ -630,8 +630,8 @@ CsmaPacketSocketTestCase::DoRun (void) // create the shared medium used by all csma devices. Ptr channel = CreateObjectWithAttributes ( - "DataRate", DataRateValue (DataRate(5000000)), - "Delay", TimeValue (MilliSeconds(2))); + "DataRate", DataRateValue (DataRate (5000000)), + "Delay", TimeValue (MilliSeconds (2))); // use a helper function to connect our nodes to the shared channel. CsmaHelper csma; @@ -643,7 +643,7 @@ CsmaPacketSocketTestCase::DoRun (void) // Make packets be sent about every DefaultPacketSize / DataRate = // 4096 bits / (5000 bits/second) = 0.82 second. PacketSocketAddress socket; - socket.SetSingleDevice(devs.Get (0)->GetIfIndex ()); + socket.SetSingleDevice (devs.Get (0)->GetIfIndex ()); socket.SetPhysicalAddress (devs.Get (1)->GetAddress ()); socket.SetProtocol (2); OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket)); diff --git a/src/test/error-model-test-suite.cc b/src/test/error-model-test-suite.cc index adeae95b9..e18921521 100644 --- a/src/test/error-model-test-suite.cc +++ b/src/test/error-model-test-suite.cc @@ -101,7 +101,7 @@ ErrorModelSimple::DoRun (void) output->TraceConnectWithoutContext ("PhyRxDrop", MakeCallback (&ErrorModelSimple::DropEvent, this)); // Send 10000 packets - Simulator::Schedule (Seconds (0), &SendPacket, 10000, input, output->GetAddress()); + Simulator::Schedule (Seconds (0), &SendPacket, 10000, input, output->GetAddress ()); Simulator::Run (); Simulator::Destroy (); diff --git a/src/test/global-routing-test-suite.cc b/src/test/global-routing-test-suite.cc index d7950cff1..f5c3ab742 100644 --- a/src/test/global-routing-test-suite.cc +++ b/src/test/global-routing-test-suite.cc @@ -95,7 +95,7 @@ DynamicGlobalRoutingTestCase::HandleRead (Ptr socket) Address from; while (packet = socket->RecvFrom (from)) { - if (packet->GetSize() == 0) + if (packet->GetSize () == 0) { //EOF break; } @@ -230,7 +230,7 @@ DynamicGlobalRoutingTestCase::DoRun (void) sink2->ShutdownSend (); sink2->SetRecvPktInfo (true); - sink2->SetRecvCallback (MakeCallback(&DynamicGlobalRoutingTestCase::HandleRead, this)); + sink2->SetRecvCallback (MakeCallback (&DynamicGlobalRoutingTestCase::HandleRead, this)); Ptr n1 = c.Get (1); Ptr ipv41 = n1->GetObject (); @@ -368,7 +368,7 @@ GlobalRoutingSlash32TestCase::DoRun (void) // 210 bytes at a rate of 448 Kb/s uint16_t port = 9; // Discard port (RFC 863) OnOffHelper onoff ("ns3::UdpSocketFactory", - Address (InetSocketAddress (ifInAddrC.GetLocal(), port))); + Address (InetSocketAddress (ifInAddrC.GetLocal (), port))); onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); onoff.SetAttribute ("DataRate", DataRateValue (DataRate (6000))); diff --git a/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc b/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc index cbef76136..07f4dd6b9 100644 --- a/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc +++ b/src/test/ns3tcp/ns3tcp-cwnd-test-suite.cc @@ -254,7 +254,7 @@ Ns3TcpCwndTestCase1::DoRun (void) // implementation that we consider a known good TCP. // std::string nscStack = "liblinux2.6.26.so"; - stack.SetTcp ("ns3::NscTcpL4Protocol", "Library", StringValue("liblinux2.6.26.so")); + stack.SetTcp ("ns3::NscTcpL4Protocol", "Library", StringValue ("liblinux2.6.26.so")); stack.Install (nodes.Get (1)); // @@ -271,7 +271,7 @@ Ns3TcpCwndTestCase1::DoRun (void) // just create a sink. // uint16_t sinkPort = 8080; - Address sinkAddress (InetSocketAddress(interfaces.GetAddress (1), sinkPort)); + Address sinkAddress (InetSocketAddress (interfaces.GetAddress (1), sinkPort)); PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort)); ApplicationContainer sinkApps = packetSinkHelper.Install (nodes.Get (1)); sinkApps.Start (Seconds (0.)); @@ -326,7 +326,7 @@ Ns3TcpCwndTestCase1::DoRun (void) pointToPoint.EnablePcapAll ("tcp-cwnd"); } - Simulator::Stop (Seconds(2)); + Simulator::Stop (Seconds (2)); Simulator::Run (); Simulator::Destroy (); @@ -436,11 +436,11 @@ Ns3TcpCwndTestCase2::DoRun (void) n2n3.Create (1); PointToPointHelper p2p1; - p2p1.SetDeviceAttribute ("DataRate", DataRateValue (DataRate(1000000))); - p2p1.SetChannelAttribute ("Delay", TimeValue (MilliSeconds(10))); + p2p1.SetDeviceAttribute ("DataRate", DataRateValue (DataRate (1000000))); + p2p1.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (10))); PointToPointHelper p2p2; - p2p2.SetDeviceAttribute ("DataRate", DataRateValue (DataRate(100000))); - p2p2.SetChannelAttribute ("Delay", TimeValue (MilliSeconds(10))); + p2p2.SetDeviceAttribute ("DataRate", DataRateValue (DataRate (100000))); + p2p2.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (10))); // And then install devices and channels connecting our topology. NetDeviceContainer dev0 = p2p1.Install (n0n1); @@ -475,7 +475,7 @@ Ns3TcpCwndTestCase2::DoRun (void) apps.Stop (Seconds (5.4)); // Create the socket for n0 - Address sinkAddress (InetSocketAddress(ipInterfs.GetAddress (1), servPort)); + Address sinkAddress (InetSocketAddress (ipInterfs.GetAddress (1), servPort)); Ptr ns3TcpSocket = Socket::CreateSocket (n0n1.Get (0), TcpSocketFactory::GetTypeId ()); ns3TcpSocket->TraceConnectWithoutContext ("CongestionWindow", MakeCallback (&Ns3TcpCwndTestCase2::CwndChange, this)); @@ -494,7 +494,7 @@ Ns3TcpCwndTestCase2::DoRun (void) } // Finally, set up the simulator to run. - Simulator::Stop (Seconds(5.4)); + Simulator::Stop (Seconds (5.4)); Simulator::Run (); Simulator::Destroy (); diff --git a/src/test/ns3tcp/ns3tcp-interop-test-suite.cc b/src/test/ns3tcp/ns3tcp-interop-test-suite.cc index 3d1c55232..a31516e8f 100644 --- a/src/test/ns3tcp/ns3tcp-interop-test-suite.cc +++ b/src/test/ns3tcp/ns3tcp-interop-test-suite.cc @@ -95,7 +95,7 @@ private: }; Ns3TcpInteroperabilityTestCase::Ns3TcpInteroperabilityTestCase () - : TestCase ("Check to see that the ns-3 TCP can work with liblinux2.6.26.so"), m_writeVectors(WRITE_VECTORS) + : TestCase ("Check to see that the ns-3 TCP can work with liblinux2.6.26.so"), m_writeVectors (WRITE_VECTORS) { } @@ -115,7 +115,7 @@ Ns3TcpInteroperabilityTestCase::DoSetup (void) if (m_writeVectors) { m_pcapFile.Open (m_pcapFilename, std::ios::out|std::ios::binary); - m_pcapFile.Init(PCAP_LINK_TYPE, PCAP_SNAPLEN); + m_pcapFile.Init (PCAP_LINK_TYPE, PCAP_SNAPLEN); } else { @@ -177,7 +177,7 @@ Ns3TcpInteroperabilityTestCase::Ipv4L3Tx (std::string context, Ptr uint8_t *actual = new uint8_t[readLen]; p->CopyData (actual, readLen); - uint32_t result = memcmp(actual, expected, readLen); + uint32_t result = memcmp (actual, expected, readLen); delete [] actual; @@ -230,7 +230,7 @@ Ns3TcpInteroperabilityTestCase::DoRun (void) // implementation that we consider a known good TCP. // std::string nscStack = "liblinux2.6.26.so"; - stack.SetTcp ("ns3::NscTcpL4Protocol", "Library", StringValue("liblinux2.6.26.so")); + stack.SetTcp ("ns3::NscTcpL4Protocol", "Library", StringValue ("liblinux2.6.26.so")); stack.Install (nodes.Get (1)); // @@ -246,7 +246,7 @@ Ns3TcpInteroperabilityTestCase::DoRun (void) // test, so just create a sink on node zero. // uint16_t sinkPort = 8080; - Address sinkAddress (InetSocketAddress(interfaces.GetAddress (0), sinkPort)); + Address sinkAddress (InetSocketAddress (interfaces.GetAddress (0), sinkPort)); PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort)); ApplicationContainer sinkApps = packetSinkHelper.Install (nodes.Get (0)); sinkApps.Start (Seconds (0.)); @@ -259,7 +259,7 @@ Ns3TcpInteroperabilityTestCase::DoRun (void) // OnOffHelper onOffHelper ("ns3::TcpSocketFactory", sinkAddress); onOffHelper.SetAttribute ("MaxBytes", UintegerValue (100000)); - ApplicationContainer sourceApps = onOffHelper.Install(nodes.Get(1)); + ApplicationContainer sourceApps = onOffHelper.Install (nodes.Get (1)); sourceApps.Start (Seconds (1.)); sourceApps.Stop (Seconds (10.)); @@ -294,7 +294,7 @@ Ns3TcpInteroperabilityTestCase::DoRun (void) pointToPoint.EnablePcapAll ("tcp-interop"); } - Simulator::Stop (Seconds(20)); + Simulator::Stop (Seconds (20)); Simulator::Run (); Simulator::Destroy (); } diff --git a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc b/src/test/ns3tcp/ns3tcp-loss-test-suite.cc index 8fd9c33c6..d4a8ac6c7 100644 --- a/src/test/ns3tcp/ns3tcp-loss-test-suite.cc +++ b/src/test/ns3tcp/ns3tcp-loss-test-suite.cc @@ -126,7 +126,7 @@ Ns3TcpLossTestCase::DoSetup (void) if (m_writeVectors) { m_pcapFile.Open (m_pcapFilename, std::ios::out|std::ios::binary); - m_pcapFile.Init(PCAP_LINK_TYPE, PCAP_SNAPLEN); + m_pcapFile.Init (PCAP_LINK_TYPE, PCAP_SNAPLEN); } else { @@ -188,7 +188,7 @@ Ns3TcpLossTestCase::Ipv4L3Tx (std::string context, Ptr packet, Ptr uint8_t *actual = new uint8_t[readLen]; p->CopyData (actual, readLen); - uint32_t result = memcmp(actual, expected, readLen); + uint32_t result = memcmp (actual, expected, readLen); delete [] actual; @@ -266,8 +266,8 @@ Ns3TcpLossTestCase::StartFlow (Ptr localSocket, // tell the tcp implementation to call WriteUntilBufferFull again // if we blocked and new tx buffer space becomes available localSocket->SetSendCallback (MakeCallback - (&Ns3TcpLossTestCase::WriteUntilBufferFull, - this)); + (&Ns3TcpLossTestCase::WriteUntilBufferFull, + this)); WriteUntilBufferFull (localSocket, localSocket->GetTxAvailable ()); } @@ -363,8 +363,8 @@ Ns3TcpLossTestCase::DoRun (void) MakeCallback (&Ns3TcpLossTestCase::Ipv4L3Tx, this)); Config::ConnectWithoutContext - ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow", - MakeCallback (&Ns3TcpLossTestCase::CwndTracer, this)); + ("/NodeList/0/$ns3::TcpL4Protocol/SocketList/0/CongestionWindow", + MakeCallback (&Ns3TcpLossTestCase::CwndTracer, this)); //////////////////////////////////////////////////////// // Set up loss model at node k1 diff --git a/src/test/ns3tcp/ns3tcp-socket-test-suite.cc b/src/test/ns3tcp/ns3tcp-socket-test-suite.cc index d983cb8e6..36d12f26a 100644 --- a/src/test/ns3tcp/ns3tcp-socket-test-suite.cc +++ b/src/test/ns3tcp/ns3tcp-socket-test-suite.cc @@ -118,18 +118,18 @@ Ns3TcpSocketTestCase1::DoRun (void) Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx", MakeCallback (&Ns3TcpSocketTestCase1::SinkRx, this)); - Simulator::Schedule(Seconds (2), &SocketWriter::Connect, socketWriter); + Simulator::Schedule (Seconds (2), &SocketWriter::Connect, socketWriter); // Send 1, 10, 100, 1000 bytes - Simulator::Schedule(Seconds (10), &SocketWriter::Write, socketWriter, 1); + Simulator::Schedule (Seconds (10), &SocketWriter::Write, socketWriter, 1); m_inputs.Add (1); - Simulator::Schedule(Seconds (12), &SocketWriter::Write, socketWriter, 10); + Simulator::Schedule (Seconds (12), &SocketWriter::Write, socketWriter, 10); m_inputs.Add (10); - Simulator::Schedule(Seconds (14), &SocketWriter::Write, socketWriter, 100); + Simulator::Schedule (Seconds (14), &SocketWriter::Write, socketWriter, 100); m_inputs.Add (100); - Simulator::Schedule(Seconds (16), &SocketWriter::Write, socketWriter, 1000); + Simulator::Schedule (Seconds (16), &SocketWriter::Write, socketWriter, 1000); m_inputs.Add (536); m_inputs.Add (464); // ns-3 TCP default segment size of 536 - Simulator::Schedule(writerStopTimeObj, &SocketWriter::Close, socketWriter); + Simulator::Schedule (writerStopTimeObj, &SocketWriter::Close, socketWriter); if (m_writeResults) { @@ -227,22 +227,22 @@ Ns3TcpSocketTestCase2::DoRun (void) Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx", MakeCallback (&Ns3TcpSocketTestCase2::SinkRx, this)); - Simulator::Schedule(Seconds (2), &SocketWriter::Connect, socketWriter); + Simulator::Schedule (Seconds (2), &SocketWriter::Connect, socketWriter); // Send 1, 10, 100, 1000 bytes // PointToPoint default MTU is 576 bytes, which leaves 536 bytes for TCP - Simulator::Schedule(Seconds (10), &SocketWriter::Write, socketWriter, 1); + Simulator::Schedule (Seconds (10), &SocketWriter::Write, socketWriter, 1); m_inputs.Add (1); - Simulator::Schedule(Seconds (12), &SocketWriter::Write, socketWriter, 10); + Simulator::Schedule (Seconds (12), &SocketWriter::Write, socketWriter, 10); m_inputs.Add (10); - Simulator::Schedule(Seconds (14), &SocketWriter::Write, socketWriter, 100); + Simulator::Schedule (Seconds (14), &SocketWriter::Write, socketWriter, 100); m_inputs.Add (100); - Simulator::Schedule(Seconds (16), &SocketWriter::Write, socketWriter, 1000); + Simulator::Schedule (Seconds (16), &SocketWriter::Write, socketWriter, 1000); m_inputs.Add (1000); // Next packet will fragment - Simulator::Schedule(Seconds (16), &SocketWriter::Write, socketWriter, 1001); + Simulator::Schedule (Seconds (16), &SocketWriter::Write, socketWriter, 1001); m_inputs.Add (1000); m_inputs.Add (1); - Simulator::Schedule(writerStopTimeObj, &SocketWriter::Close, socketWriter); + Simulator::Schedule (writerStopTimeObj, &SocketWriter::Close, socketWriter); if (m_writeResults) { diff --git a/src/test/ns3tcp/ns3tcp-state-test-suite.cc b/src/test/ns3tcp/ns3tcp-state-test-suite.cc index 08150c63a..5fd3d1bee 100644 --- a/src/test/ns3tcp/ns3tcp-state-test-suite.cc +++ b/src/test/ns3tcp/ns3tcp-state-test-suite.cc @@ -121,7 +121,7 @@ Ns3TcpStateTestCase::DoSetup (void) if (m_writeVectors) { m_pcapFile.Open (m_pcapFilename, std::ios::out|std::ios::binary); - m_pcapFile.Init(PCAP_LINK_TYPE, PCAP_SNAPLEN); + m_pcapFile.Init (PCAP_LINK_TYPE, PCAP_SNAPLEN); } else { @@ -183,7 +183,7 @@ Ns3TcpStateTestCase::Ipv4L3Tx (std::string context, Ptr packet, Pt uint8_t *actual = new uint8_t[readLen]; p->CopyData (actual, readLen); - uint32_t result = memcmp(actual, expected, readLen); + uint32_t result = memcmp (actual, expected, readLen); delete [] actual; @@ -253,8 +253,8 @@ Ns3TcpStateTestCase::StartFlow (Ptr localSocket, // tell the tcp implementation to call WriteUntilBufferFull again // if we blocked and new tx buffer space becomes available localSocket->SetSendCallback (MakeCallback - (&Ns3TcpStateTestCase::WriteUntilBufferFull, - this)); + (&Ns3TcpStateTestCase::WriteUntilBufferFull, + this)); WriteUntilBufferFull (localSocket, localSocket->GetTxAvailable ()); } @@ -378,7 +378,7 @@ Ns3TcpStateTestCase::DoRun (void) caseDescription = "Immediate FIN upon SYN_RCVD"; m_needToClose = false; dropListN0.push_back (1); // Hide the ACK in 3WHS - Simulator::Schedule (Seconds(0.002), &Socket::Close, localSocket); + Simulator::Schedule (Seconds (0.002), &Socket::Close, localSocket); break; case 6: m_totalTxBytes = 5000; @@ -390,7 +390,7 @@ Ns3TcpStateTestCase::DoRun (void) caseDescription = "FIN check 1: Loss of initiator's FIN. Wait until app close"; m_needToClose = false; dropListN0.push_back (7); // Hide the FIN from n0 - Simulator::Schedule (Seconds(0.04), &Socket::Close, localSocket); + Simulator::Schedule (Seconds (0.04), &Socket::Close, localSocket); break; case 8: m_totalTxBytes = 5000; diff --git a/src/test/ns3tcp/nsctcp-loss-test-suite.cc b/src/test/ns3tcp/nsctcp-loss-test-suite.cc index ed126e4f1..7b97f7c8c 100644 --- a/src/test/ns3tcp/nsctcp-loss-test-suite.cc +++ b/src/test/ns3tcp/nsctcp-loss-test-suite.cc @@ -97,7 +97,7 @@ NscTcpLossTestCase1::DoRun (void) devices = pointToPoint.Install (n0, n1); InternetStackHelper internet; - internet.SetTcp ("ns3::NscTcpL4Protocol", "Library", StringValue("liblinux2.6.26.so")); + internet.SetTcp ("ns3::NscTcpL4Protocol", "Library", StringValue ("liblinux2.6.26.so")); internet.InstallAll (); Ipv4AddressHelper address; @@ -121,10 +121,10 @@ NscTcpLossTestCase1::DoRun (void) Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx", MakeCallback (&NscTcpLossTestCase1::SinkRx, this)); - Simulator::Schedule(Seconds (2), &SocketWriter::Connect, socketWriter); - Simulator::Schedule(Seconds (10), &SocketWriter::Write, socketWriter, 500); + Simulator::Schedule (Seconds (2), &SocketWriter::Connect, socketWriter); + Simulator::Schedule (Seconds (10), &SocketWriter::Write, socketWriter, 500); m_inputs.Add (500); - Simulator::Schedule(writerStopTimeObj, &SocketWriter::Close, socketWriter); + Simulator::Schedule (writerStopTimeObj, &SocketWriter::Close, socketWriter); std::list sampleList; // Lose first two SYNs @@ -205,7 +205,7 @@ NscTcpLossTestCase2::DoRun (void) devices = pointToPoint.Install (n0, n1); InternetStackHelper internet; - internet.SetTcp ("ns3::NscTcpL4Protocol", "Library", StringValue("liblinux2.6.26.so")); + internet.SetTcp ("ns3::NscTcpL4Protocol", "Library", StringValue ("liblinux2.6.26.so")); internet.InstallAll (); Ipv4AddressHelper address; @@ -229,10 +229,10 @@ NscTcpLossTestCase2::DoRun (void) Config::Connect ("/NodeList/*/ApplicationList/*/$ns3::PacketSink/Rx", MakeCallback (&NscTcpLossTestCase2::SinkRx, this)); - Simulator::Schedule(Seconds (2), &SocketWriter::Connect, socketWriter); - Simulator::Schedule(Seconds (10), &SocketWriter::Write, socketWriter, 500); + Simulator::Schedule (Seconds (2), &SocketWriter::Connect, socketWriter); + Simulator::Schedule (Seconds (10), &SocketWriter::Write, socketWriter, 500); m_inputs.Add (500); - Simulator::Schedule(writerStopTimeObj, &SocketWriter::Close, socketWriter); + Simulator::Schedule (writerStopTimeObj, &SocketWriter::Close, socketWriter); std::list sampleList; // Lose first data segment diff --git a/src/test/ns3tcp/wscript b/src/test/ns3tcp/wscript index 681ae1e0f..514353eab 100644 --- a/src/test/ns3tcp/wscript +++ b/src/test/ns3tcp/wscript @@ -1,9 +1,20 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- +import sys + def configure(conf): - pass + # Add the ns3tcp module to the list of enabled modules that + # should not be built if this is a static build on Darwin. They + # don't work there for the ns3tcp module, and this is probably + # because the ns3tcp module has no source files. + if conf.env['ENABLE_STATIC_NS3'] and sys.platform == 'darwin': + conf.env['MODULES_NOT_BUILT'].append('ns3tcp') def build(bld): + # Don't do anything for this module if it should not be built. + if 'ns3tcp' in bld.env['MODULES_NOT_BUILT']: + return + ns3tcp = bld.create_ns3_module('ns3tcp', ['internet', 'point-to-point', 'csma', 'applications']) headers = bld.new_task_gen('ns3header') headers.module = 'ns3tcp' diff --git a/src/test/ns3wifi/wifi-interference-test-suite.cc b/src/test/ns3wifi/wifi-interference-test-suite.cc index ef01f5db2..33de052a0 100644 --- a/src/test/ns3wifi/wifi-interference-test-suite.cc +++ b/src/test/ns3wifi/wifi-interference-test-suite.cc @@ -155,7 +155,7 @@ WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prs // ns-3 supports RadioTap and Prism tracing extensions for 802.11b wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); - YansWifiChannelHelper wifiChannel ; + YansWifiChannelHelper wifiChannel; wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel"); wifiChannel.AddPropagationLoss ("ns3::LogDistancePropagationLossModel"); wifiPhy.SetChannel (wifiChannel.Create ()); @@ -163,8 +163,8 @@ WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prs // Add a non-QoS upper mac, and disable rate control NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default (); wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", - "DataMode",StringValue(phyMode), - "ControlMode",StringValue(phyMode)); + "DataMode",StringValue (phyMode), + "ControlMode",StringValue (phyMode)); // Set it to adhoc mode wifiMac.SetType ("ns3::AdhocWifiMac"); NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, c.Get (0)); @@ -197,7 +197,7 @@ WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prs TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory"); Ptr recvSink = Socket::CreateSocket (c.Get (0), tid); - InetSocketAddress local = InetSocketAddress (Ipv4Address("10.1.1.1"), 80); + InetSocketAddress local = InetSocketAddress (Ipv4Address ("10.1.1.1"), 80); recvSink->Bind (local); recvSink->SetRecvCallback (MakeCallback (&WifiInterferenceTestCase::ReceivePacket, this)); diff --git a/src/test/ns3wifi/wifi-msdu-aggregator-test-suite.cc b/src/test/ns3wifi/wifi-msdu-aggregator-test-suite.cc index 705bda6c5..0f1002693 100644 --- a/src/test/ns3wifi/wifi-msdu-aggregator-test-suite.cc +++ b/src/test/ns3wifi/wifi-msdu-aggregator-test-suite.cc @@ -134,8 +134,8 @@ WifiMsduAggregatorThroughputTest::DoRun (void) // and then off at 9 seconds, so we turn the sink off at 9 seconds // too in order to measure throughput in a fixed window. PacketSinkHelper packetSink ("ns3::UdpSocketFactory", - InetSocketAddress(Ipv4Address::GetAny(), - udpPort)); + InetSocketAddress (Ipv4Address::GetAny (), + udpPort)); ApplicationContainer sinkApp = packetSink.Install (sta.Get (0)); sinkApp.Start (Seconds (0)); sinkApp.Stop (Seconds (9.0)); @@ -149,8 +149,8 @@ WifiMsduAggregatorThroughputTest::DoRun (void) OnOffHelper onoff ("ns3::UdpSocketFactory", InetSocketAddress (staNodeInterface.GetAddress (0), udpPort)); - onoff.SetAttribute ("DataRate", DataRateValue(DataRate("1Mbps"))); - onoff.SetAttribute ("PacketSize", UintegerValue(100)); + onoff.SetAttribute ("DataRate", DataRateValue (DataRate ("1Mbps"))); + onoff.SetAttribute ("PacketSize", UintegerValue (100)); onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); ApplicationContainer sourceApp = onoff.Install (ap.Get (0)); @@ -185,9 +185,9 @@ WifiMsduAggregatorThroughputTest::DoRun (void) // // If aggregation is turned off, then we get about 350 kilobytes in // the same test, so we'll definitely catch the major failures. - NS_TEST_ASSERT_MSG_GT(totalOctetsThrough, 600000, - "A-MSDU test fails for low throughput of " - << totalOctetsThrough << " octets"); + NS_TEST_ASSERT_MSG_GT (totalOctetsThrough, 600000, + "A-MSDU test fails for low throughput of " + << totalOctetsThrough << " octets"); } diff --git a/src/test/ns3wifi/wscript b/src/test/ns3wifi/wscript index 79b2846ac..13feb446c 100644 --- a/src/test/ns3wifi/wscript +++ b/src/test/ns3wifi/wscript @@ -1,9 +1,20 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- +import sys + def configure(conf): - pass + # Add the ns3wifi module to the list of enabled modules that + # should not be built if this is a static build on Darwin. They + # don't work there for the ns3wifi module, and this is probably + # because the ns3wifi module has no source files. + if conf.env['ENABLE_STATIC_NS3'] and sys.platform == 'darwin': + conf.env['MODULES_NOT_BUILT'].append('ns3wifi') def build(bld): + # Don't do anything for this module if it should not be built. + if 'ns3wifi' in bld.env['MODULES_NOT_BUILT']: + return + ns3wifi = bld.create_ns3_module('ns3wifi', ['internet', 'mobility', 'propagation', 'wifi', 'applications']) headers = bld.new_task_gen('ns3header') headers.module = 'ns3wifi' diff --git a/src/test/wscript b/src/test/wscript index b5235c5da..56e15765d 100644 --- a/src/test/wscript +++ b/src/test/wscript @@ -1,10 +1,25 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- +import sys + def configure(conf): conf.sub_config('perf') + conf.sub_config('ns3tcp') + conf.sub_config('ns3wifi') + + # Add the test module to the list of enabled modules that should + # not be built if this is a static build on Darwin. They don't + # work there for the test module, and this is probably because the + # test module has no source files. + if conf.env['ENABLE_STATIC_NS3'] and sys.platform == 'darwin': + conf.env['MODULES_NOT_BUILT'].append('test') def build(bld): - test = bld.create_ns3_module('test', ['internet', 'mobility', 'applications', 'csma', 'bridge', 'config-store', 'tools', 'point-to-point', 'csma-layout']) + # Don't do anything for this module if it should not be built. + if 'test' in bld.env['MODULES_NOT_BUILT']: + return + + test = bld.create_ns3_module('test', ['internet', 'mobility', 'applications', 'csma', 'bridge', 'config-store', 'tools', 'point-to-point', 'csma-layout', 'flow-monitor']) headers = bld.new_task_gen('ns3header') headers.module = 'test' diff --git a/src/tools/model/average.h b/src/tools/model/average.h index 1bdec4cb3..4c20a5f21 100644 --- a/src/tools/model/average.h +++ b/src/tools/model/average.h @@ -82,9 +82,9 @@ public: /// Estimate of mean, alias to Avg double Mean () const { return Avg (); } /// Unbiased estimate of variance - double Var () const { return Count() / (double)(Count() - 1) * (m_avg2 - m_avg*m_avg); } + double Var () const { return Count () / (double)(Count () - 1) * (m_avg2 - m_avg*m_avg); } /// Standard deviation - double Stddev () const { return sqrt (Var ());} + double Stddev () const { return sqrt (Var ()); } //\} /** @@ -97,11 +97,11 @@ public: */ //\{ /// Margin of error of the mean for 90% confidence level - double Error90() const { return 1.645 * sqrt (Var () / Count ()); } + double Error90 () const { return 1.645 * sqrt (Var () / Count ()); } /// Margin of error of the mean for 95% confidence level - double Error95() const { return 1.960 * sqrt (Var () / Count ()); } + double Error95 () const { return 1.960 * sqrt (Var () / Count ()); } /// Margin of error of the mean for 99% confidence level - double Error99() const { return 2.576 * sqrt (Var () / Count ()); } + double Error99 () const { return 2.576 * sqrt (Var () / Count ()); } //\} private: @@ -117,7 +117,7 @@ std::ostream & operator<< (std::ostream & os, Average const & x) if (x.Count () != 0) os << x.Avg () << " (" << x.Stddev () << ") [" << x.Min () << ", " << x.Max () << "]"; else - os << "NA"; // not available + os << "NA"; // not available return os; } } diff --git a/src/tools/model/event-garbage-collector.cc b/src/tools/model/event-garbage-collector.cc index eb0c8bc60..8562de847 100644 --- a/src/tools/model/event-garbage-collector.cc +++ b/src/tools/model/event-garbage-collector.cc @@ -65,7 +65,7 @@ EventGarbageCollector::Cleanup () m_events.erase (iter++); } else - break; // EventIds are sorted by timestamp => further events are not expired for sure + break; // EventIds are sorted by timestamp => further events are not expired for sure } // If after cleanup we are still over the limit, increase the limit. diff --git a/src/tools/model/gnuplot.cc b/src/tools/model/gnuplot.cc index 4c7c9880b..b0b8c50fa 100644 --- a/src/tools/model/gnuplot.cc +++ b/src/tools/model/gnuplot.cc @@ -47,26 +47,26 @@ struct GnuplotDataset::Data /** * Returns "plot" or "splot". */ - virtual std::string GetCommand() const = 0; + virtual std::string GetCommand () const = 0; /** * Prints the plot description used as argument to (s)plot. Either the * function expression or a datafile description. Should include m_title and * m_extra in the output. */ - virtual void PrintExpression(std::ostream &os) const = 0; + virtual void PrintExpression (std::ostream &os) const = 0; /** * Print the inline data file contents trailing the plot command. Empty for * functions. */ - virtual void PrintDatafile(std::ostream &os) const = 0; + virtual void PrintDatafile (std::ostream &os) const = 0; }; GnuplotDataset::Data::Data(const std::string& title) - : m_references(1), - m_title(title), - m_extra(m_defaultExtra) + : m_references (1), + m_title (title), + m_extra (m_defaultExtra) { } @@ -79,12 +79,12 @@ GnuplotDataset::Data::~Data() std::string GnuplotDataset::m_defaultExtra = ""; GnuplotDataset::GnuplotDataset (struct Data* data) - : m_data(data) + : m_data (data) { } GnuplotDataset::GnuplotDataset (const GnuplotDataset& original) - : m_data(original.m_data) + : m_data (original.m_data) { ++m_data->m_references; } @@ -141,30 +141,30 @@ struct Gnuplot2dDataset::Data2d : public GnuplotDataset::Data */ Data2d(const std::string& title); - virtual std::string GetCommand() const; - virtual void PrintExpression(std::ostream &os) const; - virtual void PrintDatafile(std::ostream &os) const; + virtual std::string GetCommand () const; + virtual void PrintExpression (std::ostream &os) const; + virtual void PrintDatafile (std::ostream &os) const; }; Gnuplot2dDataset::Data2d::Data2d(const std::string& title) - : Data(title), - m_style(m_defaultStyle), - m_errorBars(m_defaultErrorBars) + : Data (title), + m_style (m_defaultStyle), + m_errorBars (m_defaultErrorBars) { } std::string -Gnuplot2dDataset::Data2d::GetCommand() const +Gnuplot2dDataset::Data2d::GetCommand () const { return "plot"; } void -Gnuplot2dDataset::Data2d::PrintExpression(std::ostream &os) const +Gnuplot2dDataset::Data2d::PrintExpression (std::ostream &os) const { os << "'-' "; - if (m_title.size()) + if (m_title.size ()) os << " title '" << m_title << "'"; switch (m_style) { @@ -222,12 +222,12 @@ Gnuplot2dDataset::Data2d::PrintExpression(std::ostream &os) const break; } - if (m_extra.size()) + if (m_extra.size ()) os << " " << m_extra; } void -Gnuplot2dDataset::Data2d::PrintDatafile(std::ostream &os) const +Gnuplot2dDataset::Data2d::PrintDatafile (std::ostream &os) const { for (PointSet::const_iterator i = m_pointset.begin (); i != m_pointset.end (); ++i) @@ -261,7 +261,7 @@ enum Gnuplot2dDataset::Style Gnuplot2dDataset::m_defaultStyle = LINES; enum Gnuplot2dDataset::ErrorBars Gnuplot2dDataset::m_defaultErrorBars = NONE; Gnuplot2dDataset::Gnuplot2dDataset (const std::string& title) - : GnuplotDataset( new Data2d(title) ) + : GnuplotDataset ( new Data2d (title) ) { } @@ -332,7 +332,7 @@ Gnuplot2dDataset::Add (double x, double y, double minY, double maxY) } void -Gnuplot2dDataset::AddEmptyLine() +Gnuplot2dDataset::AddEmptyLine () { struct Point data; data.empty = true; @@ -352,44 +352,44 @@ struct Gnuplot2dFunction::Function2d : public GnuplotDataset::Data */ Function2d(const std::string& title, const std::string& function); - virtual std::string GetCommand() const; - virtual void PrintExpression(std::ostream &os) const; - virtual void PrintDatafile(std::ostream &os) const; + virtual std::string GetCommand () const; + virtual void PrintExpression (std::ostream &os) const; + virtual void PrintDatafile (std::ostream &os) const; }; Gnuplot2dFunction::Function2d::Function2d(const std::string& title, const std::string& function) - : Data(title), - m_function(function) + : Data (title), + m_function (function) { } std::string -Gnuplot2dFunction::Function2d::GetCommand() const +Gnuplot2dFunction::Function2d::GetCommand () const { return "plot"; } void -Gnuplot2dFunction::Function2d::PrintExpression(std::ostream &os) const +Gnuplot2dFunction::Function2d::PrintExpression (std::ostream &os) const { os << m_function; - if (m_title.size()) + if (m_title.size ()) os << " title '" << m_title << "'"; - if (m_extra.size()) + if (m_extra.size ()) os << " " << m_extra; } void -Gnuplot2dFunction::Function2d::PrintDatafile(std::ostream &os) const +Gnuplot2dFunction::Function2d::PrintDatafile (std::ostream &os) const { } // --- Gnuplot2dFunction --------------------------------------------------- // Gnuplot2dFunction::Gnuplot2dFunction (const std::string& title, const std::string& function) - : GnuplotDataset( new Function2d(title, function) ) + : GnuplotDataset ( new Function2d (title, function) ) { } @@ -414,40 +414,40 @@ struct Gnuplot3dDataset::Data3d : public GnuplotDataset::Data */ Data3d(const std::string& title); - virtual std::string GetCommand() const; - virtual void PrintExpression(std::ostream &os) const; - virtual void PrintDatafile(std::ostream &os) const; + virtual std::string GetCommand () const; + virtual void PrintExpression (std::ostream &os) const; + virtual void PrintDatafile (std::ostream &os) const; }; Gnuplot3dDataset::Data3d::Data3d(const std::string& title) - : Data(title), - m_style(m_defaultStyle) + : Data (title), + m_style (m_defaultStyle) { } std::string -Gnuplot3dDataset::Data3d::GetCommand() const +Gnuplot3dDataset::Data3d::GetCommand () const { return "splot"; } void -Gnuplot3dDataset::Data3d::PrintExpression(std::ostream &os) const +Gnuplot3dDataset::Data3d::PrintExpression (std::ostream &os) const { os << "'-' "; - if (m_style.size()) + if (m_style.size ()) os << " " << m_style; - if (m_title.size()) + if (m_title.size ()) os << " title '" << m_title << "'"; - if (m_extra.size()) + if (m_extra.size ()) os << " " << m_extra; } void -Gnuplot3dDataset::Data3d::PrintDatafile(std::ostream &os) const +Gnuplot3dDataset::Data3d::PrintDatafile (std::ostream &os) const { for (PointSet::const_iterator i = m_pointset.begin (); i != m_pointset.end (); ++i) @@ -467,7 +467,7 @@ Gnuplot3dDataset::Data3d::PrintDatafile(std::ostream &os) const std::string Gnuplot3dDataset::m_defaultStyle = ""; Gnuplot3dDataset::Gnuplot3dDataset (const std::string& title) - : GnuplotDataset( new Data3d(title) ) + : GnuplotDataset ( new Data3d (title) ) { } @@ -494,7 +494,7 @@ Gnuplot3dDataset::Add (double x, double y, double z) } void -Gnuplot3dDataset::AddEmptyLine() +Gnuplot3dDataset::AddEmptyLine () { struct Point data; data.empty = true; @@ -514,44 +514,44 @@ struct Gnuplot3dFunction::Function3d : public GnuplotDataset::Data */ Function3d(const std::string& title, const std::string& function); - virtual std::string GetCommand() const; - virtual void PrintExpression(std::ostream &os) const; - virtual void PrintDatafile(std::ostream &os) const; + virtual std::string GetCommand () const; + virtual void PrintExpression (std::ostream &os) const; + virtual void PrintDatafile (std::ostream &os) const; }; Gnuplot3dFunction::Function3d::Function3d(const std::string& title, const std::string& function) - : Data(title), - m_function(function) + : Data (title), + m_function (function) { } std::string -Gnuplot3dFunction::Function3d::GetCommand() const +Gnuplot3dFunction::Function3d::GetCommand () const { return "splot"; } void -Gnuplot3dFunction::Function3d::PrintExpression(std::ostream &os) const +Gnuplot3dFunction::Function3d::PrintExpression (std::ostream &os) const { os << m_function; - if (m_title.size()) + if (m_title.size ()) os << " title '" << m_title << "'"; - if (m_extra.size()) + if (m_extra.size ()) os << " " << m_extra; } void -Gnuplot3dFunction::Function3d::PrintDatafile(std::ostream &os) const +Gnuplot3dFunction::Function3d::PrintDatafile (std::ostream &os) const { } // --- Gnuplot3dFunction --------------------------------------------------- // Gnuplot3dFunction::Gnuplot3dFunction (const std::string& title, const std::string& function) - : GnuplotDataset( new Function3d(title, function) ) + : GnuplotDataset ( new Function3d (title, function) ) { } @@ -564,21 +564,21 @@ Gnuplot3dFunction::SetFunction (const std::string& function) // ------------------------------------------------------------------------- // Gnuplot::Gnuplot (const std::string& outputFilename, const std::string& title) - : m_outputFilename(outputFilename), - m_terminal( DetectTerminal(outputFilename) ), - m_title(title) + : m_outputFilename (outputFilename), + m_terminal ( DetectTerminal (outputFilename) ), + m_title (title) { } std::string Gnuplot::DetectTerminal (const std::string& filename) { - std::string::size_type dotpos = filename.rfind('.'); + std::string::size_type dotpos = filename.rfind ('.'); if (dotpos == std::string::npos) return ""; - if (filename.substr(dotpos) == ".png") { + if (filename.substr (dotpos) == ".png") { return "png"; } - else if (filename.substr(dotpos) == ".pdf") { + else if (filename.substr (dotpos) == ".pdf") { return "pdf"; } @@ -626,37 +626,37 @@ Gnuplot::AddDataset (const GnuplotDataset& dataset) void Gnuplot::GenerateOutput (std::ostream &os) const { - if (m_terminal.size()) + if (m_terminal.size ()) os << "set terminal " << m_terminal << std::endl; - if (m_outputFilename.size()) + if (m_outputFilename.size ()) os << "set output '" << m_outputFilename << "'" << std::endl; - if (m_title.size()) + if (m_title.size ()) os << "set title '" << m_title << "'" << std::endl; - if (m_xLegend.size()) + if (m_xLegend.size ()) os << "set xlabel '" << m_xLegend << "'" << std::endl; - if (m_yLegend.size()) + if (m_yLegend.size ()) os << "set ylabel '" << m_yLegend << "'" << std::endl; - if (m_extra.size()) + if (m_extra.size ()) os << m_extra << std::endl; - if (m_datasets.empty()) + if (m_datasets.empty ()) return; // Determine the GetCommand() values of all datasets included. Check that all // are equal and print the command. - std::string command = m_datasets.begin()->m_data->GetCommand(); + std::string command = m_datasets.begin ()->m_data->GetCommand (); for (Datasets::const_iterator i = m_datasets.begin () + 1; i != m_datasets.end (); ++i) { - NS_ASSERT_MSG(command == i->m_data->GetCommand(), - "Cannot mix 'plot' and 'splot' GnuplotDatasets."); + NS_ASSERT_MSG (command == i->m_data->GetCommand (), + "Cannot mix 'plot' and 'splot' GnuplotDatasets."); } os << command << " "; @@ -665,7 +665,7 @@ Gnuplot::GenerateOutput (std::ostream &os) const for (Datasets::const_iterator i = m_datasets.begin (); i != m_datasets.end ();) { - i->m_data->PrintExpression(os); + i->m_data->PrintExpression (os); i++; @@ -680,15 +680,15 @@ Gnuplot::GenerateOutput (std::ostream &os) const for (Datasets::const_iterator i = m_datasets.begin (); i != m_datasets.end (); i++) { - i->m_data->PrintDatafile(os); + i->m_data->PrintDatafile (os); } } // ------------------------------------------------------------------------- // GnuplotCollection::GnuplotCollection (const std::string& outputFilename) - : m_outputFilename(outputFilename), - m_terminal( Gnuplot::DetectTerminal(outputFilename) ) + : m_outputFilename (outputFilename), + m_terminal ( Gnuplot::DetectTerminal (outputFilename) ) { } @@ -705,10 +705,10 @@ GnuplotCollection::AddPlot (const Gnuplot& plot) } Gnuplot& -GnuplotCollection::GetPlot(unsigned int id) +GnuplotCollection::GetPlot (unsigned int id) { - if (id >= m_plots.size()) - throw(std::range_error("Gnuplot id is out of range")); + if (id >= m_plots.size ()) + throw(std::range_error ("Gnuplot id is out of range")); else return m_plots[id]; } @@ -716,10 +716,10 @@ GnuplotCollection::GetPlot(unsigned int id) void GnuplotCollection::GenerateOutput (std::ostream &os) const { - if (m_terminal.size()) + if (m_terminal.size ()) os << "set terminal " << m_terminal << std::endl; - if (m_outputFilename.size()) + if (m_outputFilename.size ()) os << "set output '" << m_outputFilename << "'" << std::endl; for (Plots::const_iterator i = m_plots.begin (); i != m_plots.end (); ++i) diff --git a/src/tools/model/gnuplot.h b/src/tools/model/gnuplot.h index 9328f3ac7..0e1ac1d5f 100644 --- a/src/tools/model/gnuplot.h +++ b/src/tools/model/gnuplot.h @@ -197,7 +197,7 @@ public: * Add an empty line in the data output sequence. Empty lines in the plot * data break continuous lines and do other things in the output. */ - void AddEmptyLine(); + void AddEmptyLine (); private: @@ -286,7 +286,7 @@ public: * Add an empty line in the data output sequence. Empty lines in the plot * data break continuous lines and do other things in the output. */ - void AddEmptyLine(); + void AddEmptyLine (); private: @@ -356,7 +356,7 @@ public: * the filename's extension. * \param filename output file name */ - static std::string DetectTerminal(const std::string& filename); + static std::string DetectTerminal (const std::string& filename); /** * \param terminal terminal setting string for output. The default terminal @@ -440,7 +440,7 @@ public: * \param id index of plot to return * \return reference to plot, throws std::range_error if it does not exist. */ - Gnuplot& GetPlot(unsigned int id); + Gnuplot& GetPlot (unsigned int id); /** * \param os the output stream on which the relevant gnuplot commands should diff --git a/src/tools/test/event-garbage-collector-test-suite.cc b/src/tools/test/event-garbage-collector-test-suite.cc index 583d3e479..c4804b605 100644 --- a/src/tools/test/event-garbage-collector-test-suite.cc +++ b/src/tools/test/event-garbage-collector-test-suite.cc @@ -65,9 +65,9 @@ void EventGarbageCollectorTestCase::DoRun (void) for (int n = 0; n < 100; n++) { m_events->Track (Simulator::Schedule - (Simulator::Now (), - &EventGarbageCollectorTestCase::EventGarbageCollectorCallback, - this)); + (Simulator::Now (), + &EventGarbageCollectorTestCase::EventGarbageCollectorCallback, + this)); } Simulator::Run (); NS_TEST_EXPECT_MSG_EQ (m_events, 0, ""); diff --git a/src/uan/doc/uan.h b/src/uan/doc/uan.h deleted file mode 100644 index f07362a5d..000000000 --- a/src/uan/doc/uan.h +++ /dev/null @@ -1,203 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2009 University of Washington - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Leonard Tracy - */ - -/** - * \defgroup UAN UAN Models - * - * \section UanOverview UAN Framework Overview - * - * The main goal of the UAN Framework is to enable researchers to - * model a variety of underwater network scenarios. The UAN model - * is broken into four main parts: The channel, PHY, MAC and - * Autonomous Underwater Vehicle (AUV) models. - * - * - * \section UanPropOverview UAN Propagation Models - * - * Modelling of the underwater acoustic channel has been an active - * area of research for quite some time. Given the complications involved, - * surface and bottom interactions, varying speed of sound, etc..., the detailed - * models in use for ocean acoustics research are much too complex - * (in terms of runtime) for use in network level simulations. We have - * attempted to provide the often used models as well as make an attempt to bridge, in part, the gap between - * complicated ocean acoustic models and network level simulation. The three propagation - * models included are the ideal channel model, the Thorp propagation model and - * the Bellhop propagation model (Available as an addition). - * - * All of the Propagation Models follow the same simple interface in ns3::UanPropModel. - * The propagation models provide a power delay profile (PDP) and pathloss - * information. The PDP is retrieved using the GetPdp method which returns type UanPdp. - * ns3::UanPdp utilises a tapped delay line model for the acoustic channel. - * The UanPdp class is a container class for Taps, each tap has a delay and amplitude - * member corresponding to the time of arrival (relative to the first tap arrival time) - * and amplitude. The propagation model also provides pathloss between the source - * and receiver in dB re 1uPa. The PDP and pathloss can then be used to find the - * received signal power over a duration of time (i.e. received signal power in - * a symbol duration and ISI which interferes with neighbouring signals). Both - * UanPropModelIdeal and UanPropModelThorp return a single impulse for a PDP. - * - * a) Ideal Channel Model ns3::UanPropModelIdeal - * - * The ideal channel model assumes 0 pathloss inside a cylindrical area with bounds - * set by attribute. The ideal channel model also assumes an impulse PDP. - * - * b) Thorp Propagation Model ns3::UanPropModelThorp - * - * The Thorp Propagation Model calculates pathloss using the well-known Thorp approximation. - * This model is similar to the underwater channel model implemented in ns2 as described here: - * - * Harris, A. F. and Zorzi, M. 2007. Modeling the underwater acoustic channel in ns2. In Proceedings - * of the 2nd international Conference on Performance Evaluation Methodologies and Tools - * (Nantes, France, October 22 - 27, 2007). ValueTools, vol. 321. ICST (Institute for Computer - * Sciences Social-Informatics and Telecommunications Engineering), ICST, Brussels, Belgium, 1-8. - * - * The frequency used in calculation however, is the center frequency of the modulation as found from - * ns3::UanTxMode. The Thorp Propagation Model also assumes an impulse channel response. - * - * c) Bellhop Propagation Model ns3::UanPropModelBh (Available as an addition) - * - * The Bellhop propagation model reads propagation information from a database. A configuration - * file describing the location, and resolution of the archived information must be supplied via - * attributes. We have included a utility, create-dat, which can create these data files using the Bellhop - * Acoustic Ray Tracing software (http://oalib.hlsresearch.com/). - * - * The create-dat utility requires a Bellhop installation to run. Bellhop takes - * environment information about the channel, such as sound speed profile, surface height - * bottom type, water depth, and uses a gaussian ray tracing algorithm to determine - * propagation information. Arrivals from Bellhop are grouped together into equal length - * taps (the arrivals in a tap duration are coherently summed). The maximum taps are then - * aligned to take the same position in the PDP. The create-dat utility averages together - * several runs and then normalizes the average such that the sum of all taps is 1. The same - * configuration file used to create the data files using create-dat should be passed via - * attribute to the Bellhop Propagation Model. - * - * The Bellhop propagation model is available as a patch. The link address will be - * made available here when it is posted online. Otherwise email lentracy@gmail.com - * for more information. - * - * - * \section UanPhyOverview UAN PHY Model Overview - * - * The PHY has been designed to allow for relatively easy extension - * to new networking scenarios. We feel this is important as, to date, - * there has been no commonly accepted network level simulation model - * for underwater networks. The lack of commonly accepted network simulation - * tools has resulted in a wide array of simulators and models used to report - * results in literature. The lack of standardization makes comparing results - * nearly impossible. - * - * The main component of the PHY Model is the generic - * PHY class, ns3::UanPhyGen. The PHY class's general responsibility - * is to handle packet acquisition, error determination, and forwarding of successful - * packets up to the MAC layer. The Generic PHY uses two models for determination - * of signal to noise ratio (SINR) and packet error rate (PER). The - * combination of the PER and SINR models determine successful reception - * of packets. The PHY model connects to the channel via a Transducer class. - * The Transducer class is responsible for tracking all arriving packets and - * departing packets over the duration of the events. How the PHY class and the PER and SINR models - * respond to packets is based on the "Mode" of the transmission as described by the ns3::UanTxMode - * class. - * - * When a MAC layer sends down a packet to the PHY for transmission it specifies a "mode number" to - * be used for the transmission. The PHY class accepts, as an attribute, a list of supported modes. The - * mode number corresponds to an index in the supported modes. The UanTxMode contains simple modulation - * information and a unique string id. The generic PHY class will only acquire arriving packets which - * use a mode which is in the supported modes list of the PHY. The mode along with received signal power, - * and other pertinent attributes (e.g. possibly interfering packets and their modes) are passed to the SINR - * and PER models for calculation of SINR and probability of error. - * - * Several simple example PER and SINR models have been created. - * a) The PER models - * - Default (simple) PER model (ns3::UanPhyPerGenDefault): The Default PER model tests the packet against a threshold and - * assumes error (with prob. 1) if the SINR is below the threshold or success if the SINR is above - * the threshold - * - Micromodem FH-FSK PER (ns3::UanPhyPerUmodem). The FH-FSK PER model calculates probability of error assuming a - * rate 1/2 convolutional code with constraint length 9 and a CRC check capable of correcting - * up to 1 bit error. This is similar to what is used in the receiver of the WHOI Micromodem. - * - * b) SINR models - * - Default Model (ns3::UanPhyCalcSinrDefault), The default SINR model assumes that all transmitted energy is captured at the receiver - * and that there is no ISI. Any received signal power from interferes acts as additional - * ambient noise. - * - FH-FSK SINR Model (ns3::UanPhyCalcSinrFhFsk), The WHOI Micromodem operating in FH-FSK mode uses a predetermined hopping - * pattern that is shared by all nodes in the network. We model this by only including signal - * energy receiving within one symbol time (as given by ns3::UanTxMode) in calculating the - * received signal power. A channel clearing time is given to the FH-FSK SINR model via attribute. - * Any signal energy arriving in adjacent signals (after a symbol time and the clearing time) is - * considered ISI and is treated as additional ambient noise. Interfering signal arrivals inside - * a symbol time (any symbol time) is also counted as additional ambient noise - * - Frequency filtered SINR (ns3::UanPhyCalcSinrDual). This SINR model calculates SINR in the same manner - * as the default model. This model however only considers interference if there is an overlap in frequency - * of the arriving packets as determined by UanTxMode. - * - * In addition to the generic PHY a dual phy layer is also included (ns3::UanPhyDual). This wraps two - * generic phy layers together to model a net device which includes two receivers. This was primarily - * developed for UanMacRc, described in the next section. - * - *\section UanMAC UAN MAC Model Overview - * - * Over the last several years there have been a myriad of underwater MAC proposals - * in the literature. We have included three MAC protocols with this distribution: - * a) CW-MAC, a MAC protocol which uses a slotted contention window similar in nature to - * the IEEE 802.11 DCF. Nodes have a constant contention window measured in slot times (configured - * via attribute). If the channel is sensed busy, then nodes backoff by randomly (uniform distribution) choose - * a slot to transmit in. The slot time durations are also configured via attribute. This MAC was described in - * - * Parrish N.; Tracy L.; Roy S. Arabshahi P.; and Fox, W., System Design Considerations for Undersea Networks: - * Link and Multiple Access Protocols , IEEE Journal on Selected Areas in Communications (JSAC), Special - * Issue on Underwater Wireless Communications and Networks, Dec. 2008. - * - * b) RC-MAC (ns3::UanMacRc ns3::UanMacRcGw) a reservation channel protocol which dynamically divides - * the available bandwidth into a data channel and a control channel. This MAC protocol - * assumes there is a gateway node which all network traffic is destined for. The current - * implementation assumes a single gateway and a single network neighborhood (a single hop network). - * RTS/CTS handshaking is used and time is divided into cycles. Non-gateway nodes transmit RTS packets - * on the control channel in parallel to data packet transmissions which were scheduled in the previous cycle - * at the start of a new cycle, the gateway responds on the data channel with a CTS packet which includes - * packet transmission times of data packets for received RTS packets in the previous cycle as well as bandwidth - * allocation information. At the end of a cycle ACK packets are transmitted for received data packets. - * - * When a publication is available it will be cited here. - * - * c) Simple ALOHA (ns3::UanMacAloha) Nodes transmit at will. - * - * \section UanAUV UAN AUV Model Overview - * - * Since AUVs are one of the main components of an underwater networking application, we have included - * two models of the most used AUVs, the Seaglider and the REMUS. - * - * An AUV model includes a mobility model that reproduces the navigation capabilities of the AUV, two energy model - * that reproduce the energy consumption of the AUV and the communication device. - * - * a) mobility models are ns3::RemusMobilityModel and ns3::GliderMobilityModel - * - * b) auv energy models are ns3::RemusEnergyModel and ns3::GliderEnergyModel. Those models, interacting - * with the associated mobility models, keep track of an AUV navigation energy consumption. The energy - * consumption varies accordingly to the navigation parameter such as speed (in case of REMUS) and - * buoyancy and vertical speed (in case of Seaglider) - * - * c) transducer energy model is ns3::AcousticModemEnergyModel, it keeps track of the energy consumed - * by the acoustic transducer accordingly to its state. The specific energy consumption values are the ones of - * the WHOI Micro Modem. - * - * For a complete description of AUV mobility models, energy models, energy sources and examples please refer to - * the wiki page - * - */ diff --git a/src/uan/doc/uan.rst b/src/uan/doc/uan.rst index b2c9ff552..8ef7d1c9e 100644 --- a/src/uan/doc/uan.rst +++ b/src/uan/doc/uan.rst @@ -1,12 +1,15 @@ UAN Framework ------------- -Underwater Acoustics Networks is a research field that, in the last year, is gathering attention from researchers all over the world. In fact, the need for underwater wireless communications exists in applications such as remote control in offshore oil industry [1]_, pollution monitoring in environmental systems, speech transmission between divers, mapping of the ocean floor, mine counter measures [4]_, seismic monitoring of ocean faults as well as climate changes monitoring. Unfortunately, making on-field measurements is very expensive and there are no commonly accepted standard to base on. Hence, the priority to make research work going on, it is to realize a complete simulation framework that researchers can use to experiment, make tests and make performance evaluation and comparison. +The main goal of the UAN Framework is to enable researchers to +model a variety of underwater network scenarios. The UAN model +is broken into four main parts: The channel, PHY, MAC and +Autonomous Underwater Vehicle (AUV) models. + +The need for underwater wireless communications exists in applications such as remote control in offshore oil industry [1]_, pollution monitoring in environmental systems, speech transmission between divers, mapping of the ocean floor, mine counter measures [4]_, seismic monitoring of ocean faults as well as climate changes monitoring. Unfortunately, making on-field measurements is very expensive and there are no commonly accepted standard to base on. Hence, the priority to make research work going on, it is to realize a complete simulation framework that researchers can use to experiment, make tests and make performance evaluation and comparison. The NS-3 UAN module is a first step in this direction, trying to offer a reliable and realistic tool. In fact, the UAN module offers accurate modelling of the underwater acoustic channel, a model of the WHOI acoustic modem (one of the widely used acoustic modems)[6]_ and its communications performance, and some MAC protocols. -This project integrates the efforts of UAN module, extending it to make a simulation framework that researchers will be able to use for their aims. The extension consists of an Autonomous Underwater Vehicle (AUV) simulator (navigation and movement) along with an implementation of AUV batteries. Moreover, it will be implemented, a power model for a generic acoustic modem and, the physicals layers will be modified to use such model. For the moment, the UAN module can be used to make some sort of performance comparisons of the available MAC protocols, or tests the communication channel. With this extension, researchers will be able to use the framework to develop and evaluate their "applications". An application, is intended as a more complete concept, including each parts of the UAN module integrated with the framework's extensions. Then, the final result is a complete simulation stack for underwater network applications. - Model Description ***************** @@ -26,8 +29,154 @@ As enabling component for the energy models, a Li-Ion batteries energy source ha Design ====== -The development of the UAN Framework for ns-3 is composed by three consecutive steps. The first one is the development of the AUV simulator, the second one is the development of the UAN energy models and the third one is the integration of such components with the existing modules, UAN module and Energy Model. The module is implemented into the ``/src/uan`` folder for the part regarding acoustic modem energy model and the part regarding the AUV simulator. +UAN Propagation Models +###################### +Modelling of the underwater acoustic channel has been an active +area of research for quite some time. Given the complications involved, +surface and bottom interactions, varying speed of sound, etc..., the detailed +models in use for ocean acoustics research are much too complex +(in terms of runtime) for use in network level simulations. We have +attempted to provide the often used models as well as make an attempt to bridge, in part, the gap between +complicated ocean acoustic models and network level simulation. The three propagation +models included are the ideal channel model, the Thorp propagation model and +the Bellhop propagation model (Available as an addition). +All of the Propagation Models follow the same simple interface in ``ns3::UanPropModel``. +The propagation models provide a power delay profile (PDP) and pathloss +information. The PDP is retrieved using the GetPdp method which returns type UanPdp. +``ns3::UanPdp`` utilises a tapped delay line model for the acoustic channel. +The UanPdp class is a container class for Taps, each tap has a delay and amplitude +member corresponding to the time of arrival (relative to the first tap arrival time) +and amplitude. The propagation model also provides pathloss between the source +and receiver in dB re 1uPa. The PDP and pathloss can then be used to find the +received signal power over a duration of time (i.e. received signal power in +a symbol duration and ISI which interferes with neighbouring signals). Both +UanPropModelIdeal and UanPropModelThorp return a single impulse for a PDP. + +a) Ideal Channel Model ``ns3::UanPropModelIdeal`` + +The ideal channel model assumes 0 pathloss inside a cylindrical area with bounds +set by attribute. The ideal channel model also assumes an impulse PDP. + +b) Thorp Propagation Model ``ns3::UanPropModelThorp`` + +The Thorp Propagation Model calculates pathloss using the well-known Thorp approximation. +This model is similar to the underwater channel model implemented in ns2 as described here: + +Harris, A. F. and Zorzi, M. 2007. Modeling the underwater acoustic channel in ns2. In Proceedings +of the 2nd international Conference on Performance Evaluation Methodologies and Tools +(Nantes, France, October 22 - 27, 2007). ValueTools, vol. 321. ICST (Institute for Computer +Sciences Social-Informatics and Telecommunications Engineering), ICST, Brussels, Belgium, 1-8. + +The frequency used in calculation however, is the center frequency of the modulation as found from +ns3::UanTxMode. The Thorp Propagation Model also assumes an impulse channel response. + +c) Bellhop Propagation Model ``ns3::UanPropModelBh`` (Available as an addition) + +The Bellhop propagation model reads propagation information from a database. A configuration +file describing the location, and resolution of the archived information must be supplied via +attributes. We have included a utility, create-dat, which can create these data files using the Bellhop +Acoustic Ray Tracing software (http://oalib.hlsresearch.com/). + +The create-dat utility requires a Bellhop installation to run. Bellhop takes +environment information about the channel, such as sound speed profile, surface height +bottom type, water depth, and uses a gaussian ray tracing algorithm to determine +propagation information. Arrivals from Bellhop are grouped together into equal length +taps (the arrivals in a tap duration are coherently summed). The maximum taps are then +aligned to take the same position in the PDP. The create-dat utility averages together +several runs and then normalizes the average such that the sum of all taps is 1. The same +configuration file used to create the data files using create-dat should be passed via +attribute to the Bellhop Propagation Model. + +The Bellhop propagation model is available as a patch. The link address will be +made available here when it is posted online. Otherwise email lentracy@gmail.com +for more information. + +UAN PHY Model Overview +###################### + +The PHY has been designed to allow for relatively easy extension +to new networking scenarios. We feel this is important as, to date, +there has been no commonly accepted network level simulation model +for underwater networks. The lack of commonly accepted network simulation +tools has resulted in a wide array of simulators and models used to report +results in literature. The lack of standardization makes comparing results +nearly impossible. + +The main component of the PHY Model is the generic +PHY class, ``ns3::UanPhyGen``. The PHY class's general responsibility +is to handle packet acquisition, error determination, and forwarding of successful +packets up to the MAC layer. The Generic PHY uses two models for determination +of signal to noise ratio (SINR) and packet error rate (PER). The +combination of the PER and SINR models determine successful reception +of packets. The PHY model connects to the channel via a Transducer class. +The Transducer class is responsible for tracking all arriving packets and +departing packets over the duration of the events. How the PHY class and the PER and SINR models +respond to packets is based on the "Mode" of the transmission as described by the ``ns3::UanTxMode`` +class. + +When a MAC layer sends down a packet to the PHY for transmission it specifies a "mode number" to +be used for the transmission. The PHY class accepts, as an attribute, a list of supported modes. The +mode number corresponds to an index in the supported modes. The UanTxMode contains simple modulation +information and a unique string id. The generic PHY class will only acquire arriving packets which +use a mode which is in the supported modes list of the PHY. The mode along with received signal power, +and other pertinent attributes (e.g. possibly interfering packets and their modes) are passed to the SINR +and PER models for calculation of SINR and probability of error. + +Several simple example PER and SINR models have been created. +a) The PER models +- Default (simple) PER model (``ns3::UanPhyPerGenDefault``): The Default PER model tests the packet against a threshold and +assumes error (with prob. 1) if the SINR is below the threshold or success if the SINR is above +the threshold +- Micromodem FH-FSK PER (``ns3::UanPhyPerUmodem``). The FH-FSK PER model calculates probability of error assuming a +rate 1/2 convolutional code with constraint length 9 and a CRC check capable of correcting +up to 1 bit error. This is similar to what is used in the receiver of the WHOI Micromodem. + +b) SINR models +- Default Model (``ns3::UanPhyCalcSinrDefault``), The default SINR model assumes that all transmitted energy is captured at the receiver +and that there is no ISI. Any received signal power from interferes acts as additional ambient noise. +- FH-FSK SINR Model (``ns3::UanPhyCalcSinrFhFsk``), The WHOI Micromodem operating in FH-FSK mode uses a predetermined hopping +pattern that is shared by all nodes in the network. We model this by only including signal +energy receiving within one symbol time (as given by ``ns3::UanTxMode``) in calculating the +received signal power. A channel clearing time is given to the FH-FSK SINR model via attribute. +Any signal energy arriving in adjacent signals (after a symbol time and the clearing time) is +considered ISI and is treated as additional ambient noise. Interfering signal arrivals inside +a symbol time (any symbol time) is also counted as additional ambient noise +- Frequency filtered SINR (``ns3::UanPhyCalcSinrDual``). This SINR model calculates SINR in the same manner +as the default model. This model however only considers interference if there is an overlap in frequency +of the arriving packets as determined by UanTxMode. + +In addition to the generic PHY a dual phy layer is also included (``ns3::UanPhyDual``). This wraps two +generic phy layers together to model a net device which includes two receivers. This was primarily +developed for UanMacRc, described in the next section. + +UAN MAC Model Overview +###################### + +Over the last several years there have been a myriad of underwater MAC proposals +in the literature. We have included three MAC protocols with this distribution: +a) CW-MAC, a MAC protocol which uses a slotted contention window similar in nature to +the IEEE 802.11 DCF. Nodes have a constant contention window measured in slot times (configured +via attribute). If the channel is sensed busy, then nodes backoff by randomly (uniform distribution) choose +a slot to transmit in. The slot time durations are also configured via attribute. This MAC was described in + +Parrish N.; Tracy L.; Roy S. Arabshahi P.; and Fox, W., System Design Considerations for Undersea Networks: +Link and Multiple Access Protocols , IEEE Journal on Selected Areas in Communications (JSAC), Special +Issue on Underwater Wireless Communications and Networks, Dec. 2008. + +b) RC-MAC (``ns3::UanMacRc`` ``ns3::UanMacRcGw``) a reservation channel protocol which dynamically divides +the available bandwidth into a data channel and a control channel. This MAC protocol +assumes there is a gateway node which all network traffic is destined for. The current +implementation assumes a single gateway and a single network neighborhood (a single hop network). +RTS/CTS handshaking is used and time is divided into cycles. Non-gateway nodes transmit RTS packets +on the control channel in parallel to data packet transmissions which were scheduled in the previous cycle +at the start of a new cycle, the gateway responds on the data channel with a CTS packet which includes +packet transmission times of data packets for received RTS packets in the previous cycle as well as bandwidth +allocation information. At the end of a cycle ACK packets are transmitted for received data packets. + +When a publication is available it will be cited here. + +c) Simple ALOHA (``ns3::UanMacAloha``) Nodes transmit at will. AUV mobility models ################### diff --git a/src/uan/examples/uan-cw-example.cc b/src/uan/examples/uan-cw-example.cc index 165ddf9e2..f0ee508e5 100644 --- a/src/uan/examples/uan-cw-example.cc +++ b/src/uan/examples/uan-cw-example.cc @@ -47,7 +47,7 @@ using namespace ns3; -NS_LOG_COMPONENT_DEFINE("UanCwExample"); +NS_LOG_COMPONENT_DEFINE ("UanCwExample"); Experiment::Experiment () : m_numNodes (15), @@ -115,7 +115,7 @@ Experiment::ReceivePacket (Ptr socket) { Ptr packet; - while (packet = socket->Recv()) + while (packet = socket->Recv ()) { m_bytesTotal += packet->GetSize (); } @@ -178,8 +178,8 @@ Experiment::Run (UanHelper &uan) mobility.Install (nc); PacketSocketAddress socket; - socket.SetSingleDevice (sinkdev.Get(0)->GetIfIndex ()); - socket.SetPhysicalAddress (sinkdev.Get(0)->GetAddress ()); + socket.SetSingleDevice (sinkdev.Get (0)->GetIfIndex ()); + socket.SetPhysicalAddress (sinkdev.Get (0)->GetAddress ()); socket.SetProtocol (0); OnOffHelper app ("ns3::PacketSocketFactory", Address (socket)); diff --git a/src/uan/examples/uan-rc-example.cc b/src/uan/examples/uan-rc-example.cc index 4a98d5672..80a6a78c5 100644 --- a/src/uan/examples/uan-rc-example.cc +++ b/src/uan/examples/uan-rc-example.cc @@ -123,7 +123,7 @@ Experiment::CreateMode (uint32_t kass, fcmode, bw, 2, - buf.str()); + buf.str ()); return mode; } @@ -164,7 +164,7 @@ Experiment::Run (uint32_t param) nNodes = m_numNodes; a = param; } - Time pDelay = Seconds((double) m_maxRange / 1500.0); + Time pDelay = Seconds ((double) m_maxRange / 1500.0); uan.SetPhy ("ns3::UanPhyDual", "SupportedModesPhy1", UanModesListValue (m_dataModes), @@ -174,20 +174,20 @@ Experiment::Run (uint32_t param) "NumberOfRates", UintegerValue (m_numRates), "NumberOfNodes", UintegerValue (nNodes), "MaxReservations", UintegerValue (a), - "RetryRate", DoubleValue(1/30.0), + "RetryRate", DoubleValue (1/30.0), "SIFS", TimeValue (m_sifs), "MaxPropDelay", TimeValue (pDelay), "FrameSize", UintegerValue (m_pktSize)); Ptr chan = CreateObject(); NodeContainer sink; - sink.Create(1); - NetDeviceContainer sinkDev = uan.Install(sink, chan); + sink.Create (1); + NetDeviceContainer sinkDev = uan.Install (sink, chan); uan.SetMac ("ns3::UanMacRc", "NumberOfRates", UintegerValue (m_numRates), "MaxPropDelay", TimeValue (pDelay), - "RetryRate", DoubleValue(1.0/100.0)); + "RetryRate", DoubleValue (1.0/100.0)); NodeContainer nodes; nodes.Create (nNodes); NetDeviceContainer devices = uan.Install (nodes, chan); @@ -222,8 +222,8 @@ Experiment::Run (uint32_t param) pktskth.Install (sink); PacketSocketAddress socket; - socket.SetSingleDevice (sinkDev.Get(0)->GetIfIndex ()); - socket.SetPhysicalAddress (sinkDev.Get(0)->GetAddress ()); + socket.SetSingleDevice (sinkDev.Get (0)->GetIfIndex ()); + socket.SetPhysicalAddress (sinkDev.Get (0)->GetAddress ()); socket.SetProtocol (0); OnOffHelper app ("ns3::PacketSocketFactory", Address (socket)); @@ -235,23 +235,23 @@ Experiment::Run (uint32_t param) ApplicationContainer apps = app.Install (nodes); apps.Start (Seconds (0.5)); - apps.Stop (m_simTime + Seconds(0.5)); + apps.Stop (m_simTime + Seconds (0.5)); Ptr sinkNode = sink.Get (0); TypeId psfid = TypeId::LookupByName ("ns3::PacketSocketFactory"); - Ptr sinkSocket = Socket::CreateSocket(sinkNode, psfid); - sinkSocket->Bind(socket); + Ptr sinkSocket = Socket::CreateSocket (sinkNode, psfid); + sinkSocket->Bind (socket); sinkSocket->SetRecvCallback (MakeCallback (&Experiment::ReceivePacket, this)); - Simulator::Stop (m_simTime + Seconds(0.6)); + Simulator::Stop (m_simTime + Seconds (0.6)); Simulator::Run (); Simulator::Destroy (); return m_bytesTotal; } int -main(int argc, char *argv[]) +main (int argc, char *argv[]) { LogComponentEnable ("UanRcExample", LOG_LEVEL_ALL); diff --git a/src/uan/model/uan-net-device.h b/src/uan/model/uan-net-device.h index 21de27ad7..b10c2170c 100644 --- a/src/uan/model/uan-net-device.h +++ b/src/uan/model/uan-net-device.h @@ -35,6 +35,12 @@ class UanMac; class UanTransducer; /** + * \defgroup uan UAN Models + * This section documents the API of the ns-3 UAN module. For a generic functional description, please refer to the ns-3 manual. + */ + +/** + * \ingroup uan * \class UanNetDevice * * \brief Net device for UAN models diff --git a/src/virtual-net-device/examples/virtual-net-device.cc b/src/virtual-net-device/examples/virtual-net-device.cc index 460b9d44a..73456d3d6 100644 --- a/src/virtual-net-device/examples/virtual-net-device.cc +++ b/src/virtual-net-device/examples/virtual-net-device.cc @@ -218,9 +218,9 @@ main (int argc, char *argv[]) NS_LOG_INFO ("Create nodes."); NodeContainer c; c.Create (4); - NodeContainer n0n2 = NodeContainer (c.Get(0), c.Get (2)); - NodeContainer n1n2 = NodeContainer (c.Get(1), c.Get (2)); - NodeContainer n3n2 = NodeContainer (c.Get(3), c.Get (2)); + NodeContainer n0n2 = NodeContainer (c.Get (0), c.Get (2)); + NodeContainer n1n2 = NodeContainer (c.Get (1), c.Get (2)); + NodeContainer n3n2 = NodeContainer (c.Get (3), c.Get (2)); InternetStackHelper internet; internet.Install (c); diff --git a/src/virtual-net-device/model/virtual-net-device.cc b/src/virtual-net-device/model/virtual-net-device.cc index c6f96a555..bbbc35515 100644 --- a/src/virtual-net-device/model/virtual-net-device.cc +++ b/src/virtual-net-device/model/virtual-net-device.cc @@ -117,7 +117,7 @@ VirtualNetDevice::~VirtualNetDevice() } -void VirtualNetDevice::DoDispose() +void VirtualNetDevice::DoDispose () { NS_LOG_FUNCTION_NOARGS (); m_node = 0; diff --git a/src/virtual-net-device/model/virtual-net-device.h b/src/virtual-net-device/model/virtual-net-device.h index 89c0e3145..e9a7a6439 100644 --- a/src/virtual-net-device/model/virtual-net-device.h +++ b/src/virtual-net-device/model/virtual-net-device.h @@ -122,8 +122,8 @@ public: // inherited from NetDevice base class. - virtual void SetIfIndex(const uint32_t index); - virtual uint32_t GetIfIndex(void) const; + virtual void SetIfIndex (const uint32_t index); + virtual uint32_t GetIfIndex (void) const; virtual Ptr GetChannel (void) const; virtual void SetAddress (Address address); virtual Address GetAddress (void) const; diff --git a/src/visualizer/model/dummy-file-for-static-builds.cc b/src/visualizer/model/dummy-file-for-static-builds.cc new file mode 100644 index 000000000..0866b725e --- /dev/null +++ b/src/visualizer/model/dummy-file-for-static-builds.cc @@ -0,0 +1,21 @@ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright 2011 University of Washington + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Mitch Watrous (watrous@u.washington.edu) + */ + +// This file does nothing. diff --git a/src/visualizer/model/pyviz.cc b/src/visualizer/model/pyviz.cc index 9279e53f5..f0acb0f58 100644 --- a/src/visualizer/model/pyviz.cc +++ b/src/visualizer/model/pyviz.cc @@ -43,17 +43,17 @@ PathSplit (std::string str) { std::vector results; size_t cutAt; - while ((cutAt = str.find_first_of('/')) != str.npos) + while ((cutAt = str.find_first_of ('/')) != str.npos) { if(cutAt > 0) { - results.push_back(str.substr(0,cutAt)); + results.push_back (str.substr (0,cutAt)); } - str = str.substr(cutAt+1); + str = str.substr (cutAt+1); } - if (str.length() > 0) + if (str.length () > 0) { - results.push_back(str); + results.push_back (str); } return results; } @@ -699,28 +699,28 @@ PyViz::TraceNetDevRxCommon (std::string const &context, Ptr packet TransmissionSampleKey key = { record.srcNode, node, channel }; #ifdef NS3_LOG_ENABLE - NS_LOG_DEBUG("m_transmissionSamples begin:"); + NS_LOG_DEBUG ("m_transmissionSamples begin:"); if (g_log.IsEnabled (ns3::LOG_DEBUG)) { for (std::map::const_iterator iter = m_transmissionSamples.begin (); iter != m_transmissionSamples.end (); iter++) { - NS_LOG_DEBUG(iter->first.transmitter<<"/"<first.transmitter->GetId () << ", " - << iter->first.receiver<<"/"<first.receiver->GetId () - << ", " << iter->first.channel << " => " << iter->second.bytes << " (@ " << &iter->second << ")"); + NS_LOG_DEBUG (iter->first.transmitter<<"/"<first.transmitter->GetId () << ", " + << iter->first.receiver<<"/"<first.receiver->GetId () + << ", " << iter->first.channel << " => " << iter->second.bytes << " (@ " << &iter->second << ")"); } } - NS_LOG_DEBUG("m_transmissionSamples end."); + NS_LOG_DEBUG ("m_transmissionSamples end."); #endif std::map::iterator - iter = m_transmissionSamples.find (key); + iter = m_transmissionSamples.find (key); if (iter == m_transmissionSamples.end ()) { TransmissionSampleValue sample = { packet->GetSize () }; - NS_LOG_DEBUG ("RX: from " << key.transmitter<<"/"<GetId() << " to " - << key.receiver<<"/"<GetId() + NS_LOG_DEBUG ("RX: from " << key.transmitter<<"/"<GetId () << " to " + << key.receiver<<"/"<GetId () << " channel " << channel << ": " << packet->GetSize () << " bytes more. => new sample with " << packet->GetSize () << " bytes."); m_transmissionSamples[key] = sample; @@ -728,8 +728,8 @@ PyViz::TraceNetDevRxCommon (std::string const &context, Ptr packet else { TransmissionSampleValue &sample = iter->second; - NS_LOG_DEBUG ("RX: from " << key.transmitter<<"/"<GetId() << " to " - << key.receiver<<"/"<GetId() + NS_LOG_DEBUG ("RX: from " << key.transmitter<<"/"<GetId () << " to " + << key.receiver<<"/"<GetId () << " channel " << channel << ": " << packet->GetSize () << " bytes more. => sample " << &sample << " with bytes " << sample.bytes); @@ -838,7 +838,7 @@ PyViz::GetTransmissionSamples () const sample.receiver = iter->first.receiver; sample.channel = iter->first.channel; sample.bytes = iter->second.bytes; - NS_LOG_DEBUG ("from " << sample.transmitter->GetId() << " to " << sample.receiver->GetId() + NS_LOG_DEBUG ("from " << sample.transmitter->GetId () << " to " << sample.receiver->GetId () << ": " << sample.bytes << " bytes."); list.push_back (sample); } @@ -859,7 +859,7 @@ PyViz::GetPacketDropSamples () const PacketDropSample sample; sample.transmitter = iter->first; sample.bytes = iter->second; - NS_LOG_DEBUG ("in " << sample.transmitter->GetId() + NS_LOG_DEBUG ("in " << sample.transmitter->GetId () << ": " << sample.bytes << " bytes dropped."); list.push_back (sample); } @@ -893,7 +893,7 @@ PyViz::GetLastPackets (uint32_t nodeId) const NS_LOG_DEBUG ("GetLastPackets: " << nodeId); std::map::const_iterator - iter = m_lastPackets.find(nodeId); + iter = m_lastPackets.find (nodeId); if (iter != m_lastPackets.end ()) { return iter->second; diff --git a/src/visualizer/model/visual-simulator-impl.cc b/src/visualizer/model/visual-simulator-impl.cc index 9a43d8fc3..3c2291a18 100644 --- a/src/visualizer/model/visual-simulator-impl.cc +++ b/src/visualizer/model/visual-simulator-impl.cc @@ -121,10 +121,10 @@ VisualSimulatorImpl::Run (void) if (!Py_IsInitialized ()) { const char *argv[] = { "python", NULL}; - Py_Initialize(); - PySys_SetArgv(1, (char**) argv); + Py_Initialize (); + PySys_SetArgv (1, (char**) argv); } - PyRun_SimpleString( + PyRun_SimpleString ( "import visualizer\n" "visualizer.start();\n" ); diff --git a/src/visualizer/wscript b/src/visualizer/wscript index a6f943569..9dea2216e 100644 --- a/src/visualizer/wscript +++ b/src/visualizer/wscript @@ -1,12 +1,37 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- +import Options + +def configure(conf): + # If Python was explicitly disabled, then add this module to the + # list of modules that won't be built if they are enabled. + if Options.options.python_disable: + conf.env['MODULES_NOT_BUILT'].append('visualizer') def build(bld): + # Don't do anything for this module if Python was explicitly + # disabled. + if 'visualizer' in bld.env['MODULES_NOT_BUILT']: + return + headers = bld.new_task_gen('ns3header') headers.module = 'visualizer' headers.source = [ ] - module = bld.create_ns3_module('visualizer', ['network', 'wifi']) + module = bld.create_ns3_module('visualizer', ['internet', 'wifi', 'point-to-point']) + + # XXX This file was added so that static builds would work on + # Darwin, which doesn't like modules with no source files. It + # would have been better to add this module to the list + # conf.env['MODULES_NOT_BUILT'] if Python bindings were not + # enabled, but it's not possible for this module to determine in + # its configure() function if Python bindings will be enabled + # because that is done by the wscript file in bindings/python that + # is parsed after this module's wscript file is parsed. + module.source = [ + 'model/dummy-file-for-static-builds.cc', + ] + if not bld.env['ENABLE_PYTHON_BINDINGS']: return @@ -14,14 +39,10 @@ def build(bld): module.env.append_value('CXXFLAGS', module.env['shlib_CXXFLAGS']) module.includes = '.' - if bld.env['ENABLE_PYTHON_BINDINGS']: - module.source = [ - 'model/pyviz.cc', - 'model/visual-simulator-impl.cc', - ] - headers.source.append('model/pyviz.h') - else: - module.source = [ - ] + module.source.extend([ + 'model/pyviz.cc', + 'model/visual-simulator-impl.cc', + ]) + headers.source.append('model/pyviz.h') bld.ns3_python_bindings() diff --git a/src/wifi/model/dca-txop.cc b/src/wifi/model/dca-txop.cc index 852e54369..c12cd6d5b 100644 --- a/src/wifi/model/dca-txop.cc +++ b/src/wifi/model/dca-txop.cc @@ -38,7 +38,7 @@ NS_LOG_COMPONENT_DEFINE ("DcaTxop"); #undef NS_LOG_APPEND_CONTEXT -#define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] ";} +#define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] "; } namespace ns3 { diff --git a/src/wifi/model/edca-txop-n.cc b/src/wifi/model/edca-txop-n.cc index efd264599..1cb017ef8 100644 --- a/src/wifi/model/edca-txop-n.cc +++ b/src/wifi/model/edca-txop-n.cc @@ -38,7 +38,7 @@ NS_LOG_COMPONENT_DEFINE ("EdcaTxopN"); #undef NS_LOG_APPEND_CONTEXT -#define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] ";} +#define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] "; } namespace ns3 { @@ -143,7 +143,7 @@ EdcaTxopN::GetTypeId (void) .SetParent (ns3::Dcf::GetTypeId ()) .AddConstructor () .AddAttribute ("BlockAckThreshold", "If number of packets in this queue reaches this value,\ - block ack mechanism is used. If this value is 0, block ack is never used." , + block ack mechanism is used. If this value is 0, block ack is never used.", UintegerValue (0), MakeUintegerAccessor (&EdcaTxopN::SetBlockAckThreshold, &EdcaTxopN::GetBlockAckThreshold), @@ -151,7 +151,7 @@ EdcaTxopN::GetTypeId (void) .AddAttribute ("BlockAckInactivityTimeout", "Represents max time (blocks of 1024 micro seconds) allowed for block ack\ inactivity. If this value isn't equal to 0 a timer start after that a\ block ack setup is completed and will be reset every time that a block\ - ack frame is received. If this value is 0, block ack inactivity timeout won't be used." , + ack frame is received. If this value is 0, block ack inactivity timeout won't be used.", UintegerValue (0), MakeUintegerAccessor (&EdcaTxopN::SetBlockAckInactivityTimeout), MakeUintegerChecker ()) diff --git a/src/wifi/model/mac-low.cc b/src/wifi/model/mac-low.cc index 071a6721a..b934895ed 100644 --- a/src/wifi/model/mac-low.cc +++ b/src/wifi/model/mac-low.cc @@ -277,10 +277,10 @@ MacLowTransmissionParameters::GetNextPacketSize (void) const std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters ¶ms) { os << "[" - << "send rts=" << params.m_sendRts << ", " - << "next size=" << params.m_nextSize << ", " - << "dur=" << params.m_overrideDurationId << ", " - << "ack="; + << "send rts=" << params.m_sendRts << ", " + << "next size=" << params.m_nextSize << ", " + << "dur=" << params.m_overrideDurationId << ", " + << "ack="; switch (params.m_waitAck) { case MacLowTransmissionParameters::ACK_NONE: diff --git a/src/wifi/model/minstrel-wifi-manager.cc b/src/wifi/model/minstrel-wifi-manager.cc index 69c5802b8..ec0314901 100644 --- a/src/wifi/model/minstrel-wifi-manager.cc +++ b/src/wifi/model/minstrel-wifi-manager.cc @@ -639,7 +639,7 @@ MinstrelWifiManager::UpdateStats (MinstrelWifiRemoteStation *station) m_minstrelTable[i].adjustedRetryCount = m_minstrelTable[i].retryCount >> 1; if (m_minstrelTable[i].adjustedRetryCount > 2) { - m_minstrelTable[i].adjustedRetryCount = 2 ; + m_minstrelTable[i].adjustedRetryCount = 2; } } else diff --git a/src/wifi/model/onoe-wifi-manager.cc b/src/wifi/model/onoe-wifi-manager.cc index f62591ac8..60fecccc4 100644 --- a/src/wifi/model/onoe-wifi-manager.cc +++ b/src/wifi/model/onoe-wifi-manager.cc @@ -181,7 +181,7 @@ OnoeWifiManager::UpdateMode (OnoeWifiRemoteStation *station) station->m_tx_upper--; } break; - case - 1: + case -1: if (nrate > 0) { nrate--; diff --git a/src/wifi/model/wifi-mode.cc b/src/wifi/model/wifi-mode.cc index bc2e09948..9ec1cfb2f 100644 --- a/src/wifi/model/wifi-mode.cc +++ b/src/wifi/model/wifi-mode.cc @@ -190,7 +190,7 @@ WifiModeFactory::Search (std::string name) // is a fatal problem, but we try to be helpful by displaying the // list of WifiModes that are supported. NS_LOG_UNCOND ("Could not find match for WifiMode named \"" - << name << "\". Valid options are:"); + << name << "\". Valid options are:"); for (i = m_itemList.begin (); i != m_itemList.end (); i++) { NS_LOG_UNCOND (" " << i->uniqueUid); diff --git a/src/wifi/model/yans-error-rate-model.cc b/src/wifi/model/yans-error-rate-model.cc index 09dfc18db..09d7bc531 100644 --- a/src/wifi/model/yans-error-rate-model.cc +++ b/src/wifi/model/yans-error-rate-model.cc @@ -60,7 +60,7 @@ YansErrorRateModel::GetQamBer (double snr, unsigned int m, uint32_t signalSpread { double EbNo = snr * signalSpread / phyRate; double z = sqrt ((1.5 * Log2 (m) * EbNo) / (m - 1.0)); - double z1 = ((1.0 - 1.0 / sqrt (m)) * erfc (z)) ; + double z1 = ((1.0 - 1.0 / sqrt (m)) * erfc (z)); double z2 = 1 - pow ((1 - z1), 2.0); double ber = z2 / Log2 (m); NS_LOG_INFO ("Qam m=" << m << " rate=" << phyRate << " snr=" << snr << " ber=" << ber); diff --git a/src/wifi/model/yans-wifi-phy.cc b/src/wifi/model/yans-wifi-phy.cc index b6da63331..5b38810e9 100644 --- a/src/wifi/model/yans-wifi-phy.cc +++ b/src/wifi/model/yans-wifi-phy.cc @@ -786,7 +786,7 @@ YansWifiPhy::EndReceive (Ptr packet, Ptr even uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000; bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ()); double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30; - double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30 ; + double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30; NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm); m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ()); } diff --git a/src/wifi/test/wifi-phy-test.cc b/src/wifi/test/wifi-phy-test.cc index 049132036..f538b6e16 100644 --- a/src/wifi/test/wifi-phy-test.cc +++ b/src/wifi/test/wifi-phy-test.cc @@ -287,7 +287,7 @@ static void PrintPsr (int argc, char *argv[]) output = experiment.Run (input); double psr = output.received; - psr /= input.nPackets ; + psr /= input.nPackets; std::cout << psr << std::endl; } @@ -295,7 +295,7 @@ static void PrintPsr (int argc, char *argv[]) double CalcPsr (struct PsrExperiment::Output output, struct PsrExperiment::Input input) { double psr = output.received; - psr /= input.nPackets ; + psr /= input.nPackets; return psr; } diff --git a/src/wifi/wscript b/src/wifi/wscript index c1eb70423..1c4963c44 100644 --- a/src/wifi/wscript +++ b/src/wifi/wscript @@ -112,6 +112,7 @@ def build(bld): 'model/yans-error-rate-model.h', 'model/nist-error-rate-model.h', 'model/dsss-error-rate-model.h', + 'model/wifi-mac-queue.h', 'model/dca-txop.h', 'model/wifi-mac-header.h', 'model/qos-utils.h', diff --git a/src/wimax/doc/wimax.h b/src/wimax/doc/wimax.h deleted file mode 100644 index ce2ac6199..000000000 --- a/src/wimax/doc/wimax.h +++ /dev/null @@ -1,294 +0,0 @@ -/** - * \defgroup WiMAX WiMAX Models - * - * \section WiMAXModelOverview WiMAX Model Overview - * - * The 802.16 model provided in ns-3 attempts to provide an accurate MAC and - * PHY level implementation of the 802.16 specification with the - * Point-to-Multipoint (PMP) mode and the WirelessMAN-OFDM PHY layer. - * The model is mainly composed of three layers: - * - The convergence sublayer (CS) - * - The MAC CP Common Part Sublayer (MAC-CPS) - * - and The Physical (PHY) layer - * - * - * \section MACConvergenceSublayer MAC Convergence Sublayer - * - * The Convergence sublayer (CS) provided with this module implements - * the Packet CS, designed to work with the packet-based protocols at higher - * layers. The CS is responsible of receiving packet from the higher layer and - * from peer stations, classifying packets to appropriate connections (or - * service flows) and processing packets. It keeps a mapping of transport - * connections to service flows. This enables the MAC CPS identifying the Quality - * of Service (QoS) parameters associated to a transport connection and ensuring - * the QoS requirements. The CS currently employs an IP classifier. - * - * \section IPPacketClassifier IP Packet Classifier - * - * An IP packet classifier is used to map incoming packets to appropriate - * connections based on a set of criteria. The classifier maintains a list of - * mapping rules which associate an IP flow (src IP address and mask, dst IP address - * and mask, src port range, dst port range and protocol) to one of the service flows. - * By analyzing the IP and the TCP/UDP headers the classifier will append the incoming - * packet (from the upper layer) to the queue of the appropriate WiMAX connection. - * Classes IpcsClassifier and IpcsClassifierRecord implement the classifier module for - * both SS and BS - * - * \section CommonPartSublayer MAC Common Part Sublayer - * - * The MAC Common Part Sublayer (CPS) is the main sublayer of the IEEE 802.16 - * MAC and performs the fundamental functions of the MAC. The module implements - * the Point-Multi-Point (PMP) mode. In PMP mode BS is responsible of managing - * communication among multiple SSs. The key functionalities of the MAC CPS - * include framing and addressing, generation of MAC management messages, SS - * initialization and registration, service flow management, bandwidth - * management and scheduling services. - * Class WimaxNetDevice represents the MAC layer of a WiMAX network device. - * This class extends the NetDevice class of the ns-3 API that provides - * abstraction of a network device. WimaxNetDevice is further extended by - * BaseStationNetDevice and SubscriberStationNetDevice classes, defining MAC - * layers of BS and SS, respectively. Besides these main classes, the key - * functions of MAC are distributed to several other classes. - * - * \section FramingAndManagementMessages Framing and Management Messages - * - * The module implements a frame as a fixed duration of time, i.e., frame - * boundaries are defined with respect to time. Each frame is further - * subdivided into downlink (DL) and uplink (UL) subframes. The module implements - * the Time Division Duplex (TDD) mode where DL and UL operate on same frequency - * but are separated in time. A number of DL and UL bursts are then allocated in DL and UL - * subframes, respectively. Since the standard allows sending and - * receiving bursts of packets in a given DL or UL burst, the unit of - * transmission at the MAC layer is a packet burst. The module - * implements a special PacketBurst data structure for this purpose. A packet - * burst is essentially a list of packets. The BS downlink and uplink schedulers - * implemented by the classes BSScheduler and UplinkScheduler are responsible of - * generating DL and UL subframes, respectively. In the case of DL, the - * subframe is simulated by transmitting consecutive bursts (instances - * PacketBurst). In case of UL, the subframe is divided, with respect to time, - * into a number of slots. The bursts transmitted by the SSs in these slots are - * then aligned to slot boundaries. The frame is divided into integer number of - * symbols and Physical Slots (PS) which helps in managing bandwidth more - * effectively. The number of symbols per frame depends on the underlying - * implementation of the PHY layer. The size of a DL or UL burst is specified in - * units of symbols. - * - * \section NetworkEntryAndInitialization Network Entry and Initialization - * - * The network entry and initialization phase is basically divided into - * two sub-phases, (1) scanning and synchronization and (2) initial - * ranging. The entire phase is performed by the LinkManager component of SS - * and BS. - * Once an SS wants to join the network, it first scans the downlink - * frequencies to search for a suitable channel. The search is complete as soon - * as it detects a PHY frame. The next step is to establish synchronization - * with the BS. Once SS receives a Downlink-MAP (DL-MAP) message the synchronization - * phase is complete and it remains synchronized as long as it keeps receiving - * DL-MAP and Downlink Channel Descriptor (DCD) messages. After the synchronization - * is established, SS waits for a Uplink Channel Descriptor (UCD) message to - * acquire uplink channel parameters. Once acquired, the first sub-phase of - * the network entry and initialization is complete. - * Once synchronization is achieved, the SS waits for a UL-MAP message to - * locate a special grant, called initial ranging interval, in the UL subframe. - * This grant is allocated by the BS Uplink Scheduler at regular - * intervals. Currently this interval is set to 0.5 ms, however the user - * is enabled to modify its value from the simulation script. - * - * \section ConnectionsandAddressing Connections and Addressing - * - * All communication at the MAC layer is carried in terms of connections. The - * standard defines a connection as a unidirectional mapping between the SS and - * BS's MAC entities for the transmission of traffic. The standard defines two - * types of connections: management connections for transmitting - * control messages and transport connections for data transmission. A - * connection is identified by a 16-bit Connection Identifier (CID). - * Classes WimaxConnection and Cid implement the connection - * and CID, respectively. Note that each connection maintains its own - * transmission queue where packets to transmit on that connection are - * queued. The ConnectionManager component of BS is responsible - * of creating and managing connections for all SSs. - * - * The two key management connections defined by the standard, namely - * the Basic and Primary management connections, are created and - * allocated to the SS during the ranging process. Basic connection - * plays an important role throughout the operation of SS also because - * all (unicast) DL and UL grants are directed towards SS's Basic CID. - * In addition to management connections, an SS may have one or more - * transport connections to send data packets. - * The Connection Manager component of SS manages the connections associated to - * SS. As defined by the standard, a management connection is bidirectional, - * i.e., a pair of downlink and uplink connections is represented by the same - * CID. This feature is implemented in a way that one connection - * (in DL direction) is created by the BS and upon receiving the CID the SS - * then creates an identical connection (in UL direction) with the same CID. - * - * \section SchedulingServices Scheduling Services - * - * The module supports the four scheduling services defined by the 802.16-2004 - * standard: - * - * - Unsolicited Grant Service (UGS) - * - Real-Time Polling Services (rtPS) - * - Non Real-Time Polling Services (nrtPS) - * - Best Effort (BE) - * - * These scheduling services behave differently with respect to how they request - * bandwidth as well as how the it is granted. Each service flow is associated to - * exactly one scheduling service, and the QoS parameter set associated - * to a service flow actually defines the scheduling service it belongs - * to. When a service flow is created the UplinkScheduler calculates necessary - * parameters such as grant size and grant interval based on QoS parameters - * associated to it. - * - * \section WiMAXUplinkSchedulerModel WiMAX Uplink Scheduler Model - * - * Uplink Scheduler at the BS decides which of the SSs will be assigned - * uplink allocations based on the QoS parameters associated to a service - * flow (or scheduling service) and bandwidth requests from the SSs. Uplink - * scheduler together with Bandwidth Manager implements the complete - * scheduling service functionality. The standard defines up to four - * scheduling services (BE, UGS, rtPS, nrtPS) for applications with - * different types of QoS requirements. The service flows of these - * scheduling services behave differently with respect to how they request - * for bandwidth as well as how the bandwidth is granted. The module - * supports all four scheduling services. Each service flow is associated - * to exactly one transport connection and one scheduling service. The QoS - * parameters associated to a service flow actually define the scheduling - * service it belongs to. Standard QoS parameters for UGS, rtPS, nrtPS and - * BE services, as specified in Tables 111a to 111d of the 802.16e - * amendment, are supported. When a service flow is created the uplink - * scheduler calculates necessary parameters such as grant size and - * allocation interval based on QoS parameters associated to it. - * The current WiMAX module provides three different versions of schedulers. - * - The first one is a simple priority-based First Come First Serve (FCFS). - * For the real-time services (UGS and rtPS) the BS then allocates grants/polls on - * regular basis based on the calculated interval. For the non real-time - * services (nrtPS and BE) only minimum reserved bandwidth is guaranteed if - * available after servicing real-time flows. Note that not all of these - * parameters are utilized by the uplink scheduler. Also note that - * currently only service flow with fixed-size packet size are supported, - * as currently set up in simulation scenario with OnOff application of - * fixed packet size. This scheduler is implemented by classes - * BSSchedulerSimple and UplinkSchedulerSimple - * - The second one is similar to first scheduler except by rtPS service flow. - * All rtPS Connections are able to transmit all packet in the queue according - * to the available bandwidth. The bandwidth saturation control has been - * implemented to redistribute the effective available bandwidth to all rtPS - * that have at least one packet to transmit. The remaining bandwidth is allocated - * to nrtPS and BE Connections. This scheduler is implemented by classes - * BSSchedulerRtps and UplinkSchedulerRtps - * - The third one is a Migration-based Quality of Service uplink scheduler - * This uplink scheduler uses three queues, the low priority - * queue, the intermediate queue and the high priority queue. - * The scheduler serves the requests in strict priority order - * from the high priority queue to the low priority queue. The - * low priority queue stores the bandwidth requests of the BE - * service flow. The intermediate queue holds bandwidth requests - * sent by rtPS and by nrtPS connections. rtPS and nrtPS requests - * can migrate to the high priority queue to guarantee that - * their QoS requirements are met. Besides the requests migrated - * from the intermediate queue, the high priority queue stores - * periodic grants and unicast request opportunities that must be - * scheduled in the following frame. To guarantee the maximum delay - * requirement, the BS assigns a deadline to each rtPS bandwidth - * request in the intermediate queue. The minimum bandwidth - * requirement of both rtPS and nrtPS connections is guaranteed - * over a window of duration T. This scheduler is implemented by the class - * UplinkSchedulerMBQoS. - * - * \section WiMAXOutboundSchedulersModel WiMAX Outbound Schedulers Model - * - * Besides the uplink scheduler these are the outbound schedulers at BS and - * SS side (BSScheduler and SSScheduler). The outbound schedulers decide - * which of the packets from the outbound queues will be transmitted in a - * given allocation. The outbound scheduler at the BS schedules the - * downlink traffic, i.e., packets to be transmitted to the SSs in the - * downlink subframe. Similarly the outbound scheduler at a SS schedules - * the packet to be transmitted in the uplink allocation assigned to that - * SS in the uplink subframe. All three schedulers have been implemented to - * work as FCFS scheduler, as they allocate grants starting from highest - * priority scheduling service to the lower priority one (UGS> rtPS> - * nrtPS> BE). The standard does not suggest any scheduling algorithm and - * instead leaves this decision up to the manufacturers. Of course more - * sophisticated algorithms can be added later if required. - * - * \section WiMAXPhyModel WiMAX PHY Model - * - * For the physical layer, we chose the Wireless MAN OFDM PHY specifications - * as the more relevant for implementation as it is the schema chosen by the - * WiMAX Forum. This specification is designed for non-light-of-sight (NLOS) - * including fixed and mobile broadband wireless access. - * The proposed model uses a 256 FFT processor, with 192 data subcarriers. - * It supports all the seven modulation and coding schemes specified by Wireless - * MAN-OFDM. It is composed of two parts: the channel model and the physical model. - * - * \subsection channelModel Channel model - * - * The channel model we propose is implemented by the class SimpleOFDMWimaxChannel which - * extends the wimaxchannel class. The channel entity has a private structure named m_phyList - * which handles all the physical devices connected to it. When a physical device sends a packet (FEC Block) - * to the channel, the channel handles the packet, and then for each physical device connected to it, it - * calculates the propagation delay, the path loss according to a given propagation model and eventually forwards the - * packet to the receiver device. - * - * The channel class uses the method GetDistanceFrom() to calculate the distance between two physical - * entities according to their 3D coordinates. The delay is computed as delay = distance/C, where C - * is the speed of the light. We have implemented three different propagation models for the path loss - * calculation: FRIIS, LOG-DISTANCE and COST-Hata-Model. - * - * \subsection phyModel Physical model - * - * The physical layer performs two main operations: (i) It receives a burst from a channel and forwards it to the - * MAC layer, (ii) it receives a burst from the MAC layer and transmits it on the channel. In order to reduce the - * simulation complexity of the WiMAX physical layer, we have chosen to model offline part of the physical layer. - * More specifically we have developed an OFDM simulator to generate trace files used by the reception process to - * evaluate if a FEC block can be correctly decoded or not. - * - * Transmission Process: A burst is a set of WiMAX MAC PDUs. At the sending process, a burst is converted into - * bit-streams and then splitted into smaller FEC blocks which are then sent to the channel with a power equal - * P_tx. - * - * Reception Process: The reception process includes the following operations: - * - * 1- Receive a FEC block from the channel. - * 2- Calculate the noise level. - * 3- Estimate the signal to noise ratio (SNR) with the following formula. - * 4- Determine if a FEC block can be correctly decoded. - * 5- Concatenate received FEC blocks to reconstruct the original burst. - * 6- Forward the burst to the upper layer. - * - * The developed process to evaluate if a FEC block can be correctly received or not uses pre-generated traces. - * The trace files are generated by an external OFDM simulator (described later). A class named - * SNRToBlockErrorRateManager handles a repository containing seven trace files (one for each modulation and coding - * scheme). A repository is specific for a particular channel model. - * - * A trace file is made of 6 columns. The first column provides the SNR value (1), whereas the other columns give - * respectively the bit error rate BER (2), the block error rate BlcER(3), the standard deviation on BlcER, and - * the confidence interval (4 and 5). - * These trace files are loaded into memory by the SNRToBlockErrorRateManager entity at the beginning of the simulation. - * - * Currently, The first process uses the first and third columns to determine if a FEC block is correctly received. When - * the physical layer receives a packet with an SNR equal to SNR_rx, it asks the SNRToBlockErrorRateManager to return - * the corresponding block error rate BlcER. A random number RAND between 0 and 1 is then generated. If RAND is - * greater than BlcER, then the block is correctly received, otherwise the block is considered erroneous and is ignored. - * - * The module provides defaults SNR to block error rate traces in default-traces.h. The traces have been generated by an - * External WiMAX OFDM simulator. The simulator is based on an external mathematics and signal processing library IT++ - * and includes : a random block generator, a Reed Solomon (RS) coder, a convolutional coder, an interleaver, a 256 - * FFT-based OFDM modulator, a multi-path channel simulator and an equalizer. The multipath channel is simulated using - * the TDL_channel class of the IT++ library. - * - * Users can configure the module to use their own traces generated by another OFDM simulator or ideally by performing - * experiments in real environment. for this purpose, a path to a repository containing trace files should be provided. - * If no repository is provided the traces form default-traces.h will be loaded. A valid repository should contain 7 - * files, one for each modulation and coding scheme. - * - * The names of the files should respect the following format: modulation0.txt for modulation 0, modulation1.txt for - * modulation 1 and so on... - * The file format should be as follows - * SNR_value1 BER Blc_ER STANDARD_DEVIATION CONFIDENCE_INTERVAL1 CONFIDENCE_INTERVAL2 - * SNR_value2 BER Blc_ER STANDARD_DEVIATION CONFIDENCE_INTERVAL1 CONFIDENCE_INTERVAL2 - * ... ... ... ... ... ... - * ... ... ... ... ... ... - */ - diff --git a/src/wimax/doc/wimax.rst b/src/wimax/doc/wimax.rst index 4a6ff7b74..f1ecc8cbb 100644 --- a/src/wimax/doc/wimax.rst +++ b/src/wimax/doc/wimax.rst @@ -156,7 +156,7 @@ The WimaxNetDevice makes heavy use of the |ns3| :ref:`Attributes` subsystem for configuration and default value management. Presently, approximately 60 values are stored in this system. -For instance, class :cpp:class:`ns-3::SimpleOfdmWimaxPhy` exports these +For instance, class ``ns-3::SimpleOfdmWimaxPhy`` exports these attributes: * NoiseFigure: Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver. @@ -207,16 +207,15 @@ three layers: * Physical (PHY) layer -The following figure :ref:`WimaxArchitecture` shows the relationships of these +The following figure :ref:`wimax-architecture` shows the relationships of these models. .. _wimax-architecture: .. figure:: figures/WimaxArchitecture.* - WiMAX architecture. - -the Convergence Sublayer ++++++++++++++++++++++++ +Convergence Sublayer +++++++++++++++++++++ The Convergence sublayer (CS) provided with this module implements the Packet CS, designed to work with the packet-based protocols at higher layers. The CS is @@ -227,7 +226,8 @@ enables the MAC CPS identifying the Quality of Service (QoS) parameters associated to a transport connection and ensuring the QoS requirements. The CS currently employs an IP classifier. -IP Packet Classifier ++++++++++++++++++++ +IP Packet Classifier +++++++++++++++++++++ An IP packet classifier is used to map incoming packets to appropriate connections based on a set of criteria. The classifier maintains a list of diff --git a/src/wimax/model/bandwidth-manager.h b/src/wimax/model/bandwidth-manager.h index 522e844fc..7540ea6d6 100644 --- a/src/wimax/model/bandwidth-manager.h +++ b/src/wimax/model/bandwidth-manager.h @@ -41,6 +41,7 @@ class UlJob; class UplinkScheduler; /** + * \ingroup wimax * \brief This class manage the bandwidth request and grant mechanism. * The bandwidth request and grant mechanism is supported by the Bandwidth * Manager. Both BS and SS maintain a bandwidth manager. Furthermore BS's diff --git a/src/wimax/model/bs-link-manager.h b/src/wimax/model/bs-link-manager.h index aedb105c7..8b63c9014 100644 --- a/src/wimax/model/bs-link-manager.h +++ b/src/wimax/model/bs-link-manager.h @@ -32,6 +32,9 @@ namespace ns3 { +/** + * \ingroup wimax + */ class BSLinkManager : public Object { public: diff --git a/src/wimax/model/bs-net-device.cc b/src/wimax/model/bs-net-device.cc index 354d439ef..6e98ee68c 100644 --- a/src/wimax/model/bs-net-device.cc +++ b/src/wimax/model/bs-net-device.cc @@ -524,8 +524,8 @@ BaseStationNetDevice::StartFrame (void) { //setting DL/UL subframe allocation for this frame uint32_t symbolsPerFrame = GetPhy ()->GetSymbolsPerFrame (); - SetNrDlSymbols ((symbolsPerFrame / 2) - static_cast (ceil(GetTtg()*m_psDuration.GetSeconds ()/m_symbolDuration.GetSeconds ()))); - SetNrUlSymbols ((symbolsPerFrame / 2) - static_cast (ceil(GetRtg()*m_psDuration.GetSeconds ()/m_symbolDuration.GetSeconds ()))); + SetNrDlSymbols ((symbolsPerFrame / 2) - static_cast (ceil (GetTtg ()*m_psDuration.GetSeconds ()/m_symbolDuration.GetSeconds ()))); + SetNrUlSymbols ((symbolsPerFrame / 2) - static_cast (ceil (GetRtg ()*m_psDuration.GetSeconds ()/m_symbolDuration.GetSeconds ()))); m_frameStartTime = Simulator::Now (); diff --git a/src/wimax/model/bs-net-device.h b/src/wimax/model/bs-net-device.h index 14159d0d6..5ef70964e 100644 --- a/src/wimax/model/bs-net-device.h +++ b/src/wimax/model/bs-net-device.h @@ -44,6 +44,9 @@ class BSLinkManager; class UplinkScheduler; class BsServiceFlowManager; +/** + * \ingroup wimax + */ class BaseStationNetDevice : public WimaxNetDevice { public: diff --git a/src/wimax/model/bs-scheduler-rtps.h b/src/wimax/model/bs-scheduler-rtps.h index 9abf6ea02..8b6a94a24 100644 --- a/src/wimax/model/bs-scheduler-rtps.h +++ b/src/wimax/model/bs-scheduler-rtps.h @@ -39,6 +39,7 @@ class WimaxConnection; class Cid; /** + * \ingroup wimax * \brief This class implements a simple downlink scheduler for rtPS flows. * * The DL-rtPS-Scheduler assigns the available bandwidth the service flows diff --git a/src/wimax/model/bs-scheduler-simple.cc b/src/wimax/model/bs-scheduler-simple.cc index ab6f0e73e..fafa4b7ac 100644 --- a/src/wimax/model/bs-scheduler-simple.cc +++ b/src/wimax/model/bs-scheduler-simple.cc @@ -267,7 +267,7 @@ bool BSSchedulerSimple::SelectConnection (Ptr &connection) serviceFlowRecord = (*iter2)->GetRecord (); NS_LOG_INFO ("processing UGS: HAS PACKET=" << (*iter2)->HasPackets () << "max Latency = " << MilliSeconds ((*iter2)->GetMaximumLatency ()) << "Delay = " << ((currentTime - - serviceFlowRecord->GetDlTimeStamp ()) + GetBs ()->GetPhy ()->GetFrameDuration ())); + - serviceFlowRecord->GetDlTimeStamp ()) + GetBs ()->GetPhy ()->GetFrameDuration ())); // if latency would exceed in case grant is allocated in next frame then allocate in current frame if ((*iter2)->HasPackets () && ((currentTime - serviceFlowRecord->GetDlTimeStamp ()) + GetBs ()->GetPhy ()->GetFrameDuration ()) > MilliSeconds ((*iter2)->GetMaximumLatency ())) diff --git a/src/wimax/model/bs-scheduler-simple.h b/src/wimax/model/bs-scheduler-simple.h index c642b9148..eeaca2c9d 100644 --- a/src/wimax/model/bs-scheduler-simple.h +++ b/src/wimax/model/bs-scheduler-simple.h @@ -37,6 +37,9 @@ class GenericMacHeader; class WimaxConnection; class Cid; +/** + * \ingroup wimax + */ class BSSchedulerSimple : public BSScheduler { public: diff --git a/src/wimax/model/bs-scheduler.h b/src/wimax/model/bs-scheduler.h index 5ff10f469..3e6167098 100644 --- a/src/wimax/model/bs-scheduler.h +++ b/src/wimax/model/bs-scheduler.h @@ -37,6 +37,9 @@ class GenericMacHeader; class WimaxConnection; class Cid; +/** + * \ingroup wimax + */ class BSScheduler : public Object { public: diff --git a/src/wimax/model/bs-service-flow-manager.h b/src/wimax/model/bs-service-flow-manager.h index 52d04936e..58c1fb8eb 100644 --- a/src/wimax/model/bs-service-flow-manager.h +++ b/src/wimax/model/bs-service-flow-manager.h @@ -37,6 +37,9 @@ class SSRecord; class WimaxConnection; class BaseStationNetDevice; +/** + * \ingroup wimax + */ class BsServiceFlowManager : public ServiceFlowManager { public: diff --git a/src/wimax/model/bs-uplink-scheduler-mbqos.cc b/src/wimax/model/bs-uplink-scheduler-mbqos.cc index bda166057..72b44dbc1 100644 --- a/src/wimax/model/bs-uplink-scheduler-mbqos.cc +++ b/src/wimax/model/bs-uplink-scheduler-mbqos.cc @@ -307,7 +307,7 @@ UplinkSchedulerMBQoS::Schedule (void) // Recover period interval information for UGS flow Time frame_duration = GetBs ()->GetPhy ()->GetFrameDuration (); Time - timestamp = + timestamp = (*(ssRecord->GetServiceFlows (ServiceFlow::SF_TYPE_UGS).begin ()))->GetRecord ()->GetLastGrantTime () + MilliSeconds ((*(ssRecord->GetServiceFlows (ServiceFlow::SF_TYPE_UGS).begin ()))->GetUnsolicitedGrantInterval ()); @@ -688,7 +688,7 @@ UplinkSchedulerMBQoS::CheckDeadline (uint32_t &availableSymbols) continue; } - uint32_t symbolsToAllocate = GetBs ()->GetPhy ()->GetNrSymbols(allocationSize, job->GetSsRecord ()->GetModulationType ()); + uint32_t symbolsToAllocate = GetBs ()->GetPhy ()->GetNrSymbols (allocationSize, job->GetSsRecord ()->GetModulationType ()); if (symbolsToAllocate > availableSymbols) { symbolsToAllocate = availableSymbols; diff --git a/src/wimax/model/bs-uplink-scheduler-mbqos.h b/src/wimax/model/bs-uplink-scheduler-mbqos.h index 2b890e440..87bc93f84 100644 --- a/src/wimax/model/bs-uplink-scheduler-mbqos.h +++ b/src/wimax/model/bs-uplink-scheduler-mbqos.h @@ -42,6 +42,7 @@ class ServiceFlowRecord; class UlJob; /** + * \ingroup wimax * \brief This class implements a Migration-based Quality of Service uplink scheduler(MBQoS). * * This uplink scheduler uses three queues, the low priority diff --git a/src/wimax/model/bs-uplink-scheduler-rtps.h b/src/wimax/model/bs-uplink-scheduler-rtps.h index ec4a10d36..3dcc34069 100644 --- a/src/wimax/model/bs-uplink-scheduler-rtps.h +++ b/src/wimax/model/bs-uplink-scheduler-rtps.h @@ -34,6 +34,7 @@ class SSRecord; class ServiceFlow; /** + * \ingroup wimax * \brief This class implements a simple uplink scheduler for rtPS flows. * * The UL-rtPS-Scheduler work in this way: diff --git a/src/wimax/model/bs-uplink-scheduler-simple.h b/src/wimax/model/bs-uplink-scheduler-simple.h index 2a131ba7a..ec967b6e8 100644 --- a/src/wimax/model/bs-uplink-scheduler-simple.h +++ b/src/wimax/model/bs-uplink-scheduler-simple.h @@ -34,6 +34,9 @@ class BaseStationNetDevice; class SSRecord; class ServiceFlow; +/** + * \ingroup wimax + */ class UplinkSchedulerSimple : public UplinkScheduler { public: diff --git a/src/wimax/model/bs-uplink-scheduler.h b/src/wimax/model/bs-uplink-scheduler.h index 58d26d061..097de0e59 100644 --- a/src/wimax/model/bs-uplink-scheduler.h +++ b/src/wimax/model/bs-uplink-scheduler.h @@ -36,6 +36,7 @@ class ServiceFlow; class ServiceFlowRecord; /** + * \ingroup wimax * \brief Virtual class for uplink scheduler. */ class UplinkScheduler : public Object diff --git a/src/wimax/model/burst-profile-manager.h b/src/wimax/model/burst-profile-manager.h index 147ccd151..a915931d3 100644 --- a/src/wimax/model/burst-profile-manager.h +++ b/src/wimax/model/burst-profile-manager.h @@ -31,6 +31,9 @@ namespace ns3 { class SSRecord; class RngReq; +/** + * \ingroup wimax + */ class BurstProfileManager : public Object { public: diff --git a/src/wimax/model/cid-factory.h b/src/wimax/model/cid-factory.h index cc0b7dabe..0d1a8d4c0 100644 --- a/src/wimax/model/cid-factory.h +++ b/src/wimax/model/cid-factory.h @@ -30,6 +30,7 @@ namespace ns3 { /** + * \ingroup wimax * This class is used exclusively by the BS to allocate CIDs to new connections. * This class uses the definitions from Table 345 in ieee-802.16-2004 to * allocate cids in different integer ranges according to their type. diff --git a/src/wimax/model/cid.h b/src/wimax/model/cid.h index 282c3618c..09f2077bc 100644 --- a/src/wimax/model/cid.h +++ b/src/wimax/model/cid.h @@ -29,6 +29,9 @@ namespace ns3 { +/** + * \ingroup wimax + */ class Cid { public: diff --git a/src/wimax/model/connection-manager.h b/src/wimax/model/connection-manager.h index 2174782ff..469807b9b 100644 --- a/src/wimax/model/connection-manager.h +++ b/src/wimax/model/connection-manager.h @@ -36,8 +36,9 @@ class RngRsp; class WimaxNetDevice; class SubscriberStationNetDevice; -/* - The same connection manager class serves both for BS and SS though some functions are exclusive to only one of them. +/** + * \ingroup wimax + * The same connection manager class serves both for BS and SS though some functions are exclusive to only one of them. */ class ConnectionManager : public Object diff --git a/src/wimax/model/cs-parameters.h b/src/wimax/model/cs-parameters.h index 67c3e9e8c..67385ec1a 100644 --- a/src/wimax/model/cs-parameters.h +++ b/src/wimax/model/cs-parameters.h @@ -26,6 +26,9 @@ #define CSPARAMETERS_H_ namespace ns3 { +/** + * \ingroup wimax + */ class CsParameters { public: diff --git a/src/wimax/model/dl-mac-messages.h b/src/wimax/model/dl-mac-messages.h index 721dd3da3..38cf85bb7 100644 --- a/src/wimax/model/dl-mac-messages.h +++ b/src/wimax/model/dl-mac-messages.h @@ -29,14 +29,15 @@ namespace ns3 { +/** + * \ingroup wimax + * \brief This class implements the DCD channel encodings as described by "IEEE Standard for + * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access Systems" + * 11.4.1 DCD channel encodings, page 659 + * + */ class DcdChannelEncodings { - /** - * \brief This class implements the DCD channel encodings as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access Systems" - * 11.4.1 DCD channel encodings, page 659 - * - */ public: DcdChannelEncodings (void); virtual ~DcdChannelEncodings (void); diff --git a/src/wimax/model/ipcs-classifier-record.h b/src/wimax/model/ipcs-classifier-record.h index 2a44a6bbe..edfafffbf 100644 --- a/src/wimax/model/ipcs-classifier-record.h +++ b/src/wimax/model/ipcs-classifier-record.h @@ -28,6 +28,9 @@ namespace ns3 { +/** + * \ingroup wimax + */ class IpcsClassifierRecord { public: diff --git a/src/wimax/model/ipcs-classifier.h b/src/wimax/model/ipcs-classifier.h index 489adbdcd..cd07cf4bb 100644 --- a/src/wimax/model/ipcs-classifier.h +++ b/src/wimax/model/ipcs-classifier.h @@ -30,6 +30,9 @@ namespace ns3 { class SsServiceFlowManager; +/** + * \ingroup wimax + */ class IpcsClassifier : public Object { public: diff --git a/src/wimax/model/mac-messages.h b/src/wimax/model/mac-messages.h index 73e9a5543..876ddb4ac 100644 --- a/src/wimax/model/mac-messages.h +++ b/src/wimax/model/mac-messages.h @@ -35,6 +35,9 @@ namespace ns3 { +/** + * \ingroup wimax + */ class ManagementMessageType : public Header { public: diff --git a/src/wimax/model/ofdm-downlink-frame-prefix.h b/src/wimax/model/ofdm-downlink-frame-prefix.h index 72f5cbe6c..c27b5cff9 100644 --- a/src/wimax/model/ofdm-downlink-frame-prefix.h +++ b/src/wimax/model/ofdm-downlink-frame-prefix.h @@ -27,10 +27,10 @@ namespace ns3 { /** + * \ingroup wimax *\brief This class implements the DL Frame Prefix IE as described by IEEE-802.16 standard *\brief The DL Frame Prefix IE is contained in DLFP (Downlink Frame Prefix) in OFDM PHY */ - class DlFramePrefixIe { public: diff --git a/src/wimax/model/send-params.h b/src/wimax/model/send-params.h index 60e56d387..d2c355e5e 100644 --- a/src/wimax/model/send-params.h +++ b/src/wimax/model/send-params.h @@ -29,19 +29,19 @@ namespace ns3 { class WimaxPhy; +/** + * \ingroup wimax + * \brief The SendParams class defines the parameters with which Send() function of + * a particular PHY is called. The sole purpose of this class is to allow + * defining the pure virtual Send() function in the PHY base-class (WimaxPhy). + * This class shall be sub-classed every time a new PHY is integrated (i.e., + * a new sub-class of WimaxPhy is created) which requires different or + * additional parameters to call its Send() function. For example as it is + * seen here, it has been sub-classed for the OFDM PHY layer since its Send() + * function requires two additional parameters. + */ class SendParams { - /** - * \brief The SendParams class defines the parameters with which Send() function of - * a particular PHY is called. The sole purpose of this class is to allow - * defining the pure virtual Send() function in the PHY base-class (WimaxPhy). - * This class shall be sub-classed every time a new PHY is integrated (i.e., - * a new sub-class of WimaxPhy is created) which requires different or - * additional parameters to call its Send() function. For example as it is - * seen here, it has been sub-classed for the OFDM PHY layer since its Send() - * function requires two additional parameters. - */ - public: SendParams (); virtual ~SendParams (); diff --git a/src/wimax/model/service-flow-manager.h b/src/wimax/model/service-flow-manager.h index 9b03dc4aa..919296835 100644 --- a/src/wimax/model/service-flow-manager.h +++ b/src/wimax/model/service-flow-manager.h @@ -35,10 +35,10 @@ class WimaxNetDevice; class SSRecord; class WimaxConnection; -/* - The same service flow manager class serves both for BS and SS though some functions are exclusive to only one of them. +/** + * \ingroup wimax + * The same service flow manager class serves both for BS and SS though some functions are exclusive to only one of them. */ - class ServiceFlowManager : public Object { public: diff --git a/src/wimax/model/service-flow-record.h b/src/wimax/model/service-flow-record.h index 0bb110e2d..3ce330758 100644 --- a/src/wimax/model/service-flow-record.h +++ b/src/wimax/model/service-flow-record.h @@ -28,11 +28,13 @@ #include "ns3/ptr.h" namespace ns3 { + +/** + * \ingroup wimax + * \brief this class implements a structure to manage some parameters and statistics related to a service flow + */ class ServiceFlowRecord { - /** - * \brief this class implements a structure to manage some parameters and statistics related to a service flow - */ public: ServiceFlowRecord (void); ~ServiceFlowRecord (void); diff --git a/src/wimax/model/service-flow.h b/src/wimax/model/service-flow.h index ef0b5c109..a39cfeece 100644 --- a/src/wimax/model/service-flow.h +++ b/src/wimax/model/service-flow.h @@ -32,11 +32,12 @@ namespace ns3 { class ServiceFlowRecord; class WimaxConnection; -class ServiceFlow -{ /** + * \ingroup wimax * This class implements service flows as described by the IEEE-802.16 standard */ +class ServiceFlow +{ public: enum Direction { diff --git a/src/wimax/model/simple-ofdm-send-param.h b/src/wimax/model/simple-ofdm-send-param.h index 942234b77..f60f6c724 100644 --- a/src/wimax/model/simple-ofdm-send-param.h +++ b/src/wimax/model/simple-ofdm-send-param.h @@ -29,6 +29,10 @@ #define SIMPLEOFDMSENDPARAM_H_ namespace ns3 { + +/** + * \ingroup wimax + */ class simpleOfdmSendParam { public: @@ -103,7 +107,7 @@ public: /** * \return the received burst */ - Ptr GetBurst(void); + Ptr GetBurst (void); private: bvec m_fecBlock; diff --git a/src/wimax/model/simple-ofdm-wimax-channel.cc b/src/wimax/model/simple-ofdm-wimax-channel.cc index 76a40d413..1fb98795a 100644 --- a/src/wimax/model/simple-ofdm-wimax-channel.cc +++ b/src/wimax/model/simple-ofdm-wimax-channel.cc @@ -150,7 +150,7 @@ SimpleOfdmWimaxChannel::Send (Time BlockTime, simpleOfdmSendParam * param; for (std::list >::iterator iter = m_phyList.begin (); iter != m_phyList.end (); ++iter) { - Time delay = Seconds(0); + Time delay = Seconds (0); if (phy != *iter) { double distance = 0; @@ -158,7 +158,7 @@ SimpleOfdmWimaxChannel::Send (Time BlockTime, if (receiverMobility != 0 && senderMobility != 0 && m_loss != 0) { distance = senderMobility->GetDistanceFrom (receiverMobility); - delay = Seconds(distance/300000000.0); + delay = Seconds (distance/300000000.0); rxPowerDbm = m_loss->CalcRxPower (txPowerDbm, senderMobility, receiverMobility); } @@ -199,7 +199,7 @@ SimpleOfdmWimaxChannel::EndSendDummyBlock (Ptr rxphy, simple param->GetModulationType (), param->GetDirection (), param->GetRxPowerDbm (), - param->GetBurst()); + param->GetBurst ()); delete param; } } diff --git a/src/wimax/model/simple-ofdm-wimax-channel.h b/src/wimax/model/simple-ofdm-wimax-channel.h index 9a5e677f8..738bb9b51 100644 --- a/src/wimax/model/simple-ofdm-wimax-channel.h +++ b/src/wimax/model/simple-ofdm-wimax-channel.h @@ -35,6 +35,9 @@ class Packet; class PacketBurst; class SimpleOfdmWimaxPhy; +/** + * \ingroup wimax + */ class SimpleOfdmWimaxChannel : public WimaxChannel { public: diff --git a/src/wimax/model/simple-ofdm-wimax-phy.cc b/src/wimax/model/simple-ofdm-wimax-phy.cc index f4bbece22..dc54987e9 100644 --- a/src/wimax/model/simple-ofdm-wimax-phy.cc +++ b/src/wimax/model/simple-ofdm-wimax-phy.cc @@ -43,7 +43,7 @@ NS_OBJECT_ENSURE_REGISTERED (SimpleOfdmWimaxPhy); TypeId SimpleOfdmWimaxPhy::GetTypeId (void) { static TypeId - tid = + tid = TypeId ("ns3::SimpleOfdmWimaxPhy").SetParent () .AddAttribute ("NoiseFigure", @@ -263,7 +263,7 @@ SimpleOfdmWimaxPhy::Send (Ptr burst, m_nrFecBlocksSent = 0; m_currentBurst = burst; SetBlockParameters (burst->GetSize (), modulationType); - NotifyTxBegin(m_currentBurst); + NotifyTxBegin (m_currentBurst); StartSendDummyFecBlock (true, modulationType, direction); m_traceTx (burst); } @@ -318,11 +318,11 @@ SimpleOfdmWimaxPhy::EndSendFecBlock (WimaxPhy::ModulationType modulationType, { // this is the last FEC block of the burst NS_ASSERT_MSG (m_nrRemainingBlocksToSend == 0, "Error while sending a burst"); - NotifyTxEnd(m_currentBurst); + NotifyTxEnd (m_currentBurst); } else { - StartSendDummyFecBlock(false,modulationType,direction); + StartSendDummyFecBlock (false,modulationType,direction); } } @@ -393,7 +393,7 @@ SimpleOfdmWimaxPhy::StartReceive (uint32_t burstSize, { if (isFirstBlock) { - NotifyRxBegin(burst); + NotifyRxBegin (burst); m_receivedFecBlocks->clear (); m_nrRecivedFecBlocks=0; SetBlockParameters (burstSize, modulationType); diff --git a/src/wimax/model/simple-ofdm-wimax-phy.h b/src/wimax/model/simple-ofdm-wimax-phy.h index 5011511e3..7dd723a9f 100644 --- a/src/wimax/model/simple-ofdm-wimax-phy.h +++ b/src/wimax/model/simple-ofdm-wimax-phy.h @@ -39,6 +39,9 @@ class NetDevice; class Packet; class SimpleOfdmWimaxChannel; +/** + * \ingroup wimax + */ class SimpleOfdmWimaxPhy : public WimaxPhy { public: diff --git a/src/wimax/model/snr-to-block-error-rate-manager.h b/src/wimax/model/snr-to-block-error-rate-manager.h index e6f4ed721..e4cc74195 100644 --- a/src/wimax/model/snr-to-block-error-rate-manager.h +++ b/src/wimax/model/snr-to-block-error-rate-manager.h @@ -20,7 +20,17 @@ */ +#ifndef SNRTOBLOCKERRORRATEMANAGER_H_ +#define SNRTOBLOCKERRORRATEMANAGER_H_ + +#include "ns3/snr-to-block-error-rate-record.h" +#include +#include "ns3/ptr.h" + +namespace ns3 { + /** + * \ingroup wimax * \brief This class handles the SNR to BlcER traces. A path to a repository containing trace files should be provided. * If no repository is provided the traces form default-traces.h will be loaded. * A valid repository should contain 7 files, one for each modulation and coding scheme. @@ -33,15 +43,6 @@ * ... ... ... ... ... ... * SNR_value(n) BER(n) Blc_ER(n) STANDARD_DEVIATION(n) CONFIDENCE_INTERVAL1(n) CONFIDENCE_INTERVAL2(n) */ -#ifndef SNRTOBLOCKERRORRATEMANAGER_H_ -#define SNRTOBLOCKERRORRATEMANAGER_H_ - -#include "ns3/snr-to-block-error-rate-record.h" -#include -#include "ns3/ptr.h" - -namespace ns3 { - class SNRToBlockErrorRateManager { public: diff --git a/src/wimax/model/snr-to-block-error-rate-record.h b/src/wimax/model/snr-to-block-error-rate-record.h index 69a93938d..797894c7c 100644 --- a/src/wimax/model/snr-to-block-error-rate-record.h +++ b/src/wimax/model/snr-to-block-error-rate-record.h @@ -19,17 +19,17 @@ * */ +#ifndef SNRTOBLOCKERRORRATERECORD_H_ +#define SNRTOBLOCKERRORRATERECORD_H_ +namespace ns3 { + /** + * \ingroup wimax * \brief This class represents a record (handled by SnrToBlockErrorRate manager) that keeps a mapping between * an SNR value and its corresponding (1) Bit Error Rate, (2) Block Error Rate, (3) Standard deviation, (4 and 5) * confidence interval. * */ - -#ifndef SNRTOBLOCKERRORRATERECORD_H_ -#define SNRTOBLOCKERRORRATERECORD_H_ -namespace ns3 { - class SNRToBlockErrorRateRecord { public: diff --git a/src/wimax/model/ss-link-manager.h b/src/wimax/model/ss-link-manager.h index e18553b1f..2c5b7aa5e 100644 --- a/src/wimax/model/ss-link-manager.h +++ b/src/wimax/model/ss-link-manager.h @@ -33,12 +33,13 @@ namespace ns3 { +/** + * \ingroup wimax + * \brief this class implements the link manager of subscriber station net device. An ss link manager is + * responsible for link scanning and ranging + */ class SSLinkManager : public Object { - /** - * \brief this class implements the link manager of subscriber station net device. An ss link manager is - * responsible for link scanning and ranging - */ public: SSLinkManager (Ptr ss); ~SSLinkManager (void); diff --git a/src/wimax/model/ss-manager.h b/src/wimax/model/ss-manager.h index 8016b356b..f3f3b050f 100644 --- a/src/wimax/model/ss-manager.h +++ b/src/wimax/model/ss-manager.h @@ -29,12 +29,13 @@ namespace ns3 { +/** + * \ingroup wimax + * \brief this class manages a list of SSrecord + * \see SSrecord + */ class SSManager : public Object { - /** - * \brief this class manages a list of SSrecord - * \see SSrecord - */ public: SSManager (void); ~SSManager (void); diff --git a/src/wimax/model/ss-net-device.cc b/src/wimax/model/ss-net-device.cc index 5bd4ca971..3f4b0fd0e 100644 --- a/src/wimax/model/ss-net-device.cc +++ b/src/wimax/model/ss-net-device.cc @@ -57,7 +57,7 @@ TypeId SubscriberStationNetDevice::GetTypeId (void) { static TypeId - tid = + tid = TypeId ("ns3::SubscriberStationNetDevice") .SetParent () diff --git a/src/wimax/model/ss-net-device.h b/src/wimax/model/ss-net-device.h index 969ce0b37..dba01534e 100644 --- a/src/wimax/model/ss-net-device.h +++ b/src/wimax/model/ss-net-device.h @@ -40,6 +40,10 @@ class SSScheduler; class SSLinkManager; class SsServiceFlowManager; class IpcsClassifier; + +/** + * \ingroup wimax + */ class SubscriberStationNetDevice : public WimaxNetDevice { public: diff --git a/src/wimax/model/ss-record.h b/src/wimax/model/ss-record.h index 83b2dab0b..c205d7777 100644 --- a/src/wimax/model/ss-record.h +++ b/src/wimax/model/ss-record.h @@ -36,11 +36,12 @@ namespace ns3 { class ServiceFlow; +/** + * \ingroup wimax + * \brief This class is used by the base station to store some information related to subscriber station in the cell. + */ class SSRecord { - /** - * \brief This class is used by the base station to store some information related to subscriber station in the cell. - */ public: SSRecord (void); SSRecord (Mac48Address macAddress); diff --git a/src/wimax/model/ss-scheduler.h b/src/wimax/model/ss-scheduler.h index 96aba72f8..25b23a4ac 100644 --- a/src/wimax/model/ss-scheduler.h +++ b/src/wimax/model/ss-scheduler.h @@ -34,6 +34,9 @@ namespace ns3 { class SubscriberStationNetDevice; class WimaxConnection; +/** + * \ingroup wimax + */ class SSScheduler : public Object { diff --git a/src/wimax/model/ss-service-flow-manager.h b/src/wimax/model/ss-service-flow-manager.h index eeea8feb1..3c859613f 100644 --- a/src/wimax/model/ss-service-flow-manager.h +++ b/src/wimax/model/ss-service-flow-manager.h @@ -36,6 +36,9 @@ class WimaxNetDevice; class WimaxConnection; class SubscriberStationNetDevice; +/** + * \ingroup wimax + */ class SsServiceFlowManager : public ServiceFlowManager { public: diff --git a/src/wimax/model/ul-job.cc b/src/wimax/model/ul-job.cc index 776a7f53b..db0b9105d 100644 --- a/src/wimax/model/ul-job.cc +++ b/src/wimax/model/ul-job.cc @@ -24,7 +24,7 @@ namespace ns3 { -UlJob::UlJob (void) : m_deadline(Seconds (0)), m_size (0) +UlJob::UlJob (void) : m_deadline (Seconds (0)), m_size (0) { } diff --git a/src/wimax/model/ul-job.h b/src/wimax/model/ul-job.h index 87326f9d2..692c4fec4 100644 --- a/src/wimax/model/ul-job.h +++ b/src/wimax/model/ul-job.h @@ -38,11 +38,12 @@ enum ReqType DATA, UNICAST_POLLING }; +/** + * \ingroup wimax + * \brief this class implements a structure to compute the priority of service flows + */ class UlJob : public Object { - /** - * \brief this class implements a structure to compute the priority of service flows - */ public: enum JobPriority { diff --git a/src/wimax/model/ul-mac-messages.h b/src/wimax/model/ul-mac-messages.h index 8bc89eaba..a62f70231 100644 --- a/src/wimax/model/ul-mac-messages.h +++ b/src/wimax/model/ul-mac-messages.h @@ -30,14 +30,15 @@ namespace ns3 { +/** + * \ingroup wimax + * \brief This class implements the UCD channel encodings as described by "IEEE Standard for + * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access Systems" + * 11.3.1 UCD channel encodings, page 651 + * + */ class UcdChannelEncodings { - /** - * \brief This class implements the UCD channel encodings as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access Systems" - * 11.3.1 UCD channel encodings, page 651 - * - */ public: UcdChannelEncodings (void); virtual ~UcdChannelEncodings (void); diff --git a/src/wimax/model/wimax-channel.h b/src/wimax/model/wimax-channel.h index 6b5bfe8e3..14e3bcd9f 100644 --- a/src/wimax/model/wimax-channel.h +++ b/src/wimax/model/wimax-channel.h @@ -33,6 +33,9 @@ class Packet; class Position; class PacketBurst; +/** + * \ingroup wimax + */ class WimaxChannel : public Channel { public: diff --git a/src/wimax/model/wimax-connection.h b/src/wimax/model/wimax-connection.h index 02295ea6a..6bb9bae7b 100644 --- a/src/wimax/model/wimax-connection.h +++ b/src/wimax/model/wimax-connection.h @@ -35,6 +35,9 @@ namespace ns3 { class ServiceFlow; class Cid; +/** + * \ingroup wimax + */ class WimaxConnection : public Object { public: diff --git a/src/wimax/model/wimax-mac-header.h b/src/wimax/model/wimax-mac-header.h index ecd2c2d83..e2202f09d 100644 --- a/src/wimax/model/wimax-mac-header.h +++ b/src/wimax/model/wimax-mac-header.h @@ -27,8 +27,10 @@ namespace ns3 { -/*Represents the HT (Header Type) field of generic MAC and bandwidth request headers*/ - +/** + * \ingroup wimax + * \brief Represents the HT (Header Type) field of generic MAC and bandwidth request headers +*/ class MacHeaderType : public Header { /** diff --git a/src/wimax/model/wimax-mac-queue.cc b/src/wimax/model/wimax-mac-queue.cc index 4dc14f326..b537505e4 100644 --- a/src/wimax/model/wimax-mac-queue.cc +++ b/src/wimax/model/wimax-mac-queue.cc @@ -275,7 +275,7 @@ WimaxMacQueue::Dequeue (MacHeaderType::HeaderType packetType, uint32_t available "\n\t\t maxFragmentSize=" << maxFragmentSize << "" "\n\t\t fragmentOffset=" << fragmentOffset << "\n\t\t payloadSize=" << packet->GetSize () - << std::endl); + << std::endl); Ptr fragment = packet->CreateFragment (fragmentOffset, maxFragmentSize); m_bytes -= maxFragmentSize; diff --git a/src/wimax/model/wimax-mac-queue.h b/src/wimax/model/wimax-mac-queue.h index af5b12a3d..52d5d7878 100644 --- a/src/wimax/model/wimax-mac-queue.h +++ b/src/wimax/model/wimax-mac-queue.h @@ -31,6 +31,9 @@ namespace ns3 { +/** + * \ingroup wimax + */ class WimaxMacQueue : public Object { public: diff --git a/src/wimax/model/wimax-mac-to-mac-header.h b/src/wimax/model/wimax-mac-to-mac-header.h index bdb9094b6..4d2ef76ad 100644 --- a/src/wimax/model/wimax-mac-to-mac-header.h +++ b/src/wimax/model/wimax-mac-to-mac-header.h @@ -23,8 +23,11 @@ #include #include "ns3/header.h" + namespace ns3 { + /** + * \ingroup wimax * \brief this class implements the mac to mac header needed to dump a wimax pcap file * The header format was reverse-engineered by looking at existing live pcap traces which * could be opened with wireshark i.e., we have no idea where this is coming from. diff --git a/src/wimax/model/wimax-net-device.cc b/src/wimax/model/wimax-net-device.cc index 082069b1e..d140e9610 100644 --- a/src/wimax/model/wimax-net-device.cc +++ b/src/wimax/model/wimax-net-device.cc @@ -52,7 +52,7 @@ Time WimaxNetDevice::m_frameStartTime = Seconds (0); TypeId WimaxNetDevice::GetTypeId (void) { static TypeId - tid = + tid = TypeId ("ns3::WimaxNetDevice") .SetParent () diff --git a/src/wimax/model/wimax-net-device.h b/src/wimax/model/wimax-net-device.h index bdde5102d..72ffc5f15 100644 --- a/src/wimax/model/wimax-net-device.h +++ b/src/wimax/model/wimax-net-device.h @@ -52,6 +52,20 @@ class ServiceFlowManager; class BandwidthManager; class UplinkScheduler; +/** + * \defgroup wimax WiMAX Models + * + * This section documents the API of the ns-3 wimax module. For a generic functional description, please refer to the ns-3 manual. + */ + +/** + * \brief Hold together all Wimax-related objects in a NetDevice. + * \ingroup wimax + * + * This class holds together ns3::WimaxPhy, ns3::WimaxConnection, + * ns3::ConectionManager, ns3::BurstProfileManager, and + * ns3::BandwidthManager. + */ class WimaxNetDevice : public NetDevice { public: diff --git a/src/wimax/model/wimax-phy.h b/src/wimax/model/wimax-phy.h index ffbec9fd4..f1faba325 100644 --- a/src/wimax/model/wimax-phy.h +++ b/src/wimax/model/wimax-phy.h @@ -39,6 +39,9 @@ class WimaxNetDevice; class NetDevice; class Packet; +/** + * \ingroup wimax + */ class WimaxPhy : public Object { public: diff --git a/src/wimax/model/wimax-tlv.h b/src/wimax/model/wimax-tlv.h index 222b2f252..493805e70 100644 --- a/src/wimax/model/wimax-tlv.h +++ b/src/wimax/model/wimax-tlv.h @@ -35,12 +35,13 @@ namespace ns3 { +/** + * \ingroup wimax + * \brief The value field of a tlv can take different values (uint8_t, uint16, vector...). This class is a virtual interface + * that all the types of tlv values should derive + */ class TlvValue { - /** - * \brief The value field of a tlv can take different values (uint8_t, uint16, vector...). This class is a virtual interface - * that all the types of tlv values should derive - */ public: virtual ~TlvValue () { @@ -54,15 +55,16 @@ private: // ============================================================================= +/** + * \ingroup wimax + * \brief This class implements the Type-Len-Value structure channel encodings as described by "IEEE Standard for + * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access Systems" + * 11. TLV encodings, page 645 + * + */ class Tlv : public Header { public: - /** - * \brief This class implements the Type-Len-Value structure channel encodings as described by "IEEE Standard for - * Local and metropolitan area networks Part 16: Air Interface for Fixed Broadband Wireless Access Systems" - * 11. TLV encodings, page 645 - * - */ enum CommonTypes { HMAC_TUPLE = 149, @@ -97,6 +99,9 @@ private: }; // ============================================================================== +/** + * \ingroup wimax + */ class U8TlvValue : public TlvValue { public: @@ -114,6 +119,9 @@ private: }; // ============================================================================== +/** + * \ingroup wimax + */ class U16TlvValue : public TlvValue { public: @@ -131,6 +139,9 @@ private: }; // ============================================================================== +/** + * \ingroup wimax + */ class U32TlvValue : public TlvValue { public: @@ -150,11 +161,12 @@ private: // ============================================================================== +/** + * \ingroup wimax + * \brief this class is used to implement a vector of values in one tlv value field + */ class VectorTlvValue : public TlvValue { - /** - * \brief this class is used to implement a vector of values in one tlv value field - */ public: typedef std::vector::const_iterator Iterator; VectorTlvValue (void); @@ -171,7 +183,9 @@ private: }; // ============================================================================== - +/** + * \ingroup wimax + */ class SfVectorTlvValue : public VectorTlvValue { @@ -215,11 +229,12 @@ public: }; // ============================================================================== +/** + * \ingroup wimax + * \brief this class implements the convergence sub-layer descriptor as a tlv vector + */ class CsParamVectorTlvValue : public VectorTlvValue { - /* - * \brief this class implements the convergence sub-layer descriptor as a tlv vector - */ public: enum Type { @@ -234,11 +249,12 @@ private: // ============================================================================== +/** + * \ingroup wimax + * \brief this class implements the classifier descriptor as a tlv vector + */ class ClassificationRuleVectorTlvValue : public VectorTlvValue { - /* - * \brief this class implements the classifier descriptor as a tlv vector - */ public: enum ClassificationRuleTlvType { @@ -258,6 +274,9 @@ private: }; // ============================================================================== +/** + * \ingroup wimax + */ class TosTlvValue : public TlvValue { public: @@ -278,6 +297,9 @@ private: }; // ============================================================================== +/** + * \ingroup wimax + */ class PortRangeTlvValue : public TlvValue { public: @@ -301,6 +323,9 @@ private: }; // ============================================================================== +/** + * \ingroup wimax + */ class ProtocolTlvValue : public TlvValue { public: @@ -320,6 +345,9 @@ private: // ============================================================================== +/** + * \ingroup wimax + */ class Ipv4AddressTlvValue : public TlvValue { public: diff --git a/src/wimax/test/phy-test.cc b/src/wimax/test/phy-test.cc index 4dcd4f74e..59c54a03b 100644 --- a/src/wimax/test/phy-test.cc +++ b/src/wimax/test/phy-test.cc @@ -39,7 +39,7 @@ using namespace ns3; -NS_LOG_COMPONENT_DEFINE("WimaxPhyTest"); +NS_LOG_COMPONENT_DEFINE ("WimaxPhyTest"); /* * Configure a network with 3 SS and 1 BS @@ -108,7 +108,7 @@ Ns3WimaxSimpleOFDMTestCase::DoRun (void) { double - frameDuratioTab[7] = { 0.0025, 0.004, 0.005, 0.008, 0.01, 0.0125, 0.02 }; + frameDuratioTab[7] = { 0.0025, 0.004, 0.005, 0.008, 0.01, 0.0125, 0.02 }; for (int i = 0; i < 7; i++) { NS_LOG_DEBUG ("Frame Duration = " << frameDuratioTab[i]); diff --git a/src/wscript b/src/wscript index 08a2821d6..d968b5d70 100644 --- a/src/wscript +++ b/src/wscript @@ -1,6 +1,7 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- import os, os.path +import sys import shutil import types import warnings @@ -20,7 +21,7 @@ try: except NameError: from sets import Set as set # Python 2.3 fallback -all_modules = ( +all_modules = [ 'core', 'network', 'config-store', @@ -60,7 +61,7 @@ all_modules = ( 'point-to-point-layout', 'csma-layout', 'template', - ) + ] def set_options(opt): opt.sub_options('core') @@ -89,6 +90,7 @@ def configure(conf): conf.sub_config('click') conf.sub_config('openflow') conf.sub_config('stats') + conf.sub_config('visualizer') blddir = os.path.abspath(os.path.join(conf.blddir, conf.env.variant())) conf.env.append_value('NS3_MODULE_PATH', blddir) @@ -282,6 +284,19 @@ def build(bld): bld.create_obj = types.MethodType(create_obj, bld) bld.ns3_python_bindings = types.MethodType(ns3_python_bindings, bld) + # Remove these modules from the list of all modules. + for not_built in bld.env['MODULES_NOT_BUILT']: + + # XXX Becaue these modules are located in subdirectories of + # test, their names in the all_modules list include the extra + # relative path "test/". If these modules are moved into the + # src directory, then this if block should be removed. + if not_built == 'ns3tcp' or not_built == 'ns3wifi': + not_built = 'test/' + not_built + + if not_built in all_modules: + all_modules.remove(not_built) + bld.add_subdirs(list(all_modules)) for module in all_modules: diff --git a/test.py b/test.py index 25426b9db..bc8680e97 100755 --- a/test.py +++ b/test.py @@ -49,6 +49,7 @@ interesting_config_items = [ "ENABLE_REAL_TIME", "ENABLE_THREADING", "ENABLE_EXAMPLES", + "ENABLE_TESTS", "EXAMPLE_DIRECTORIES", "ENABLE_PYTHON_BINDINGS", "ENABLE_CLICK", @@ -59,6 +60,7 @@ NSC_ENABLED = False ENABLE_REAL_TIME = False ENABLE_THREADING = False ENABLE_EXAMPLES = True +ENABLE_TESTS = True ENABLE_CLICK = False ENABLE_OPENFLOW = False EXAMPLE_DIRECTORIES = [] @@ -77,6 +79,7 @@ core_valgrind_skip_tests = [ "ns3-tcp-cwnd", "nsc-tcp-loss", "ns3-tcp-interoperability", + "routing-click", ] # @@ -1626,6 +1629,19 @@ def run_tests(): shutil.copyfile(xml_results_file, options.xml) # + # Let the user know if they need to turn on tests or examples. + # + if not ENABLE_TESTS or not ENABLE_EXAMPLES: + print + if not ENABLE_TESTS: + print '*** Note: ns-3 tests are currently disabled. Enable them by adding' + print '*** "--enable-tests" to ./waf configure or modifying your .ns3rc file.' + print + if not ENABLE_EXAMPLES: + print '*** Note: ns-3 examples are currently disabled. Enable them by adding' + print '*** "--enable-examples" to ./waf configure or modifying your .ns3rc file.' + print + # # If we have been asked to retain all of the little temporary files, we # don't delete tm. If we do delete the temporary files, delete only the # directory we just created. We don't want to happily delete any retained diff --git a/utils/check-style.py b/utils/check-style.py index c42884bf0..7fdcde758 100755 --- a/utils/check-style.py +++ b/utils/check-style.py @@ -77,9 +77,6 @@ mod_remove_extra_semicolon=True """ level1 = """ # extra spaces here and there -sp_func_proto_paren=Add -sp_func_def_paren=Add -sp_func_call_paren=Add sp_brace_typedef=Add sp_enum_assign=Add sp_before_sparen=Add @@ -93,6 +90,9 @@ sp_type_func=Add sp_angle_paren=Add """ level0 = """ +sp_func_proto_paren=Add +sp_func_def_paren=Add +sp_func_call_paren=Add sp_after_semi_for=Ignore sp_before_sparen=Ignore sp_type_func=Ignore diff --git a/wscript b/wscript index 46c1593c6..023838f62 100644 --- a/wscript +++ b/wscript @@ -102,6 +102,23 @@ def dist_hook(): shutil.rmtree("doc/latex", True) shutil.rmtree("nsc", True) +# Print the sorted list of module names in columns. +def print_module_names(names): + # Sort the list of module names. + names.sort() + + # Print the list of module names in 3 columns. + i = 1 + for name in names: + print name.ljust(25), + if i == 3: + print + i = 0 + i = i+1 + + if i != 1: + print + def set_options(opt): # options provided by the modules opt.tool_options('compiler_cc') @@ -293,6 +310,38 @@ def configure(conf): if conf.check_compilation_flag('-Wl,--soname=foo'): env['WL_SONAME_SUPPORTED'] = True + env['ENABLE_STATIC_NS3'] = False + if Options.options.enable_static: + if env['PLATFORM'].startswith('linux') and \ + env['CXX_NAME'] in ['gcc', 'icc']: + if re.match('i[3-6]86', os.uname()[4]): + conf.report_optional_feature("static", "Static build", True, '') + env['ENABLE_STATIC_NS3'] = True + elif os.uname()[4] == 'x86_64': + if env['ENABLE_PYTHON_BINDINGS'] and \ + not conf.check_compilation_flag('-mcmodel=large'): + conf.report_optional_feature("static", "Static build", False, + "Can't enable static builds because " + \ + "no -mcmodel=large compiler " \ + "option. Try --disable-python or upgrade your " \ + "compiler to at least gcc 4.3.x.") + else: + conf.report_optional_feature("static", "Static build", True, '') + env['ENABLE_STATIC_NS3'] = True + elif env['CXX_NAME'] == 'gcc' and \ + (env['PLATFORM'].startswith('darwin') or \ + env['PLATFORM'].startswith('cygwin')): + conf.report_optional_feature("static", "Static build", True, '') + env['ENABLE_STATIC_NS3'] = True + else: + conf.report_optional_feature("static", "Static build", False, + "Unsupported platform") + else: + conf.report_optional_feature("static", "Static build", False, + "option --enable-static not selected") + + conf.env['MODULES_NOT_BUILT'] = [] + conf.sub_config('src') # Set the list of enabled modules. @@ -309,6 +358,22 @@ def configure(conf): # Enable the modules from the list. conf.env['NS3_ENABLED_MODULES'] = ['ns3-'+mod for mod in modules_enabled] + + # Add the template module to the list of enabled modules that + # should not be built if this is a static build on Darwin. They + # don't work there for the template module, and this is probably + # because the template module has no source files. + if conf.env['ENABLE_STATIC_NS3'] and sys.platform == 'darwin': + conf.env['MODULES_NOT_BUILT'].append('template') + + # Remove these modules from the list of enabled modules. + for not_built in conf.env['MODULES_NOT_BUILT']: + not_built_name = 'ns3-' + not_built + if not_built_name in conf.env['NS3_ENABLED_MODULES']: + conf.env['NS3_ENABLED_MODULES'].remove(not_built_name) + if not conf.env['NS3_ENABLED_MODULES']: + raise Utils.WafError('Exiting because the ' + not_built + ' module can not be built and it was the only one enabled.') + conf.sub_config('bindings/python') conf.sub_config('src/mpi') @@ -380,36 +445,6 @@ def configure(conf): conf.find_program('valgrind', var='VALGRIND') - env['ENABLE_STATIC_NS3'] = False - if Options.options.enable_static: - if env['PLATFORM'].startswith('linux') and \ - env['CXX_NAME'] in ['gcc', 'icc']: - if re.match('i[3-6]86', os.uname()[4]): - conf.report_optional_feature("static", "Static build", True, '') - env['ENABLE_STATIC_NS3'] = True - elif os.uname()[4] == 'x86_64': - if env['ENABLE_PYTHON_BINDINGS'] and \ - not conf.check_compilation_flag('-mcmodel=large'): - conf.report_optional_feature("static", "Static build", False, - "Can't enable static builds because " + \ - "no -mcmodel=large compiler " \ - "option. Try --disable-python or upgrade your " \ - "compiler to at least gcc 4.3.x.") - else: - conf.report_optional_feature("static", "Static build", True, '') - env['ENABLE_STATIC_NS3'] = True - elif env['CXX_NAME'] == 'gcc' and \ - (env['PLATFORM'].startswith('darwin') or \ - env['PLATFORM'].startswith('cygwin')): - conf.report_optional_feature("static", "Static build", True, '') - env['ENABLE_STATIC_NS3'] = True - else: - conf.report_optional_feature("static", "Static build", False, - "Unsupported platform") - else: - conf.report_optional_feature("static", "Static build", False, - "option --enable-static not selected") - # These flags are used for the implicitly dependent modules. if env['ENABLE_STATIC_NS3']: if sys.platform == 'darwin': @@ -733,26 +768,22 @@ def shutdown(ctx): return env = bld.env - # Don't print the list if this a clean or distribution clean. + # Don't print the lists if this a clean or distribution clean. if ('clean' not in Options.arg_line) and ('distclean' not in Options.arg_line): - # Get the sorted list of built modules without the "ns3-" in their name. - modules_without_prefix =[mod[len('ns3-'):] for mod in env['NS3_ENABLED_MODULES']] - modules_without_prefix.sort() - - # Print the list of built modules in 3 columns. + # Print the list of built modules. print print 'Modules built:' - i = 1 - for mod in modules_without_prefix: - print mod.ljust(25), - if i == 3: - print - i = 0 - i = i+1 - print + names_without_prefix =[name[len('ns3-'):] for name in env['NS3_ENABLED_MODULES']] + print_module_names(names_without_prefix) print + # Print the list of enabled modules that were not built. + if env['MODULES_NOT_BUILT']: + print 'Modules not built:' + print_module_names(env['MODULES_NOT_BUILT']) + print + # Write the build status file. build_status_file = os.path.join (env['NS3_BUILDDIR'], env['NS3_ACTIVE_VARIANT'], 'build-status.py') out = open(build_status_file, 'w')