This commit is contained in:
Nicola Baldo
2011-06-29 15:59:13 +02:00
574 changed files with 7232 additions and 6335 deletions

View File

@@ -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

View File

@@ -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
------------

View File

@@ -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

View File

@@ -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.

View File

@@ -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 ::

View File

@@ -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

View File

@@ -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: ::

View File

@@ -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 <name>, the file ``bindings/python/ns3_module_<name>.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 <name>, another function register_methods_Ns3<name>(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_<name>.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/<module>/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>-module.h. Typically, the first statement is #include "ns3/<module>-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;
* ``<module>.py``: if this file exists, it becomes the "frontend" python module for the ns3 module, and the extension module (.so file) becomes _<module>.so instead of <module>.so. The <module>.py file has to import all symbols from the module _<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
`<http://www.nsnam.org/wiki/index.php/NS-3_Python_Bindings>`_.

View File

@@ -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 \

View File

@@ -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.

View File

@@ -1,14 +0,0 @@
Devices and Channels
--------------------
.. toctree::
bridge
csma
lte
point-to-point
mesh
wifi
wimax
simple
uan

View File

@@ -19,13 +19,27 @@ This document is written in `reStructuredText <http://docutils.sourceforge.net/r
:maxdepth: 2
organization
network
devices
propagation
energy
internet-models
routing
distributed
emulation-overview
animation
aodv
applications
support
bridge
click
csma
dsdv
emulation-overview
energy
flow-monitor
internet-models
lte
mesh
distributed
network
olsr
openflow-switch
point-to-point
propagation
simple
statistics
uan
wifi
wimax

View File

@@ -15,7 +15,7 @@ It is important to distinguish between **modules** and **models**:
protocols, devices, etc.
An |ns3| module may consist of more than one model (for instance, the
:mod:`internet` model contains models for both TCP and UDP). In general,
:mod:`internet` module contains models for both TCP and UDP). In general,
ns-3 models do not span multiple software modules, however.
This manual provides documentation about the models of |ns3|. It
@@ -31,22 +31,17 @@ complements two other sources of documentation concerning models:
`main web site <http://www.nsnam.org>`_ to find copies of the manual.
Finally, additional documentation about various aspects of |ns3| may
exist on the `project wiki <http://www.nsnam.org/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 <http://www.nsnam.org/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.

View File

@@ -1,7 +0,0 @@
Routing and Switching
---------------------
.. toctree::
click
openflow-switch

View File

@@ -1,8 +0,0 @@
Support
-------
.. toctree::
flow-monitor
animation
statistics

View File

@@ -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
*/

View File

@@ -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 = <ns-developers@isi.edu>
- 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 = <ns-developers@isi.edu>
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

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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.

View File

@@ -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.<release>.<hotfix>``. 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.

View File

@@ -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 <http://www.nsnam.org/doxygen/index.html>`_: Documentation of the public APIs of the simulator
* `Tutorial <http://www.nsnam.org/tutorials.html>`_: *(this document)*
* `Reference Manual <http://www.nsnam.org/tutorials.html>`_:
* `Manual <http://www.nsnam.org/tutorials.html>`_:
* `Model Library <http://www.nsnam.org/tutorials.html>`_:
* `ns-3 wiki <http://www.nsnam.org/wiki/index.php/Main_Page>`_
This document is written in `reStructuredText <http://docutils.sourceforge.net/rst.html>`_ for `Sphinx <http://sphinx.pocoo.org/>`_ and is maintained in the

View File

@@ -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
<http://www.nsnam.org/wiki/index.php>`_;
<http://www.nsnam.org/wiki/index.php>`_
* `Contributed Code
<http://www.nsnam.org/wiki/index.php/Contributed_Code>`_ page, similar to ns-2's popular Contributed Code
`page
<http://nsnam.isi.edu/nsnam/index.php/Contributed_Code>`_;
<http://nsnam.isi.edu/nsnam/index.php/Contributed_Code>`_
* Open `bug tracker
<http://www.nsnam.org/bugzilla>`_;
* |ns3| developers will gladly help potential contributors to get
started with the simulator (please contact `one of us
<http://www.nsnam.org/people.html>`_).
<http://www.nsnam.org/bugzilla>`_
We realize that if you are reading this document, contributing back to
the project is probably not your foremost concern at this point, but

View File

@@ -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

View File

@@ -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",

View File

@@ -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;

View File

@@ -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<Node> r1 = CreateObject<Node> ();
Ptr<Node> r2 = CreateObject<Node> ();
Ptr<Node> sta2 = CreateObject<Node> ();
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));

View File

@@ -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);

View File

@@ -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"

View File

@@ -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);

View File

@@ -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);

View File

@@ -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));

View File

@@ -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<Ipv4StaticRouting> staticRoutingB = ipv4RoutingHelper.GetStaticRouting(ipv4B);
Ptr<Ipv4StaticRouting> 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)));

View File

@@ -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)));

View File

@@ -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 <rohrej@ittc.ku.edu>
*
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, 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:
* <timestamp> <node-id> received one packet from <src-address>
* - 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 <fstream>
#include <iostream>
#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<Socket> SetupPacketReceive (Ipv4Address addr, Ptr<Node> node);
void ReceivePacket (Ptr<Socket> 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> socket)
{
Ptr<Packet> 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<Socket>
RoutingExperiment::SetupPacketReceive (Ipv4Address addr, Ptr<Node> node)
{
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
Ptr<Socket> 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<PositionAllocator> taPositionAlloc = pos.Create ()->GetObject<PositionAllocator> ();
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<Socket> 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<FlowMonitor> 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 ();
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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;

View File

@@ -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'])

View File

@@ -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<Socket> sock, Ipv4Address dstaddr, uint16_t port)
void SendStuff (Ptr<Socket> sock, Ipv4Address dstaddr, uint16_t port)
{
Ptr<Packet> p = Create<Packet> ();
p->AddPaddingAtEnd (100);
@@ -180,7 +180,7 @@ void SendStuff(Ptr<Socket> sock, Ipv4Address dstaddr, uint16_t port)
return;
}
void BindSock(Ptr<Socket> sock, Ptr<NetDevice> netdev)
void BindSock (Ptr<Socket> sock, Ptr<NetDevice> netdev)
{
sock->BindToNetDevice (netdev);
return;
@@ -193,7 +193,7 @@ srcSocketRecv (Ptr<Socket> socket)
Ptr<Packet> 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> 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 ());
}

View File

@@ -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<Socket> sock, Ptr<NetDevice> netdev)
void BindSock (Ptr<Socket> sock, Ptr<NetDevice> netdev)
{
sock->BindToNetDevice(netdev);
sock->BindToNetDevice (netdev);
return;
}
void StartFlow(Ptr<Socket> localSocket,
Ipv4Address servAddress,
uint16_t servPort)
void StartFlow (Ptr<Socket> localSocket,
Ipv4Address servAddress,
uint16_t servPort)
{
NS_LOG_INFO ("Starting flow at time " << Simulator::Now ().GetSeconds ());
currentTxBytes = 0;

View File

@@ -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<Application> ()
.AddConstructor<Sender> ()
.AddAttribute ("PacketSize", "The size of packets transmitted.",
UintegerValue(64),
MakeUintegerAccessor(&Sender::m_pktSize),
UintegerValue (64),
MakeUintegerAccessor (&Sender::m_pktSize),
MakeUintegerChecker<uint32_t>(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<uint32_t>())
.AddAttribute ("NumPackets", "Total number of packets to send.",
UintegerValue (30),
MakeUintegerAccessor (&Sender::m_numPkts),
MakeUintegerChecker<uint32_t>(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<uint32_t>())
.AddAttribute("NumPackets", "Total number of packets to send.",
UintegerValue(30),
MakeUintegerAccessor(&Sender::m_numPkts),
MakeUintegerChecker<uint32_t>(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> socketFactory = GetNode()->GetObject<SocketFactory>
(UdpSocketFactory::GetTypeId());
Ptr<SocketFactory> socketFactory = GetNode ()->GetObject<SocketFactory>
(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> packet = Create<Packet>(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<Application> ()
.AddConstructor<Receiver> ()
.AddAttribute("Port", "Listening port.",
UintegerValue(1603),
MakeUintegerAccessor(&Receiver::m_port),
MakeUintegerChecker<uint32_t>())
.AddAttribute ("Port", "Listening port.",
UintegerValue (1603),
MakeUintegerAccessor (&Receiver::m_port),
MakeUintegerChecker<uint32_t>())
;
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> socketFactory = GetNode()->GetObject<SocketFactory>
(UdpSocketFactory::GetTypeId());
m_socket = socketFactory->CreateSocket();
Ptr<SocketFactory> socketFactory = GetNode ()->GetObject<SocketFactory>
(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<void, Ptr<Socket> > ());
m_socket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ());
}
// end Receiver::StopApplication
}
void
Receiver::SetCounter(Ptr<CounterCalculator<> > calc)
Receiver::SetCounter (Ptr<CounterCalculator<> > calc)
{
m_calc = calc;
// end Receiver::SetCounter
}
void
Receiver::SetDelayTracker(Ptr<TimeMinMaxAvgTotalCalculator> delay)
Receiver::SetDelayTracker (Ptr<TimeMinMaxAvgTotalCalculator> delay)
{
m_delay = delay;
// end Receiver::SetDelayTracker
}
void
Receiver::Receive(Ptr<Socket> socket)
Receiver::Receive (Ptr<Socket> socket)
{
// NS_LOG_FUNCTION (this << socket << packet << from);
Ptr<Packet> 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> socket)
//-- TimestampTag
//------------------------------------------------------
TypeId
TimestampTag::GetTypeId(void)
TimestampTag::GetTypeId (void)
{
static TypeId tid = TypeId ("TimestampTag")
.SetParent<Tag> ()
.AddConstructor<TimestampTag> ()
.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;
}

View File

@@ -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<CounterCalculator<> > calc);
void SetDelayTracker(Ptr<TimeMinMaxAvgTotalCalculator> delay);
void SetCounter (Ptr<CounterCalculator<> > calc);
void SetDelayTracker (Ptr<TimeMinMaxAvgTotalCalculator> 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> socket);
void Receive (Ptr<Socket> socket);
Ptr<Socket> 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;

View File

@@ -54,11 +54,11 @@ NS_LOG_COMPONENT_DEFINE ("WiFiDistanceExperiment");
void TxCallback(Ptr<CounterCalculator<uint32_t> > datac,
std::string path, Ptr<const Packet> packet) {
NS_LOG_INFO("Sent frame counted in " <<
datac->GetKey());
datac->Update();
void TxCallback (Ptr<CounterCalculator<uint32_t> > datac,
std::string path, Ptr<const Packet> packet) {
NS_LOG_INFO ("Sent frame counted in " <<
datac->GetKey ());
datac->Update ();
// end TxCallback
}
@@ -68,52 +68,52 @@ void TxCallback(Ptr<CounterCalculator<uint32_t> > 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<ListPositionAllocator> positionAlloc =
CreateObject<ListPositionAllocator>();
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<Node> appSource = NodeList::GetNode(0);
Ptr<Node> appSource = NodeList::GetNode (0);
Ptr<Sender> sender = CreateObject<Sender>();
appSource->AddApplication(sender);
sender->SetStartTime(Seconds(1));
appSource->AddApplication (sender);
sender->SetStartTime (Seconds (1));
Ptr<Node> appSink = NodeList::GetNode(1);
Ptr<Node> appSink = NodeList::GetNode (1);
Ptr<Receiver> receiver = CreateObject<Receiver>();
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<CounterCalculator<uint32_t> > totalTx =
CreateObject<CounterCalculator<uint32_t> >();
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<PacketCounterCalculator> totalRx =
CreateObject<PacketCounterCalculator>();
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<PacketCounterCalculator> appTx =
CreateObject<PacketCounterCalculator>();
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<CounterCalculator<> > appRx =
CreateObject<CounterCalculator<> >();
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<PacketSizeMinMaxAvgTotalCalculator> appTxPkts =
CreateObject<PacketSizeMinMaxAvgTotalCalculator>();
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<TimeMinMaxAvgTotalCalculator> delayStat =
CreateObject<TimeMinMaxAvgTotalCalculator>();
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<DataOutputInterface> output = 0;
if (format == "omnet") {
NS_LOG_INFO("Creating omnet formatted data output.");
NS_LOG_INFO ("Creating omnet formatted data output.");
output = CreateObject<OmnetDataOutput>();
} 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<SqliteDataOutput>();
#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
}

View File

@@ -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.");

View File

@@ -61,7 +61,7 @@ uint8_t data[writeSize];
// implement a sending "Application", although not a proper ns3::Application
// subclass.
void StartFlow(Ptr<Socket>, Ipv4Address, uint16_t);
void StartFlow (Ptr<Socket>, Ipv4Address, uint16_t);
void WriteUntilBufferFull (Ptr<Socket>, 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<Socket> localSocket,
Ipv4Address servAddress,
uint16_t servPort)
void StartFlow (Ptr<Socket> 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

View File

@@ -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<RateErrorModel> em1 =
CreateObjectWithAttributes<RateErrorModel> ("RanVar", u01, "ErrorRate", rate);
Ptr<RateErrorModel> em2 =
CreateObjectWithAttributes<RateErrorModel> ("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 ();

View File

@@ -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<linux2.6.26>/net.ipv4.tcp_sack", StringValue ("0"));
Config::Set ("/NodeList/1/$ns3::Ns3NscStack<linux2.6.26>/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<linux2.6.26>/net.ipv4.tcp_sack", StringValue ("0"));
Config::Set ("/NodeList/3/$ns3::Ns3NscStack<linux2.6.26>/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 ();

View File

@@ -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<NodeContainer> nodeAdjacencyList(N-1);
for(uint32_t i=0; i<nodeAdjacencyList.size(); ++i)
std::vector<NodeContainer> nodeAdjacencyList (N-1);
for(uint32_t i=0; i<nodeAdjacencyList.size (); ++i)
{
nodeAdjacencyList[i] = NodeContainer (serverNode, clientNodes.Get (i));
}
@@ -105,8 +105,8 @@ main (int argc, char *argv[])
PointToPointHelper p2p;
p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
std::vector<NetDeviceContainer> deviceAdjacencyList(N-1);
for(uint32_t i=0; i<deviceAdjacencyList.size(); ++i)
std::vector<NetDeviceContainer> deviceAdjacencyList (N-1);
for(uint32_t i=0; i<deviceAdjacencyList.size (); ++i)
{
deviceAdjacencyList[i] = p2p.Install (nodeAdjacencyList[i]);
}
@@ -114,12 +114,12 @@ main (int argc, char *argv[])
// Later, we add IP addresses.
NS_LOG_INFO ("Assign IP Addresses.");
Ipv4AddressHelper ipv4;
std::vector<Ipv4InterfaceContainer> interfaceAdjacencyList(N-1);
for(uint32_t i=0; i<interfaceAdjacencyList.size(); ++i)
std::vector<Ipv4InterfaceContainer> interfaceAdjacencyList (N-1);
for(uint32_t i=0; i<interfaceAdjacencyList.size (); ++i)
{
std::ostringstream subnet;
subnet<<"10.1."<<i+1<<".0";
ipv4.SetBase (subnet.str().c_str(), "255.255.255.0");
ipv4.SetBase (subnet.str ().c_str (), "255.255.255.0");
interfaceAdjacencyList[i] = ipv4.Assign (deviceAdjacencyList[i]);
}
@@ -128,7 +128,7 @@ main (int argc, char *argv[])
// Create a packet sink on the star "hub" to receive these packets
uint16_t port = 50000;
Address sinkLocalAddress(InetSocketAddress (Ipv4Address::GetAny (), port));
Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress);
ApplicationContainer sinkApp = sinkHelper.Install (serverNode);
sinkApp.Start (Seconds (1.0));
@@ -137,18 +137,18 @@ main (int argc, char *argv[])
// Create the OnOff applications to send TCP to the server
OnOffHelper clientHelper ("ns3::TcpSocketFactory", Address ());
clientHelper.SetAttribute
("OnTime", RandomVariableValue (ConstantVariable (1)));
("OnTime", RandomVariableValue (ConstantVariable (1)));
clientHelper.SetAttribute
("OffTime", RandomVariableValue (ConstantVariable (0)));
("OffTime", RandomVariableValue (ConstantVariable (0)));
//normally wouldn't need a loop here but the server IP address is different
//on each p2p subnet
ApplicationContainer clientApps;
for(uint32_t i=0; i<clientNodes.GetN(); ++i)
for(uint32_t i=0; i<clientNodes.GetN (); ++i)
{
AddressValue remoteAddress
(InetSocketAddress (interfaceAdjacencyList[i].GetAddress (0), port));
(InetSocketAddress (interfaceAdjacencyList[i].GetAddress (0), port));
clientHelper.SetAttribute ("Remote", remoteAddress);
clientApps.Add(clientHelper.Install (clientNodes.Get(i)));
clientApps.Add (clientHelper.Install (clientNodes.Get (i)));
}
clientApps.Start (Seconds (1.0));
clientApps.Stop (Seconds (10.0));

View File

@@ -198,7 +198,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.));
@@ -213,9 +213,9 @@ main (int argc, char *argv[])
app->SetStartTime (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 ();

View File

@@ -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);

View File

@@ -52,7 +52,7 @@ int
main (int argc, char *argv[])
{
Ptr<MyObject> myObject = CreateObject<MyObject> ();
myObject->TraceConnectWithoutContext ("MyInteger", MakeCallback(&IntTrace));
myObject->TraceConnectWithoutContext ("MyInteger", MakeCallback (&IntTrace));
myObject->m_myInt = 1234;
}

View File

@@ -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;

View File

@@ -171,7 +171,7 @@ static void
RxDrop (Ptr<PcapFileWrapper> file, Ptr<const Packet> 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<PcapFileWrapper> 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 ();

View File

@@ -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;

View File

@@ -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));

View File

@@ -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));

View File

@@ -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;

View File

@@ -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<Node> appSink = NodeList::GetNode (lastNodeIndex);
// Let's fetch the IP address of the last node, which is on Ipv4Interface 1
Ipv4Address remoteAddr = appSink->GetObject<Ipv4> ()->GetAddress(1, 0).GetLocal ();
Ipv4Address remoteAddr = appSink->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();
OnOffHelper onoff ("ns3::UdpSocketFactory",
Address (InetSocketAddress (remoteAddr, port)));

View File

@@ -91,7 +91,7 @@ private:
Vector GetPosition (Ptr<Node> node);
Ptr<Socket> SetupPacketReceive (Ptr<Node> node);
NodeContainer GenerateNeighbors(NodeContainer c, uint32_t senderId);
NodeContainer GenerateNeighbors (NodeContainer c, uint32_t senderId);
void ApplicationSetup (Ptr<Node> client, Ptr<Node> 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> socket)
Ptr<Packet> 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<Node> sender, NodeContainer c)
Experiment::SendMultiDestinations (Ptr<Node> 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<Node> client, Ptr<Node> server, double start,
Ptr<Ipv4> ipv4Server = server->GetObject<Ipv4>();
Ptr<Ipv4> ipv4Client = client->GetObject<Ipv4>();
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<Node> client, Ptr<Node> 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<FlowMonitor> 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);

View File

@@ -54,7 +54,7 @@ int main (int argc, char *argv[])
Ptr <YansErrorRateModel> yans = CreateObject<YansErrorRateModel> ();
Ptr <NistErrorRateModel> nist = CreateObject<NistErrorRateModel> ();
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);
}

View File

@@ -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);

View File

@@ -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 ();

View File

@@ -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]);

View File

@@ -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<ConstantPositionMobilityModel> ());
nodes.Get (i)->AggregateObject (CreateObject<ConstantPositionMobilityModel> ());
}
// 3. Create propagation loss matrix
@@ -140,7 +140,7 @@ void experiment (bool enableCtsRts)
// 8. Install FlowMonitor on all nodes
FlowMonitorHelper flowmon;
Ptr<FlowMonitor> monitor = flowmon.InstallAll();
Ptr<FlowMonitor> monitor = flowmon.InstallAll ();
// 9. Run simulation for 10 seconds
Simulator::Stop (Seconds (10));

View File

@@ -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);

View File

@@ -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);

View File

@@ -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

View File

@@ -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<Socket> 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));

View File

@@ -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 */

131
src/aodv/doc/aodv.rst Normal file
View File

@@ -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
++++++++++++++++++++++++++++++

View File

@@ -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> node = nodes.Get (size/2);

View File

@@ -30,18 +30,18 @@ namespace aodv
bool
DuplicatePacketDetection::IsDuplicate (Ptr<const Packet> 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 ();
}

View File

@@ -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<const Packet> p, const Ipv4Header & header);
/// Set duplicate records lifetimes

View File

@@ -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);
}

View File

@@ -87,7 +87,7 @@ public:
///\name Handle link failure callback
//\{
void SetCallback (Callback<void, Ipv4Address> cb) { m_handleLinkFailure = cb;}
void SetCallback (Callback<void, Ipv4Address> cb) { m_handleLinkFailure = cb; }
Callback<void, Ipv4Address> GetCallback () const { return m_handleLinkFailure; }
//\}
private:

View File

@@ -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;
}

View File

@@ -317,9 +317,9 @@ public:
*/
bool RemoveUnDestination (std::pair<Ipv4Address, uint32_t> & 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

View File

@@ -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<OutputStreamWrapper> stream) const
{
*stream->GetStream () << "Node: " << m_ipv4->GetObject<Node> ()->GetId () << " Time: " << Simulator::Now().GetSeconds () << "s ";
*stream->GetStream () << "Node: " << m_ipv4->GetObject<Node> ()->GetId () << " Time: " << Simulator::Now ().GetSeconds () << "s ";
m_routingTable.Print (stream);
}
@@ -316,7 +316,7 @@ RoutingProtocol::RouteOutput (Ptr<Packet> 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<const Packet> 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" <<header.GetDestination ());
NS_LOG_LOGIC ("Send new RREQ for outbound packet to " <<header.GetDestination ());
SendRequest (header.GetDestination ());
}
}
@@ -367,7 +367,7 @@ RoutingProtocol::RouteInput (Ptr<const Packet> p, const Ipv4Header &header,
Ptr<const NetDevice> 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<const Packet> p, const Ipv4Header & header,
if (toDst.GetFlag () == VALID)
{
Ptr<Ipv4Route> 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<NetDevice> 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<NetDevice> 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> 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<Packet> 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<Packet> 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<Packet> 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<uint32_t>(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<Packet> 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<Packet> 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> 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<Packet> 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<Packet> 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<Ipv4Route> 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> 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> packet, std::vector<Ipv4Address> p
{
Ptr<Socket> 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> packet, std::vector<Ipv4Address> p
{
Ptr<Socket> 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 ())

View File

@@ -226,7 +226,7 @@ private:
/// Initiate RERR
void SendRerrWhenBreaksLinkToNextHop (Ipv4Address nextHop);
/// Forward RERR
void SendRerrMessage(Ptr<Packet> packet, std::vector<Ipv4Address> precursors);
void SendRerrMessage (Ptr<Packet> packet, std::vector<Ipv4Address> 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

View File

@@ -69,10 +69,10 @@ public:
void SetErrorCallback (ErrorCallback ecb) { m_ecb = ecb; }
Ptr<const Packet> GetPacket () const { return m_packet; }
void SetPacket (Ptr<const Packet> 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

View File

@@ -158,7 +158,7 @@ RoutingTableEntry::Invalidate (Time badLinkLifetime)
void
RoutingTableEntry::Print (Ptr<OutputStreamWrapper> 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)

View File

@@ -60,9 +60,9 @@ class RoutingTableEntry
{
public:
/// c-to
RoutingTableEntry (Ptr<NetDevice> 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<NetDevice> 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<Ipv4Route> GetRoute () const { return m_ipv4Route; }
void SetRoute (Ptr<Ipv4Route> r) { m_ipv4Route = r; }
void SetNextHop (Ipv4Address nextHop) { m_ipv4Route->SetGateway(nextHop); }
Ipv4Address GetNextHop () const { return m_ipv4Route->GetGateway(); }
void SetOutputDevice (Ptr<NetDevice> dev) { m_ipv4Route->SetOutputDevice(dev); }
Ptr<NetDevice> 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<NetDevice> dev) { m_ipv4Route->SetOutputDevice (dev); }
Ptr<NetDevice> 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<OutputStreamWrapper> stream) const;
void Print (Ptr<OutputStreamWrapper> 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<OutputStreamWrapper> stream) const;
void Print (Ptr<OutputStreamWrapper> stream) const;
private:
std::map<Ipv4Address, RoutingTableEntry> m_ipv4AddressEntry;

View File

@@ -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 ();
}

View File

@@ -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");
}
}

View File

@@ -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

View File

@@ -214,13 +214,13 @@ struct RrepAckHeaderTest : public TestCase
RrepAckHeaderTest () : TestCase ("AODV RREP-ACK")
{
}
virtual void DoRun()
virtual void DoRun ()
{
RrepAckHeader h;
Ptr<Packet> p = Create<Packet> ();
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<Packet> p = Create<Packet> ();
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 Packet>, const Ipv4Header &, Socket::SocketErrno) {}
void Unicast2 (Ptr<Ipv4Route> route, Ptr<const Packet> packet, const Ipv4Header & header) {}
void Error2 (Ptr<const Packet>, const Ipv4Header &, Socket::SocketErrno) {}
virtual void DoRun()
virtual void DoRun ()
{
Ptr<const Packet> packet = Create<Packet> ();
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<const Packet> packet = Create<Packet> ();
@@ -338,7 +338,7 @@ AodvRqueueTest::DoRun ()
q.Enqueue (e2);
Ptr<Packet> packet2 = Create<Packet> ();
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<NetDevice> 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<NetDevice> 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");

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -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");
}
}

View File

@@ -61,7 +61,7 @@ LoopbackTestCase::DoRun ()
nodes.Create (1);
Ptr<MobilityModel> m = CreateObject<ConstantPositionMobilityModel> ();
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<V4Ping> ping = CreateObject<V4Ping> ();
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);

Some files were not shown because too many files have changed in this diff Show More