Merge
This commit is contained in:
3
AUTHORS
3
AUTHORS
@@ -26,4 +26,5 @@ Aleksey Kovalenko (kovalenko@iitp.ru)
|
||||
Liu Jian (liujatp@gmail.com)
|
||||
Andrey Hippo (ahippo@yandex.ru)
|
||||
Francesco Malandrino (francesco.malandrino@gmail.com)
|
||||
|
||||
Faker Moatamri (faker.moatamri@sophia.inria.fr)
|
||||
Guangyu Pei (guangyu.pei@boeing.com)
|
||||
|
||||
@@ -203,6 +203,11 @@ def register_Ns3Buffer_methods(root_module, cls):
|
||||
'int32_t',
|
||||
[],
|
||||
is_const=True)
|
||||
## buffer.h: void ns3::Buffer::CopyData(std::ostream * os, uint32_t size) const [member function]
|
||||
cls.add_method('CopyData',
|
||||
'void',
|
||||
[param('std::ostream *', 'os'), param('uint32_t', 'size')],
|
||||
is_const=True)
|
||||
## buffer.h: ns3::Buffer::Buffer(ns3::Buffer const & o) [copy constructor]
|
||||
cls.add_constructor([param('ns3::Buffer const &', 'o')])
|
||||
## buffer.h: ns3::Buffer::Buffer() [constructor]
|
||||
@@ -544,6 +549,11 @@ def register_Ns3Packet_methods(root_module, cls):
|
||||
'uint32_t',
|
||||
[param('uint8_t *', 'buffer'), param('uint32_t', 'size')],
|
||||
is_const=True)
|
||||
## packet.h: void ns3::Packet::CopyData(std::ostream * os, uint32_t size) const [member function]
|
||||
cls.add_method('CopyData',
|
||||
'void',
|
||||
[param('std::ostream *', 'os'), param('uint32_t', 'size')],
|
||||
is_const=True)
|
||||
## packet.h: ns3::Ptr<ns3::Packet> ns3::Packet::CreateFragment(uint32_t start, uint32_t length) const [member function]
|
||||
cls.add_method('CreateFragment',
|
||||
'ns3::Ptr< ns3::Packet >',
|
||||
|
||||
@@ -25,8 +25,6 @@ def register_types(module):
|
||||
module.add_class('UdpHeader', parent=root_module['ns3::Header'])
|
||||
## ipv4-static-routing-impl.h: ns3::Ipv4StaticRoutingImpl [class]
|
||||
module.add_class('Ipv4StaticRoutingImpl', parent=root_module['ns3::Ipv4StaticRouting'])
|
||||
## ipv4-global-routing.h: ns3::Ipv4GlobalRouting [class]
|
||||
module.add_class('Ipv4GlobalRouting', parent=root_module['ns3::Ipv4RoutingProtocol'])
|
||||
## ipv4-list-routing-impl.h: ns3::Ipv4ListRoutingImpl [class]
|
||||
module.add_class('Ipv4ListRoutingImpl', parent=root_module['ns3::Ipv4ListRouting'])
|
||||
|
||||
@@ -88,7 +86,6 @@ def register_methods(root_module):
|
||||
register_Ns3TcpHeader_methods(root_module, root_module['ns3::TcpHeader'])
|
||||
register_Ns3UdpHeader_methods(root_module, root_module['ns3::UdpHeader'])
|
||||
register_Ns3Ipv4StaticRoutingImpl_methods(root_module, root_module['ns3::Ipv4StaticRoutingImpl'])
|
||||
register_Ns3Ipv4GlobalRouting_methods(root_module, root_module['ns3::Ipv4GlobalRouting'])
|
||||
register_Ns3Ipv4ListRoutingImpl_methods(root_module, root_module['ns3::Ipv4ListRoutingImpl'])
|
||||
return
|
||||
|
||||
@@ -181,10 +178,10 @@ def register_Ns3Icmpv4Echo_methods(root_module, cls):
|
||||
'uint16_t',
|
||||
[],
|
||||
is_const=True)
|
||||
## icmpv4.h: ns3::Ptr<ns3::Packet const> ns3::Icmpv4Echo::GetData() const [member function]
|
||||
## icmpv4.h: uint32_t ns3::Icmpv4Echo::GetData(uint8_t * payload) const [member function]
|
||||
cls.add_method('GetData',
|
||||
'ns3::Ptr< ns3::Packet const >',
|
||||
[],
|
||||
'uint32_t',
|
||||
[param('uint8_t *', 'payload')],
|
||||
is_const=True)
|
||||
## icmpv4.h: static ns3::TypeId ns3::Icmpv4Echo::GetTypeId() [member function]
|
||||
cls.add_method('GetTypeId',
|
||||
@@ -636,70 +633,6 @@ def register_Ns3Ipv4StaticRoutingImpl_methods(root_module, cls):
|
||||
visibility='protected', is_virtual=True)
|
||||
return
|
||||
|
||||
def register_Ns3Ipv4GlobalRouting_methods(root_module, cls):
|
||||
## ipv4-global-routing.h: ns3::Ipv4GlobalRouting::Ipv4GlobalRouting(ns3::Ipv4GlobalRouting const & arg0) [copy constructor]
|
||||
cls.add_constructor([param('ns3::Ipv4GlobalRouting const &', 'arg0')])
|
||||
## ipv4-global-routing.h: static ns3::TypeId ns3::Ipv4GlobalRouting::GetTypeId() [member function]
|
||||
cls.add_method('GetTypeId',
|
||||
'ns3::TypeId',
|
||||
[],
|
||||
is_static=True)
|
||||
## ipv4-global-routing.h: ns3::Ipv4GlobalRouting::Ipv4GlobalRouting() [constructor]
|
||||
cls.add_constructor([])
|
||||
## ipv4-global-routing.h: ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRouting::RouteOutput(ns3::Ipv4Header const & header, uint32_t oif, ns3::Socket::SocketErrno & sockerr) [member function]
|
||||
cls.add_method('RouteOutput',
|
||||
'ns3::Ptr< ns3::Ipv4Route >',
|
||||
[param('ns3::Ipv4Header const &', 'header'), param('uint32_t', 'oif'), param('ns3::Socket::SocketErrno &', 'sockerr')],
|
||||
is_virtual=True)
|
||||
## ipv4-global-routing.h: bool ns3::Ipv4GlobalRouting::RouteInput(ns3::Ptr<ns3::Packet const> p, ns3::Ipv4Header const & header, ns3::Ptr<const ns3::NetDevice> idev, ns3::Callback<void,ns3::Ptr<ns3::Ipv4Route>,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ucb, ns3::Callback<void,ns3::Ptr<ns3::Ipv4MulticastRoute>,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> mcb, ns3::Callback<void,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,unsigned int,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> lcb, ns3::Callback<void,ns3::Ptr<const ns3::Packet>,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ecb) [member function]
|
||||
cls.add_method('RouteInput',
|
||||
'bool',
|
||||
[param('ns3::Ptr< ns3::Packet const >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice const >', 'idev'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4Route >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ucb'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4MulticastRoute >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'mcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, unsigned int, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'lcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ecb')],
|
||||
is_virtual=True)
|
||||
## ipv4-global-routing.h: void ns3::Ipv4GlobalRouting::AddHostRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
|
||||
cls.add_method('AddHostRouteTo',
|
||||
'void',
|
||||
[param('ns3::Ipv4Address', 'dest'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')])
|
||||
## ipv4-global-routing.h: void ns3::Ipv4GlobalRouting::AddHostRouteTo(ns3::Ipv4Address dest, uint32_t interface) [member function]
|
||||
cls.add_method('AddHostRouteTo',
|
||||
'void',
|
||||
[param('ns3::Ipv4Address', 'dest'), param('uint32_t', 'interface')])
|
||||
## ipv4-global-routing.h: void ns3::Ipv4GlobalRouting::AddNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
|
||||
cls.add_method('AddNetworkRouteTo',
|
||||
'void',
|
||||
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('ns3::Ipv4Address', 'nextHop'), param('uint32_t', 'interface')])
|
||||
## ipv4-global-routing.h: void ns3::Ipv4GlobalRouting::AddNetworkRouteTo(ns3::Ipv4Address network, ns3::Ipv4Mask networkMask, uint32_t interface) [member function]
|
||||
cls.add_method('AddNetworkRouteTo',
|
||||
'void',
|
||||
[param('ns3::Ipv4Address', 'network'), param('ns3::Ipv4Mask', 'networkMask'), param('uint32_t', 'interface')])
|
||||
## ipv4-global-routing.h: uint32_t ns3::Ipv4GlobalRouting::GetNRoutes() [member function]
|
||||
cls.add_method('GetNRoutes',
|
||||
'uint32_t',
|
||||
[])
|
||||
## ipv4-global-routing.h: ns3::Ipv4RoutingTableEntry * ns3::Ipv4GlobalRouting::GetRoute(uint32_t i) [member function]
|
||||
cls.add_method('GetRoute',
|
||||
'ns3::Ipv4RoutingTableEntry *',
|
||||
[param('uint32_t', 'i')])
|
||||
## ipv4-global-routing.h: void ns3::Ipv4GlobalRouting::RemoveRoute(uint32_t i) [member function]
|
||||
cls.add_method('RemoveRoute',
|
||||
'void',
|
||||
[param('uint32_t', 'i')])
|
||||
## ipv4-global-routing.h: void ns3::Ipv4GlobalRouting::SetNode(ns3::Ptr<ns3::Node> node) [member function]
|
||||
cls.add_method('SetNode',
|
||||
'void',
|
||||
[param('ns3::Ptr< ns3::Node >', 'node')])
|
||||
## ipv4-global-routing.h: ns3::Ptr<ns3::Node> ns3::Ipv4GlobalRouting::GetNode() const [member function]
|
||||
cls.add_method('GetNode',
|
||||
'ns3::Ptr< ns3::Node >',
|
||||
[],
|
||||
is_const=True)
|
||||
## ipv4-global-routing.h: void ns3::Ipv4GlobalRouting::DoDispose() [member function]
|
||||
cls.add_method('DoDispose',
|
||||
'void',
|
||||
[],
|
||||
visibility='protected', is_virtual=True)
|
||||
return
|
||||
|
||||
def register_Ns3Ipv4ListRoutingImpl_methods(root_module, cls):
|
||||
## ipv4-list-routing-impl.h: ns3::Ipv4ListRoutingImpl::Ipv4ListRoutingImpl(ns3::Ipv4ListRoutingImpl const & arg0) [copy constructor]
|
||||
cls.add_constructor([param('ns3::Ipv4ListRoutingImpl const &', 'arg0')])
|
||||
|
||||
@@ -36,7 +36,7 @@ The resulting binaries are placed in build/<debuglevel>/srcpath.
|
||||
|
||||
Other waf usages include:
|
||||
|
||||
1. ./waf check
|
||||
1. ./waf --check
|
||||
Runs the unit tests
|
||||
|
||||
2. ./waf --doxygen
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
* ns-3 requires Doxygen version 1.5.4 or greater to fully build all items,
|
||||
* although earlier versions of Doxygen will mostly work.
|
||||
*
|
||||
* Type "./waf check" followed by "./waf --doxygen" to build the documentation.
|
||||
* There is a program that runs during "./waf check" that builds pieces of
|
||||
* Type "./waf --check" followed by "./waf --doxygen" to build the documentation.
|
||||
* There is a program that runs during "./waf --check" that builds pieces of
|
||||
* the documentation through introspection. The doc/ directory contains
|
||||
* configuration for Doxygen (doxygen.conf and main.txt). The Doxygen
|
||||
* build process puts html files into the doc/html/ directory, and latex
|
||||
|
||||
@@ -205,7 +205,7 @@ add this to @code{src/common/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 "./waf --check". You
|
||||
shouldn't have broken anything by this operation.
|
||||
@subsection include guards
|
||||
Next, let's add some
|
||||
|
||||
@@ -6,12 +6,12 @@ Steps in doing an ns-3 release
|
||||
- revise and check in RELEASE_NOTES
|
||||
- DO NOT change VERSION at this time
|
||||
- confirm that Doxygen builds cleanly and without warnings
|
||||
(./waf check; ./waf --doxygen), and check in any necessary changes
|
||||
(./waf --check; ./waf --doxygen), and check in any necessary changes
|
||||
- ensure no regressions (./waf --regression)
|
||||
3. ./waf configure; ./waf dist
|
||||
- this will create an ns-3-dev.tar.bz2 tarball
|
||||
- this will also create a ns-3-dev-ref-traces.tar.bz2 tarball
|
||||
4. test dev tarball on release platforms (waf check and maybe some other
|
||||
4. test dev tarball on release platforms (waf --check and maybe some other
|
||||
scripts)
|
||||
5. once you are happy with the tarball, tag ns-3-dev and ns-3-dev-ref-traces
|
||||
- hg tag "ns-3.x"
|
||||
|
||||
@@ -248,7 +248,7 @@ from network number 10.1.2.0 in this case, as seen below.
|
||||
Now we have a topology built, but we need applications. This section is
|
||||
going to be fundamentally similar to the applications section of
|
||||
@code{first.cc} but we are going to instantiate the server on one of the
|
||||
nodes that has a CSMA node and the client on the node having only a
|
||||
nodes that has a CSMA device and the client on the node having only a
|
||||
point-to-point device.
|
||||
|
||||
First, we set up the echo server. We create a @code{UdpEchoServerHelper} and
|
||||
@@ -296,7 +296,7 @@ leftmost point-to-point node seen in the topology illustration.
|
||||
Since we have actually built an internetwork here, we need some form of
|
||||
internetwork routing. @command{ns-3} provides what we call a global route
|
||||
manager to set up the routing tables on nodes. This route manager has a
|
||||
global function that runs though the nodes created for the simulation and does
|
||||
global function that runs through the nodes created for the simulation and does
|
||||
the hard work of setting up routing for you.
|
||||
|
||||
Basically, what happens is that each node behaves as if it were an OSPF router
|
||||
@@ -317,7 +317,7 @@ you haven't encountered yet.
|
||||
|
||||
@verbatim
|
||||
PointToPointHelper::EnablePcapAll ("second");
|
||||
CsmaHelper::EnablePcap ("second", csmaDevices.Get (0), true);
|
||||
CsmaHelper::EnablePcap ("second", csmaDevices.Get (1), true);
|
||||
@end verbatim
|
||||
|
||||
The CSMA network is a multi-point-to-point network. This means that there
|
||||
@@ -336,8 +336,8 @@ In this example, we are going to select one of the devices on the CSMA
|
||||
network and ask it to perform a promiscuous sniff of the network, thereby
|
||||
emulating what @code{tcpdump} would do. If you were on a Linux machine
|
||||
you might do something like @code{tcpdump -i eth0} to get the trace.
|
||||
In this case, we specify the device using @code{csmaDevices.Get(0)},
|
||||
which selects the zeroth device in the container. Setting the final
|
||||
In this case, we specify the device using @code{csmaDevices.Get(1)},
|
||||
which selects the first device in the container. Setting the final
|
||||
parameter to true enables promiscuous captures.
|
||||
|
||||
The last section of code just runs and cleans up the simulation just like
|
||||
@@ -374,7 +374,7 @@ run the program.
|
||||
@verbatim
|
||||
export NS_LOG=
|
||||
./waf --run scratch/mysecond
|
||||
#end verbatim
|
||||
@end verbatim
|
||||
|
||||
Since we have set up the UDP echo applications to log just as we did in
|
||||
@code{first.cc}, you will see similar output when you run the script.
|
||||
@@ -395,7 +395,7 @@ the echo packet. The final message, @code{Received 1024 bytes from 10.1.2.4}
|
||||
is from the echo client, indicating that it has received its echo back from
|
||||
the server.
|
||||
|
||||
If you now go and look in the top level directory, you will find two trace
|
||||
If you now go and look in the top level directory, you will find three trace
|
||||
files:
|
||||
|
||||
@verbatim
|
||||
@@ -648,7 +648,7 @@ was in non-promiscuous mode.
|
||||
|
||||
To illustrate the difference between promiscuous and non-promiscuous traces, we
|
||||
also requested a non-promiscuous trace for the next-to-last node. Go ahead and
|
||||
take a look at the @code{tcpdump} for @code{second-10-0.pcap}.
|
||||
take a look at the @code{tcpdump} for @code{second-100-0.pcap}.
|
||||
|
||||
@verbatim
|
||||
tcpdump -nn -tt -r second-100-0.pcap
|
||||
@@ -845,11 +845,11 @@ helpers:
|
||||
|
||||
For simplicity, this code uses the default PHY layer configuration and
|
||||
channel models which are documented in the API doxygen documentation for
|
||||
the @code{YansWifiChannelHelper::Default} and @code{YAnsWifiPhyHelper::Default}
|
||||
the @code{YansWifiChannelHelper::Default} and @code{YansWifiPhyHelper::Default}
|
||||
methods. Once these objects are created, we create a channel object
|
||||
and associate it to our PHY layer object manager to make sure
|
||||
that all the PHY objects created layer by the @code{YansWifiPhyHelper}
|
||||
all share the same underlying channel, that is, they share the same
|
||||
that all the PHY layer objects created by the @code{YansWifiPhyHelper}
|
||||
share the same underlying channel, that is, they share the same
|
||||
wireless medium and can communication and interfere:
|
||||
|
||||
@verbatim
|
||||
@@ -1111,9 +1111,9 @@ third-0-0.pcap third-0-1.pcap third-1-0.pcap third-1-1.pcap
|
||||
@end verbatim
|
||||
|
||||
The file ``third-0-0.pcap'' corresponds to the point-to-point device on node
|
||||
zero -- the left side of the ``backbone.'' The file ``third-1-0.pcap''
|
||||
zero -- the left side of the ``backbone''. The file ``third-1-0.pcap''
|
||||
corresponds to the point-to-point device on node one -- the right side of the
|
||||
``backbone.'' The file ``third-0-1.pcap'' will be the promiscuous (monitor
|
||||
``backbone''. The file ``third-0-1.pcap'' will be the promiscuous (monitor
|
||||
mode) trace from the Wifi network and the file ``third-1-1.pcap'' will be the
|
||||
promiscuous trace from the CSMA network. Can you verify this by inspecting
|
||||
the code?
|
||||
@@ -1329,9 +1329,9 @@ If you are feeling brave, there is a list of all trace sources in the
|
||||
@uref{http://www.nsnam.org/doxygen-release/index.html,,ns-3 Doxygen}
|
||||
which you can find in the ``Modules'' tab.
|
||||
Under the ``core'' section, you will find a link to ``The list of all trace
|
||||
sources.'' You may find it interesting to try and hook some of these
|
||||
sources.''. You may find it interesting to try and hook some of these
|
||||
traces yourself. Additionally in the ``Modules'' documentation, there is
|
||||
a link to ``The list of all attributes.'' You can set the default value of
|
||||
a link to ``The list of all attributes.''. You can set the default value of
|
||||
any of these @code{Attributes} via the command line as we have previously
|
||||
discussed.
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ done a
|
||||
@end verbatim
|
||||
|
||||
to build the project. So now if you look in the directory
|
||||
@code{build/debug/ns-3} you will find the four module include files shown
|
||||
@code{build/debug/ns3} you will find the four module include files shown
|
||||
above. You can take a look at the contents of these files and find that they
|
||||
do include all of the public include files in their respective modules.
|
||||
|
||||
@@ -308,8 +308,8 @@ The next line of the script is the following,
|
||||
|
||||
We will use this statement as a convenient place to talk about our Doxygen
|
||||
documentation system. If you look at the project web site,
|
||||
@uref{http://www.nsnam.org,,ns-3 project}, you will find a link to ``APIs
|
||||
(Doxygen)'' in the navigation bar. If you select this link, you will be
|
||||
@uref{http://www.nsnam.org,,ns-3 project}, you will find a link to ``Doxygen
|
||||
(ns-3-dev)'' in the navigation bar. If you select this link, you will be
|
||||
taken to our documentation page.
|
||||
|
||||
Along the left side, you will find a graphical representation of the structure
|
||||
@@ -601,7 +601,7 @@ since we passed a @code{NodeContainer} containing one node) created by the
|
||||
helper.
|
||||
|
||||
Applications require a time to ``start'' generating traffic and may take an
|
||||
optional time to ``stop.'' We provide both. These times are set using the
|
||||
optional time to ``stop''. We provide both. These times are set using the
|
||||
@code{ApplicationContainer} methods @code{Start} and @code{Stop}. These
|
||||
methods take @code{Time} parameters. In this case, we use an explicit C++
|
||||
conversion sequence to take the C++ double 1.0 and convert it to an
|
||||
@@ -815,12 +815,12 @@ drwxr-xr-x utils files
|
||||
The source code is mainly in the @code{src} directory. You can view source
|
||||
code either by clicking on the directory name or by clicking on the @code{files}
|
||||
link to the right of the directory name. If you click on the @code{src}
|
||||
directory you be taken to the lising of the @code{src} subdirectories. If you
|
||||
directory, you will be taken to the listing of the @code{src} subdirectories. If you
|
||||
click on @code{core} subdirectory, you will find a list of files. The first file
|
||||
you will find (as of this writing) is @code{abort.h}. If you
|
||||
click on @code{abort.h} link, you will be sent to the source file for @code{abort.h}.
|
||||
|
||||
Our example scripts are in the @code{examples} directory. The source code for
|
||||
the helpers we have used in this chapter can be found in the
|
||||
@code{src/helpers} directory. Feel free to poke around in the directory tree to
|
||||
@code{src/helper} directory. Feel free to poke around in the directory tree to
|
||||
get a feel for what is there and the style of @command{ns-3} programs.
|
||||
|
||||
@@ -44,7 +44,7 @@ the Getting Started section of the @command{ns-3} web site:
|
||||
|
||||
@cindex tarball
|
||||
The @command{ns-3} code is available in Mercurial repositories on the server
|
||||
code.nsnam.org. You can also download a tarball release at
|
||||
@uref{http://code.nsnam.org}. You can also download a tarball release at
|
||||
@uref{http://www.nsnam.org/releases/}, or you can work with repositories
|
||||
using Mercurial. We recommend using Mercurial unless there's a good reason
|
||||
not to. See the end of this section for instructions on how to get a tarball
|
||||
@@ -53,7 +53,7 @@ release.
|
||||
@cindex repository
|
||||
The simplest way to get started using Mercurial repositories is to use the
|
||||
@code{ns-3-allinone} environment. This is a set of scripts that manages the
|
||||
downloading and building of various subystems of @command{ns-3} for you. We
|
||||
downloading and building of various subsystems of @command{ns-3} for you. We
|
||||
recommend that you begin your @command{ns-3} adventures in this environment
|
||||
as it can really simplify your life at this point.
|
||||
|
||||
@@ -128,12 +128,13 @@ Since the release numbers are going to be changing, I will stick with
|
||||
the more constant ns-3-dev here in the tutorial, but you can replace the
|
||||
string ``ns-3-dev'' with your choice of release (e.g., ns-3.4 and
|
||||
ns-3.4-ref-traces) in the text below. You can find the latest version of the
|
||||
code either by inspection of the repository list or by going to the ``Getting
|
||||
Started'' web page and looking for the latest release identifier.
|
||||
code either by inspection of the repository list or by going to the
|
||||
@uref{http://www.nsnam.org/getting_started.html,,``Getting Started''}
|
||||
web page and looking for the latest release identifier.
|
||||
|
||||
Go ahead and change into the @code{ns-3-allinone} directory you created when
|
||||
you cloned that repository. We are now going to use the @code{download.py}
|
||||
script to pull down the various pieces of @command{ns-3} you will be using/
|
||||
script to pull down the various pieces of @command{ns-3} you will be using.
|
||||
|
||||
Go ahead and type the following into your shell (remember you can substitute
|
||||
the name of your chosen release number instead of @code{ns-3-dev} -- like
|
||||
@@ -257,15 +258,15 @@ get a copy of a release by typing the following into your Linux shell
|
||||
mkdir tarballs
|
||||
cd tarballs
|
||||
wget http://www.nsnam.org/releases/ns-allinone-3.4.tar.bz2
|
||||
tar xjf ns-3.4.tar.bz2
|
||||
tar xjf ns-allinone-3.4.tar.bz2
|
||||
@end verbatim
|
||||
|
||||
If you change into the directory @code{ns-allinone-3.4} you should see a
|
||||
number of files:
|
||||
|
||||
@verbatim
|
||||
build.py* ns-3.4-RC2/ nsc-0.5.0/ util.py
|
||||
constants.py ns-3.4-RC2-ref-traces/ pybindgen-0.10.0.630/
|
||||
build.py* ns-3.4/ nsc-0.5.0/ README
|
||||
constants.py ns-3.4-ref-traces/ pybindgen-0.10.0.630/ util.py
|
||||
@end verbatim
|
||||
|
||||
You are now ready to build the @command{ns-3} distribution.
|
||||
@@ -404,7 +405,7 @@ Configuration finished successfully (00:00:02); project is now ready to build.
|
||||
@end verbatim
|
||||
|
||||
Note the last part of the above output. Some ns-3 options are not enabled by
|
||||
default or require support from the underlying system to work properly
|
||||
default or require support from the underlying system to work properly.
|
||||
For instance, to enable XmlTo, the library libxml-2.0 must be found on the
|
||||
system. in the example above, this library was not found and the corresponding
|
||||
feature was not enabled. There is a feature to use sudo to set the suid bit of
|
||||
@@ -438,7 +439,7 @@ programs to run as root. There are many other configure- and build-time options
|
||||
available in waf. To explore these options, type:
|
||||
|
||||
@verbatim
|
||||
./waf -- help
|
||||
./waf --help
|
||||
@end verbatim
|
||||
|
||||
We'll use some of the testing-related commands in the next section.
|
||||
@@ -455,10 +456,10 @@ but now you know how to change the configuration and build optimized code.
|
||||
|
||||
@cindex unit tests
|
||||
You can run the unit tests of the @command{ns-3} distribution by running the
|
||||
``check'' command,
|
||||
``--check'' option,
|
||||
|
||||
@verbatim
|
||||
./waf check
|
||||
./waf --check
|
||||
@end verbatim
|
||||
|
||||
You should see a report from each unit test that executes indicating that the
|
||||
@@ -488,7 +489,7 @@ This command is typically run by @code{users} to quickly verify that an
|
||||
|
||||
@cindex regression tests
|
||||
You can also run our regression test suite to ensure that your distribution and
|
||||
tool chain have produced binaries that generate output that is identical to
|
||||
toolchain have produced binaries that generate output that is identical to
|
||||
known-good reference output files. You downloaded these reference traces to
|
||||
your machine during the download process above. (Warning: The @code{ns-3.2}
|
||||
and @code{ns-3.3} releases do not use the @code{ns-3-allinone} environment
|
||||
@@ -505,7 +506,7 @@ along with a suggestion on diff parameters and options in order to see what
|
||||
has gone awry. If the error was discovered in a pcap file, it will be useful
|
||||
to convert the pcap files to text using tcpdump prior to comparison.
|
||||
|
||||
Some regression tests wmay be SKIPped if the required support
|
||||
Some regression tests may be SKIPped if the required support
|
||||
is not present.
|
||||
|
||||
To run the regression tests, you provide Waf with the regression flag.
|
||||
@@ -568,7 +569,7 @@ ubiquitous hello world program by typing the following:
|
||||
@end verbatim
|
||||
|
||||
Waf first checks to make sure that the program is built correctly and
|
||||
executes a build if required. Waf then then executes the program, which
|
||||
executes a build if required. Waf then executes the program, which
|
||||
produces the following output.
|
||||
|
||||
@verbatim
|
||||
|
||||
@@ -562,7 +562,7 @@ The build system is now configured and you can build the debug versions of
|
||||
the ns-3 programs by simply typing,
|
||||
|
||||
@verbatim
|
||||
./waf check
|
||||
./waf --check
|
||||
@end verbatim
|
||||
|
||||
You will see many Waf status messages displayed as the system compiles. The
|
||||
|
||||
@@ -226,7 +226,7 @@ only have to understand a tiny and intuitively obvious subset of Python in
|
||||
order to extend the system in most cases.
|
||||
|
||||
For those interested in the gory details of Waf, the main web site can be
|
||||
found at @uref{http://freehackers.org/~tnagy/waf.html}.
|
||||
found at @uref{http://code.google.com/p/waf/}.
|
||||
|
||||
@node Development Environment
|
||||
@section Development Environment
|
||||
@@ -275,7 +275,7 @@ problems.
|
||||
@cindex MinGW
|
||||
If you do use Cygwin or MinGW; and use Logitech products, we will save you
|
||||
quite a bit of heartburn right off the bat and encourage you to take a look
|
||||
at the @uref{http://www.mingw.org/MinGWiki/index.php/FAQ,,MinGW FAQ}.
|
||||
at the @uref{http://oldwiki.mingw.org/index.php/FAQ,,MinGW FAQ}.
|
||||
|
||||
@cindex Logitech
|
||||
Search for ``Logitech'' and read the FAQ entry, ``why does make often
|
||||
@@ -295,7 +295,7 @@ such as VMware server and install a Linux virtual machine.
|
||||
We will assume a basic facility with the Berkeley Sockets API in the examples
|
||||
used in this tutorial. If you are new to sockets, we recommend reviewing the
|
||||
API and some common usage cases. For a good overview of programming TCP/IP
|
||||
sockets we recommend @uref{http://www.elsevier.com/wps/product/cws_home/680765,,Practical TCP/IP Sockets in C, Donahoo and Calvert}.
|
||||
sockets we recommend @uref{http://www.elsevier.com/wps/find/bookdescription.cws_home/717656/description#description,,TCP/IP Sockets in C, Donahoo and Calvert}.
|
||||
|
||||
There is an associated web site that includes source for the examples in the
|
||||
book, which you can find at:
|
||||
@@ -305,6 +305,6 @@ If you understand the first four chapters of the book (or for those who do
|
||||
not have access to a copy of the book, the echo clients and servers shown in
|
||||
the website above) you will be in good shape to understand the tutorial.
|
||||
There is a similar book on Multicast Sockets,
|
||||
@uref{http://www.elsevier.com/wps/product/cws_home/700736,,Multicast Sockets, Makofske and Almeroth}.
|
||||
@uref{http://www.elsevier.com/wps/find/bookdescription.cws_home/700736/description#description,,Multicast Sockets, Makofske and Almeroth}.
|
||||
that covers material you may need to understand if you look at the multicast
|
||||
examples in the distribution.
|
||||
|
||||
@@ -112,7 +112,7 @@ actually logging messages from the @code{UdpEchoClientApplication} and
|
||||
example, to print more information by setting its logging level via the
|
||||
NS_LOG environment variable.
|
||||
|
||||
I am going to assume from here on that are using an sh-like shell that uses
|
||||
I am going to assume from here on that you are using an sh-like shell that uses
|
||||
the``VARIABLE=value'' syntax. If you are using a csh-like shell, then you
|
||||
will have to convert my examples to the ``setenv VARIABLE value'' syntax
|
||||
required by those shells.
|
||||
@@ -353,7 +353,7 @@ Recall that we have defined a logging component in that script:
|
||||
|
||||
You now know that you can enable all of the logging for this component by
|
||||
setting the @code{NS_LOG} environment variable to the various levels. Let's
|
||||
go ahead add some logging to the script. The macro used to add an
|
||||
go ahead and add some logging to the script. The macro used to add an
|
||||
informational level log message is @code{NS_LOG_INFO}. Go ahead and add one
|
||||
(just before we start creating the nodes) that tells you that the script is
|
||||
``Creating Topology.'' This is done as in this code snippet,
|
||||
@@ -439,7 +439,7 @@ in the following code,
|
||||
|
||||
This simple two line snippet is actually very useful by itself. It opens the
|
||||
door to the @command{ns-3} global variable and @code{Attribute} systems. Go
|
||||
ahead and add that two lines of code to the @code{scratch/first.cc} script at
|
||||
ahead and add that two lines of code to the @code{scratch/myfirst.cc} script at
|
||||
the start of @code{main}. Go ahead and build the script and run it, but ask
|
||||
the script for help in the following way,
|
||||
|
||||
@@ -497,7 +497,7 @@ is created in the system. We overrode this default with the @code{Attribute}
|
||||
setting in the @code{PointToPointHelper} above. Let's use the default values
|
||||
for the point-to-point devices and channels by deleting the
|
||||
@code{SetDeviceAttribute} call and the @code{SetChannelAttribute} call from
|
||||
the @code{first.cc} we have in the scratch directory.
|
||||
the @code{myfirst.cc} we have in the scratch directory.
|
||||
|
||||
Your script should now just declare the @code{PointToPointHelper} and not do
|
||||
any @code{set} operations as in the following example,
|
||||
@@ -801,8 +801,8 @@ the script just after the GNU GPL comment:
|
||||
#include <fstream>
|
||||
@end verbatim
|
||||
|
||||
Then, right before the before the call to @code{Simulator::Run ()}, add the
|
||||
following lines of code.
|
||||
Then, right before the call to @code{Simulator::Run ()}, add the
|
||||
following lines of code:
|
||||
|
||||
@verbatim
|
||||
std::ofstream ascii;
|
||||
@@ -811,7 +811,7 @@ following lines of code.
|
||||
@end verbatim
|
||||
|
||||
The first two lines are just vanilla C++ code to open a stream that will be
|
||||
written to a file named ``myfirst.tr.'' See your favorite C++ tutorial if you
|
||||
written to a file named ``myfirst.tr''. See your favorite C++ tutorial if you
|
||||
are unfamiliar with this code. The last line of code in the snippet above
|
||||
tells @command{ns-3} that you want to enable ASCII tracing on all
|
||||
point-to-point devices in your simulation; and you want the (provided) trace
|
||||
@@ -900,7 +900,7 @@ managed in the @command{ns-3} core code that contains all of the nodes that are
|
||||
created in a script. Just as a filesystem may have directories under the
|
||||
root, we may have node numbers in the @code{NodeList}. The string
|
||||
@code{/NodeList/0} therefore refers to the zeroth node in the @code{NodeList}
|
||||
which we typically think of as ``node 0.'' In each node there is a list of
|
||||
which we typically think of as ``node 0''. In each node there is a list of
|
||||
devices that have been installed. This list appears next in the namespace.
|
||||
You can see that this trace event comes from @code{DeviceList/0} which is the
|
||||
zeroth device installed in the node.
|
||||
@@ -928,14 +928,12 @@ device on the node with the echo server. I have reproduced that event below.
|
||||
00 r
|
||||
01 2.25732
|
||||
02 /NodeList/1/DeviceList/0/$ns3::PointToPointNetDevice/MacRx
|
||||
03 ns3::PppHeader (
|
||||
04 Point-to-Point Protocol: IP (0x0021))
|
||||
05 ns3::Ipv4Header (
|
||||
06 tos 0x0 ttl 64 id 0 offset 0 flags [none]
|
||||
07 length: 1052 10.1.1.1 > 10.1.1.2)
|
||||
08 ns3::UdpHeader (
|
||||
09 length: 1032 49153 > 9)
|
||||
10 Payload (size=1024)
|
||||
03 ns3::Ipv4Header (
|
||||
04 tos 0x0 ttl 64 id 0 protocol 17 offset 0 flags [none]
|
||||
05 length: 1052 10.1.1.1 > 10.1.1.2)
|
||||
06 ns3::UdpHeader (
|
||||
07 length: 1032 49153 > 9)
|
||||
08 Payload (size=1024)
|
||||
@end verbatim
|
||||
|
||||
Notice that the trace operation is now @code{r} and the simulation time has
|
||||
@@ -978,7 +976,7 @@ file names will be built using the prefix, the node number, the device number
|
||||
and a ``.pcap'' suffix.
|
||||
|
||||
In our example script, we will eventually see files named ``myfirst-0-0.pcap''
|
||||
and ``myfirst.1-0.pcap'' which are the pcap traces for node 0-device 0 and
|
||||
and ``myfirst-1-0.pcap'' which are the pcap traces for node 0-device 0 and
|
||||
node 1-device 0, respectively.
|
||||
|
||||
Once you have added the line of code to enable pcap tracing, you can run the
|
||||
@@ -1010,9 +1008,9 @@ at the @code{pcap} files.
|
||||
2.257324 IP 10.1.1.2.9 > 10.1.1.1.49153: UDP, length 1024
|
||||
@end verbatim
|
||||
|
||||
You can see in the dump of @code{myfirst-0.0.pcap} (the client device) that the
|
||||
You can see in the dump of @code{myfirst-0-0.pcap} (the client device) that the
|
||||
echo packet is sent at 2 seconds into the simulation. If you look at the
|
||||
second dump (@code{first-1-0.pcap}) you can see that packet being received
|
||||
second dump (@code{myfirst-1-0.pcap}) you can see that packet being received
|
||||
at 2.257324 seconds. You see the packet being echoed back at 2.257324 seconds
|
||||
in the second dump, and finally, you see the packet being received back at
|
||||
the client in the first dump at 2.514648 seconds.
|
||||
|
||||
@@ -142,8 +142,7 @@ void PacketSink::HandleRead (Ptr<Socket> socket)
|
||||
{
|
||||
InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
|
||||
NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " <<
|
||||
address.GetIpv4() << " [" << address << "]---'" <<
|
||||
packet->PeekData() << "'");
|
||||
address.GetIpv4() << " [" << address << "]");
|
||||
}
|
||||
m_rxTrace (packet, from);
|
||||
}
|
||||
|
||||
@@ -87,10 +87,11 @@ V4Ping::Receive (Ptr<Socket> socket)
|
||||
if (echo.GetSequenceNumber () == (m_seq - 1) &&
|
||||
echo.GetIdentifier () == 0)
|
||||
{
|
||||
Ptr<const Packet> data = echo.GetData ();
|
||||
if (data->GetSize () == 16)
|
||||
uint8_t data[16];
|
||||
uint32_t dataSize = echo.GetData (data);
|
||||
if (dataSize == 16)
|
||||
{
|
||||
uint32_t *buf = (uint32_t *)data->PeekData ();
|
||||
uint32_t *buf = (uint32_t *)data;
|
||||
if (buf[0] == GetNode ()->GetId () &&
|
||||
buf[1] == GetApplicationId ())
|
||||
{
|
||||
|
||||
@@ -643,6 +643,32 @@ Buffer::PeekData (void) const
|
||||
return m_data->m_data + m_start;
|
||||
}
|
||||
|
||||
void
|
||||
Buffer::CopyData(std::ostream *os, uint32_t size) const
|
||||
{
|
||||
if (size == GetSize ())
|
||||
{
|
||||
// fast path
|
||||
os->write((const char*)(m_data->m_data + m_start), m_zeroAreaStart-m_start);
|
||||
char zero = 0;
|
||||
for (uint32_t i = 0; i < m_zeroAreaEnd - m_zeroAreaStart; ++i)
|
||||
{
|
||||
os->write (&zero, 1);
|
||||
}
|
||||
os->write ((const char*)(m_data->m_data + m_zeroAreaStart), m_end - m_zeroAreaEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// slow path
|
||||
Buffer::Iterator i = Begin ();
|
||||
while (!i.IsEnd () && size > 0)
|
||||
{
|
||||
char byte = i.ReadU8 ();
|
||||
os->write (&byte, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************
|
||||
* The buffer iterator below.
|
||||
******************************************************/
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
#define BUFFER_HEURISTICS 1
|
||||
#define BUFFER_USE_INLINE 1
|
||||
@@ -486,6 +487,8 @@ public:
|
||||
int32_t GetCurrentStartOffset (void) const;
|
||||
int32_t GetCurrentEndOffset (void) const;
|
||||
|
||||
void CopyData (std::ostream *os, uint32_t size) const;
|
||||
|
||||
Buffer (Buffer const &o);
|
||||
Buffer &operator = (Buffer const &o);
|
||||
Buffer ();
|
||||
|
||||
@@ -356,6 +356,12 @@ Packet::CopyData (uint8_t *buffer, uint32_t size) const
|
||||
return cur;
|
||||
}
|
||||
|
||||
void
|
||||
Packet::CopyData(std::ostream *os, uint32_t size) const
|
||||
{
|
||||
return m_buffer.CopyData (os, size);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Packet::GetUid (void) const
|
||||
{
|
||||
|
||||
@@ -344,6 +344,8 @@ public:
|
||||
*/
|
||||
uint32_t CopyData (uint8_t *buffer, uint32_t size) const;
|
||||
|
||||
void CopyData(std::ostream *os, uint32_t size) const;
|
||||
|
||||
/**
|
||||
* A packet is allocated a new uid when it is created
|
||||
* empty or with zero-filled payload.
|
||||
|
||||
@@ -164,7 +164,7 @@ PcapWriter::WritePacket (Ptr<const Packet> packet)
|
||||
Write32 (us & 0xffffffff);
|
||||
Write32 (packet->GetSize ());
|
||||
Write32 (packet->GetSize ());
|
||||
WriteData (packet->PeekData (), packet->GetSize ());
|
||||
packet->CopyData (m_writer, packet->GetSize ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,7 +412,7 @@ void PcapWriter::WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t chann
|
||||
}
|
||||
|
||||
// finally, write rest of packet
|
||||
WriteData (packet->PeekData (), packet->GetSize ());
|
||||
packet->CopyData (m_writer, packet->GetSize ());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ def configure(conf):
|
||||
"library 'libxml-2.0 >= 2.7' not found")
|
||||
conf.sub_config('stats')
|
||||
|
||||
conf.write_config_header('ns3/contrib-config.h', project_root_relative=True)
|
||||
conf.write_config_header('ns3/contrib-config.h', top=True)
|
||||
|
||||
def build(bld):
|
||||
module = bld.create_ns3_module('contrib', ['simulator', 'common'])
|
||||
|
||||
@@ -55,6 +55,18 @@ TestManager::EnableVerbose (void)
|
||||
{
|
||||
Get ()->m_verbose = true;
|
||||
}
|
||||
|
||||
void
|
||||
TestManager::PrintTestNames (std::ostream &os)
|
||||
{
|
||||
for (TestsCI i = Get ()->m_tests.begin (); i != Get ()->m_tests.end (); i++)
|
||||
{
|
||||
std::string *testName = (*i).second;
|
||||
os << *testName << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::ostream &
|
||||
TestManager::Failure (void)
|
||||
{
|
||||
@@ -95,6 +107,47 @@ TestManager::RealRunTests (void)
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
bool
|
||||
TestManager::RunTest (std::string name)
|
||||
{
|
||||
return Get ()->RealRunTest (name);
|
||||
}
|
||||
bool
|
||||
TestManager::RealRunTest (std::string name)
|
||||
{
|
||||
TestsCI i;
|
||||
|
||||
for (i = m_tests.begin (); i != m_tests.end (); i++)
|
||||
{
|
||||
std::string *testName = (*i).second;
|
||||
if (*testName == name)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == m_tests.end ())
|
||||
{
|
||||
std::cerr << "Test with name " << name << " not found." << std::endl;
|
||||
}
|
||||
|
||||
if (!(*i).first->RunTests ())
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
std::cerr << "FAIL " << name << std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_verbose)
|
||||
{
|
||||
std::cerr << "PASS "<< name << std::endl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Test::Test (char const *name)
|
||||
{
|
||||
TestManager::Add (this, name);
|
||||
|
||||
@@ -89,12 +89,17 @@ public:
|
||||
*/
|
||||
static bool RunTests (void);
|
||||
|
||||
static bool RunTest (std::string name);
|
||||
|
||||
static void PrintTestNames (std::ostream &os);
|
||||
|
||||
private:
|
||||
friend class Test;
|
||||
static void Add (Test *test, char const *name);
|
||||
static std::ostream &Failure (void);
|
||||
static TestManager *Get (void);
|
||||
bool RealRunTests (void);
|
||||
bool RealRunTest (std::string name);
|
||||
|
||||
TestManager ();
|
||||
~TestManager ();
|
||||
|
||||
@@ -41,7 +41,7 @@ int main ()
|
||||
conf.env['ENABLE_THREADING'],
|
||||
"<pthread.h> include not detected")
|
||||
|
||||
conf.write_config_header('ns3/core-config.h', project_root_relative=True)
|
||||
conf.write_config_header('ns3/core-config.h', top=True)
|
||||
|
||||
def build(bld):
|
||||
core = bld.create_ns3_module('core')
|
||||
|
||||
@@ -29,7 +29,9 @@ TypeId
|
||||
BridgeChannel::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::BridgeChannel")
|
||||
.SetParent<Channel> ();
|
||||
.SetParent<Channel> ()
|
||||
.AddConstructor<BridgeChannel> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,12 +46,12 @@ MeshWifiInterfaceMac::GetTypeId ()
|
||||
.SetParent<WifiMac> ()
|
||||
.AddConstructor<MeshWifiInterfaceMac> ()
|
||||
.AddAttribute ("BeaconInterval", "Beacon Interval",
|
||||
TimeValue (Seconds (1.0)),
|
||||
TimeValue (Seconds (0.5)),
|
||||
MakeTimeAccessor (&MeshWifiInterfaceMac::m_beaconInterval),
|
||||
MakeTimeChecker ()
|
||||
)
|
||||
.AddAttribute ("RandomStart", "Window when beacon generating starts (uniform random) in seconds",
|
||||
TimeValue (Seconds (0.1)),
|
||||
TimeValue (Seconds (0.5)),
|
||||
MakeTimeAccessor (&MeshWifiInterfaceMac::m_randomStart),
|
||||
MakeTimeChecker ()
|
||||
)
|
||||
|
||||
@@ -805,7 +805,7 @@ MacLow::DoNavResetNow (Time duration)
|
||||
(*i)->NavReset (duration);
|
||||
}
|
||||
m_lastNavStart = Simulator::Now ();
|
||||
m_lastNavDuration = duration;
|
||||
m_lastNavStart = duration;
|
||||
}
|
||||
bool
|
||||
MacLow::DoNavStartNow (Time duration)
|
||||
|
||||
@@ -38,6 +38,7 @@ WifiNetDevice::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::WifiNetDevice")
|
||||
.SetParent<NetDevice> ()
|
||||
.AddConstructor<WifiNetDevice> ()
|
||||
.AddAttribute ("Channel", "The channel attached to this device",
|
||||
PointerValue (),
|
||||
MakePointerAccessor (&WifiNetDevice::DoGetChannel),
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
virtual ~NqosWifiMacHelper ();
|
||||
/**
|
||||
* Create a mac helper in a default working state.
|
||||
* i.e., this is an adhoc mac by default.
|
||||
*/
|
||||
static NqosWifiMacHelper Default (void);
|
||||
/**
|
||||
|
||||
@@ -108,7 +108,9 @@ Icmpv4Echo::SetSequenceNumber (uint16_t seq)
|
||||
void
|
||||
Icmpv4Echo::SetData (Ptr<const Packet> data)
|
||||
{
|
||||
m_data = data->Copy ();
|
||||
uint32_t size = (data->GetSize ()>16)?16:data->GetSize();
|
||||
data->CopyData (m_data, size);
|
||||
m_dataSize = size;
|
||||
}
|
||||
uint16_t
|
||||
Icmpv4Echo::GetIdentifier (void) const
|
||||
@@ -120,10 +122,11 @@ Icmpv4Echo::GetSequenceNumber (void) const
|
||||
{
|
||||
return m_sequence;
|
||||
}
|
||||
Ptr<const Packet>
|
||||
Icmpv4Echo::GetData (void) const
|
||||
uint32_t
|
||||
Icmpv4Echo::GetData (uint8_t data[16]) const
|
||||
{
|
||||
return m_data->Copy ();
|
||||
memcpy (data, m_data, m_dataSize);
|
||||
return m_dataSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,8 +142,14 @@ Icmpv4Echo::GetTypeId (void)
|
||||
Icmpv4Echo::Icmpv4Echo ()
|
||||
: m_identifier (0),
|
||||
m_sequence (0),
|
||||
m_data (0)
|
||||
{}
|
||||
m_dataSize (0)
|
||||
{
|
||||
// make sure that thing is initialized to get initialized bytes
|
||||
for (uint8_t j = 0; j < 16; j++)
|
||||
{
|
||||
m_data[j] = 0;
|
||||
}
|
||||
}
|
||||
Icmpv4Echo::~Icmpv4Echo ()
|
||||
{}
|
||||
TypeId
|
||||
@@ -151,14 +160,14 @@ Icmpv4Echo::GetInstanceTypeId (void) const
|
||||
uint32_t
|
||||
Icmpv4Echo::GetSerializedSize (void) const
|
||||
{
|
||||
return 4 + m_data->GetSize ();
|
||||
return 4 + m_dataSize;
|
||||
}
|
||||
void
|
||||
Icmpv4Echo::Serialize (Buffer::Iterator start) const
|
||||
{
|
||||
start.WriteHtonU16 (m_identifier);
|
||||
start.WriteHtonU16 (m_sequence);
|
||||
start.Write (m_data->PeekData (), m_data->GetSize ());
|
||||
start.Write (m_data, m_dataSize);
|
||||
}
|
||||
uint32_t
|
||||
Icmpv4Echo::Deserialize (Buffer::Iterator start)
|
||||
@@ -166,11 +175,8 @@ Icmpv4Echo::Deserialize (Buffer::Iterator start)
|
||||
m_identifier = start.ReadNtohU16 ();
|
||||
m_sequence = start.ReadNtohU16 ();
|
||||
NS_ASSERT (start.GetSize () >= 4);
|
||||
uint32_t size = start.GetSize () - 4;
|
||||
uint8_t *buffer = new uint8_t[size] ();
|
||||
start.Read (buffer, size);
|
||||
m_data = Create<Packet> (buffer, size);
|
||||
delete[] buffer;
|
||||
m_dataSize = start.GetSize () - 4;
|
||||
start.Read (m_data, m_dataSize);
|
||||
return start.GetSize ();
|
||||
}
|
||||
void
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
void SetData (Ptr<const Packet> data);
|
||||
uint16_t GetIdentifier (void) const;
|
||||
uint16_t GetSequenceNumber (void) const;
|
||||
Ptr<const Packet> GetData (void) const;
|
||||
uint32_t GetData (uint8_t payload[16]) const;
|
||||
|
||||
|
||||
static TypeId GetTypeId (void);
|
||||
@@ -64,7 +64,8 @@ public:
|
||||
private:
|
||||
uint16_t m_identifier;
|
||||
uint16_t m_sequence;
|
||||
Ptr<Packet> m_data;
|
||||
uint8_t m_data[16];
|
||||
uint32_t m_dataSize;
|
||||
};
|
||||
|
||||
class Icmpv4DestinationUnreachable : public Header
|
||||
|
||||
@@ -35,6 +35,7 @@ Ipv4ListRoutingImpl::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Ipv4ListRoutingImpl")
|
||||
.SetParent<Ipv4ListRouting> ()
|
||||
.AddConstructor<Ipv4ListRoutingImpl> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ Ipv4StaticRoutingImpl::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Ipv4StaticRoutingImpl")
|
||||
.SetParent<Ipv4StaticRouting> ()
|
||||
.AddConstructor<Ipv4StaticRoutingImpl> ()
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ NscTcpSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags,
|
||||
{
|
||||
SocketAddressTag tag;
|
||||
bool found;
|
||||
found = packet->FindFirstMatchingTag (tag);
|
||||
found = packet->PeekPacketTag (tag);
|
||||
NS_ASSERT (found);
|
||||
fromAddress = tag.GetAddress ();
|
||||
}
|
||||
@@ -600,7 +600,7 @@ bool NscTcpSocketImpl::ReadPendingData (void)
|
||||
SocketAddressTag tag;
|
||||
|
||||
tag.SetAddress (m_peerAddress);
|
||||
p->AddTag (tag);
|
||||
p->AddPacketTag (tag);
|
||||
m_deliveryQueue.push (p);
|
||||
m_rxAvailable += p->GetSize ();
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ TcpSocketImplTest::Test1_HandleRecv (Ptr<Socket> sock)
|
||||
{
|
||||
rxBytes1 += sz;
|
||||
rxPayload = new uint8_t[sz];
|
||||
memcpy (rxPayload, p->PeekData(), sz);
|
||||
p->CopyData (rxPayload, sz);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -82,7 +82,6 @@ def build(bld):
|
||||
'ipv4-l3-protocol.cc',
|
||||
'ipv4-static-routing-impl.cc',
|
||||
'ipv4-list-routing-impl.cc',
|
||||
'ipv4-global-routing.cc',
|
||||
'ipv4-end-point.cc',
|
||||
'udp-l4-protocol.cc',
|
||||
'tcp-l4-protocol.cc',
|
||||
@@ -110,7 +109,6 @@ def build(bld):
|
||||
'udp-header.h',
|
||||
'tcp-header.h',
|
||||
'sequence-number.h',
|
||||
'ipv4-global-routing.h',
|
||||
'ipv4-list-routing-impl.h',
|
||||
'ipv4-static-routing-impl.h',
|
||||
'icmpv4.h',
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \ingroup ipv4-routing
|
||||
* \ingroup ipv4Routing
|
||||
*
|
||||
* This class is a specialization of Ipv4RoutingProtocol that allows
|
||||
* other instances of Ipv4RoutingProtocol to be inserted in a
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ns3 {
|
||||
class NetDevice;
|
||||
|
||||
/**
|
||||
* \ingroup ipv4-routing
|
||||
* \ingroup ipv4Routing
|
||||
*
|
||||
*\brief Ipv4 route cache entry (similar to Linux struct rtable)
|
||||
*
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
std::ostream& operator<< (std::ostream& os, Ipv4Route const& route);
|
||||
|
||||
/**
|
||||
* \ingroup ipv4-routing
|
||||
* \ingroup ipv4Routing
|
||||
*
|
||||
* \brief Ipv4 multicast route cache entry (similar to Linux struct mfc_cache)
|
||||
*/
|
||||
|
||||
@@ -32,7 +32,7 @@ class NetDevice;
|
||||
|
||||
/**
|
||||
* \ingroup node
|
||||
* \defgroup ipv4-routing Ipv4 Routing
|
||||
* \defgroup ipv4Routing Ipv4 Routing
|
||||
*
|
||||
* Abstract base class for Ipv4 routing protocols. Defines two
|
||||
* virtual functions for packet routing and forwarding. The first,
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \ingroup ipv4-routing
|
||||
* \ingroup ipv4Routing
|
||||
*
|
||||
* A record of an IPv4 routing table entry for Ipv4GlobalRouting and
|
||||
* Ipv4StaticRouting. This is not a reference counted object.
|
||||
@@ -155,7 +155,7 @@ private:
|
||||
std::ostream& operator<< (std::ostream& os, Ipv4RoutingTableEntry const& route);
|
||||
|
||||
/**
|
||||
* \ingroup ipv4-routing
|
||||
* \ingroup ipv4Routing
|
||||
*
|
||||
* \brief A record of an IPv4 multicast route for Ipv4GlobalRouting and Ipv4StaticRouting
|
||||
*/
|
||||
|
||||
@@ -44,7 +44,7 @@ class Ipv4RoutingTableEntry;
|
||||
class Ipv4MulticastRoutingTableEntry;
|
||||
|
||||
/**
|
||||
* \ingroup ipv4-routing
|
||||
* \ingroup ipv4Routing
|
||||
*
|
||||
* \brief Static routing protocol for IP version 4 stacks.
|
||||
*
|
||||
|
||||
@@ -148,7 +148,7 @@ Socket::Recv (uint8_t* buf, uint32_t size, uint32_t flags)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
memcpy (buf, p->PeekData (), p->GetSize());
|
||||
p->CopyData (buf, p->GetSize ());
|
||||
return p->GetSize ();
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ Socket::RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
memcpy (buf, p->PeekData (), p->GetSize());
|
||||
p->CopyData (buf, p->GetSize ());
|
||||
return p->GetSize ();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/node-list.h"
|
||||
#include "ns3/ipv4.h"
|
||||
#include "ns3/ipv4-global-routing.h"
|
||||
#include "ns3/ipv4-routing-protocol.h"
|
||||
#include "ns3/ipv4-list-routing.h"
|
||||
#include "global-router-interface.h"
|
||||
#include "global-route-manager-impl.h"
|
||||
#include "candidate-queue.h"
|
||||
#include "ipv4-global-routing.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("GlobalRouteManager");
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ def build(bld):
|
||||
'global-route-manager.cc',
|
||||
'global-route-manager-impl.cc',
|
||||
'candidate-queue.cc',
|
||||
'ipv4-global-routing.cc',
|
||||
]
|
||||
headers = bld.new_task_gen('ns3header')
|
||||
headers.module = 'global-routing'
|
||||
|
||||
@@ -31,7 +31,7 @@ def configure(conf):
|
||||
|
||||
conf.check(header_name='sys/inttypes.h', define_name='HAVE_SYS_INT_TYPES_H')
|
||||
|
||||
conf.write_config_header('ns3/simulator-config.h', project_root_relative=True)
|
||||
conf.write_config_header('ns3/simulator-config.h', top=True)
|
||||
|
||||
if not conf.check(lib='rt', uselib='RT', define_name='HAVE_RT'):
|
||||
conf.report_optional_feature("RealTime", "Real Time Simulator",
|
||||
|
||||
@@ -25,13 +25,42 @@
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
if (argc > 1)
|
||||
{
|
||||
if (std::string (argv[1]) == "--ListTests")
|
||||
{
|
||||
#ifdef RUN_SELF_TESTS
|
||||
ns3::PacketMetadata::Enable ();
|
||||
ns3::TestManager::EnableVerbose ();
|
||||
bool success = ns3::TestManager::RunTests ();
|
||||
if (!success)
|
||||
return 1;
|
||||
ns3::TestManager::PrintTestNames (std::cout);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// run the test named by argv[1]
|
||||
#ifdef RUN_SELF_TESTS
|
||||
bool success = ns3::TestManager::RunTest (argv[1]);
|
||||
if (!success)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
std::cerr << "Unit tests not enabled" << std::endl;
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// run all tests
|
||||
#ifdef RUN_SELF_TESTS
|
||||
ns3::PacketMetadata::Enable ();
|
||||
ns3::TestManager::EnableVerbose ();
|
||||
bool success = ns3::TestManager::RunTests ();
|
||||
if (!success)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif /* RUN_SELF_TESTS */
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
187
wscript
187
wscript
@@ -146,6 +146,9 @@ def set_options(opt):
|
||||
opt.add_option('--regression',
|
||||
help=("Enable regression testing; only used for the 'check' target"),
|
||||
default=False, dest='regression', action="store_true")
|
||||
opt.add_option('--check',
|
||||
help=("Enable unit testing"),
|
||||
default=False, dest='check', action="store_true")
|
||||
opt.add_option('--regression-generate',
|
||||
help=("Generate new regression test traces."),
|
||||
default=False, dest='regression_generate', action="store_true")
|
||||
@@ -523,6 +526,8 @@ def build(bld):
|
||||
" (--with-regression-traces configure option)")
|
||||
regression.run_regression(bld, regression_traces)
|
||||
|
||||
if Options.options.check:
|
||||
_run_check(bld)
|
||||
|
||||
|
||||
def shutdown(ctx):
|
||||
@@ -561,35 +566,163 @@ def shutdown(ctx):
|
||||
|
||||
check_context = Build.BuildContext
|
||||
def check(bld):
|
||||
"run the NS-3 unit tests"
|
||||
Scripting.build(bld)
|
||||
## generate the trace sources list docs
|
||||
env = wutils.bld.env
|
||||
proc_env = wutils.get_proc_env()
|
||||
try:
|
||||
program_obj = wutils.find_program('print-introspected-doxygen', env)
|
||||
except ValueError: # could happen if print-introspected-doxygen is
|
||||
# not built because of waf configure
|
||||
# --enable-modules=xxx
|
||||
pass
|
||||
else:
|
||||
prog = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj)).abspath(env)
|
||||
out = open(os.path.join('doc', 'introspected-doxygen.h'), 'w')
|
||||
if subprocess.Popen([prog], stdout=out, env=proc_env).wait():
|
||||
raise SystemExit(1)
|
||||
out.close()
|
||||
|
||||
print "-- Running NS-3 C++ core unit tests..."
|
||||
wutils.run_program('run-tests', env, wutils.get_command_template(env))
|
||||
|
||||
if env['ENABLE_PYTHON_BINDINGS']:
|
||||
print "-- Running NS-3 Python bindings unit tests..."
|
||||
wutils.run_argv([env['PYTHON'], os.path.join("utils", "python-unit-tests.py")],
|
||||
env, proc_env, force_no_valgrind=True)
|
||||
else:
|
||||
print "-- Skipping NS-3 Python bindings unit tests: Python bindings not enabled."
|
||||
"""run the NS-3 unit tests (deprecated in favour of --check option)"""
|
||||
raise Utils.WafError("Please run `./waf --check' instead.")
|
||||
|
||||
|
||||
class print_introspected_doxygen_task(Task.TaskBase):
|
||||
after = 'cc cxx cc_link cxx_link'
|
||||
color = 'BLUE'
|
||||
|
||||
def __init__(self, bld):
|
||||
self.bld = bld
|
||||
super(print_introspected_doxygen_task, self).__init__(generator=self)
|
||||
|
||||
def __str__(self):
|
||||
return 'print-introspected-doxygen\n'
|
||||
|
||||
def runnable_status(self):
|
||||
return Task.RUN_ME
|
||||
|
||||
def run(self):
|
||||
## generate the trace sources list docs
|
||||
env = wutils.bld.env
|
||||
proc_env = wutils.get_proc_env()
|
||||
try:
|
||||
program_obj = wutils.find_program('print-introspected-doxygen', env)
|
||||
except ValueError: # could happen if print-introspected-doxygen is
|
||||
# not built because of waf configure
|
||||
# --enable-modules=xxx
|
||||
pass
|
||||
else:
|
||||
prog = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj)).abspath(env)
|
||||
out = open(os.path.join('..', 'doc', 'introspected-doxygen.h'), 'w')
|
||||
if subprocess.Popen([prog], stdout=out, env=proc_env).wait():
|
||||
raise SystemExit(1)
|
||||
out.close()
|
||||
|
||||
class run_python_unit_tests_task(Task.TaskBase):
|
||||
after = 'cc cxx cc_link cxx_link'
|
||||
color = 'BLUE'
|
||||
|
||||
def __init__(self, bld):
|
||||
self.bld = bld
|
||||
super(run_python_unit_tests_task, self).__init__(generator=self)
|
||||
|
||||
def __str__(self):
|
||||
return 'run-python-unit-tests\n'
|
||||
|
||||
def runnable_status(self):
|
||||
return Task.RUN_ME
|
||||
|
||||
def run(self):
|
||||
proc_env = wutils.get_proc_env()
|
||||
wutils.run_argv([self.bld.env['PYTHON'], os.path.join("..", "utils", "python-unit-tests.py")],
|
||||
self.bld.env, proc_env, force_no_valgrind=True)
|
||||
|
||||
|
||||
class run_a_unit_test_task(Task.TaskBase):
|
||||
after = 'cc cxx cc_link cxx_link'
|
||||
color = 'BLUE'
|
||||
|
||||
def __init__(self, bld, name_of_test):
|
||||
self.bld = bld
|
||||
super(run_a_unit_test_task, self).__init__(generator=self)
|
||||
self.name_of_test = name_of_test
|
||||
try:
|
||||
program_obj = wutils.find_program("run-tests", self.bld.env)
|
||||
except ValueError, ex:
|
||||
raise Utils.WafError(str(ex))
|
||||
program_node = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj))
|
||||
self.program_path = program_node.abspath(self.bld.env)
|
||||
|
||||
def __str__(self):
|
||||
return 'run-unit-test(%s)\n' % self.name_of_test
|
||||
|
||||
def runnable_status(self):
|
||||
return Task.RUN_ME
|
||||
|
||||
def run(self):
|
||||
#print repr([self.program_path, self.name_of_test])
|
||||
try:
|
||||
self.retval = wutils.run_argv([self.program_path, self.name_of_test], self.bld.env)
|
||||
except Utils.WafError:
|
||||
self.retval = 1
|
||||
#print "running test %s: exit with %i" % (self.name_of_test, retval)
|
||||
return 0
|
||||
|
||||
class get_list_of_unit_tests_task(Task.TaskBase):
|
||||
after = 'cc cxx cc_link cxx_link'
|
||||
color = 'BLUE'
|
||||
|
||||
def __init__(self, bld):
|
||||
self.bld = bld
|
||||
super(get_list_of_unit_tests_task, self).__init__(generator=self)
|
||||
self.tests = []
|
||||
|
||||
def __str__(self):
|
||||
return 'get-unit-tests-list\n'
|
||||
|
||||
def runnable_status(self):
|
||||
return Task.RUN_ME
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
program_obj = wutils.find_program("run-tests", self.bld.env)
|
||||
except ValueError, ex:
|
||||
raise Utils.WafError(str(ex))
|
||||
program_node = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj))
|
||||
program_path = program_node.abspath(self.bld.env)
|
||||
proc = subprocess.Popen([program_path, "--ListTests"], stdout=subprocess.PIPE,
|
||||
env=wutils.get_proc_env())
|
||||
self.tests = [l.rstrip() for l in proc.stdout.readlines()]
|
||||
retval = proc.wait()
|
||||
if retval:
|
||||
return retval
|
||||
test_tasks = []
|
||||
for name_of_test in self.tests:
|
||||
test_tasks.append(run_a_unit_test_task(self.bld, name_of_test))
|
||||
collector = collect_unit_test_results_task(self.bld, list(test_tasks))
|
||||
collector.run_after = list(test_tasks)
|
||||
self.more_tasks = [collector] + test_tasks
|
||||
|
||||
|
||||
class collect_unit_test_results_task(Task.TaskBase):
|
||||
after = 'run_a_unit_test_task'
|
||||
color = 'BLUE'
|
||||
|
||||
def __init__(self, bld, test_tasks):
|
||||
self.bld = bld
|
||||
super(collect_unit_test_results_task, self).__init__(generator=self)
|
||||
self.test_tasks = test_tasks
|
||||
|
||||
def __str__(self):
|
||||
return 'collect-unit-tests-results\n'
|
||||
|
||||
def runnable_status(self):
|
||||
for t in self.run_after:
|
||||
if not t.hasrun:
|
||||
return Task.ASK_LATER
|
||||
return Task.RUN_ME
|
||||
|
||||
def run(self):
|
||||
failed = 0
|
||||
for task in self.test_tasks:
|
||||
if task.retval:
|
||||
failed += 1
|
||||
if failed:
|
||||
print "C++ UNIT TESTS: %i tests passed, %i failed." % (len(self.test_tasks) - failed, failed)
|
||||
return 1
|
||||
else:
|
||||
print "C++ UNIT TESTS: all %i tests passed." % (len(self.test_tasks),)
|
||||
return 0
|
||||
|
||||
|
||||
def _run_check(bld):
|
||||
task = get_list_of_unit_tests_task(bld)
|
||||
print_introspected_doxygen_task(bld)
|
||||
if bld.env['ENABLE_PYTHON_BINDINGS']:
|
||||
run_python_unit_tests_task(bld)
|
||||
|
||||
|
||||
def check_shell(bld):
|
||||
|
||||
Reference in New Issue
Block a user