diff --git a/AUTHORS b/AUTHORS index e2262bcbf..311dc742e 100644 --- a/AUTHORS +++ b/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) diff --git a/bindings/python/ns3_module_common.py b/bindings/python/ns3_module_common.py index a7e510bdf..08e0b76c8 100644 --- a/bindings/python/ns3_module_common.py +++ b/bindings/python/ns3_module_common.py @@ -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::CreateFragment(uint32_t start, uint32_t length) const [member function] cls.add_method('CreateFragment', 'ns3::Ptr< ns3::Packet >', diff --git a/bindings/python/ns3_module_internet_stack.py b/bindings/python/ns3_module_internet_stack.py index f5cda47aa..a2626bc91 100644 --- a/bindings/python/ns3_module_internet_stack.py +++ b/bindings/python/ns3_module_internet_stack.py @@ -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::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::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 p, ns3::Ipv4Header const & header, ns3::Ptr idev, ns3::Callback,ns3::Ptr,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> ucb, ns3::Callback,ns3::Ptr,const ns3::Ipv4Header&,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> mcb, ns3::Callback,const ns3::Ipv4Header&,unsigned int,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty,ns3::empty> lcb, ns3::Callback,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 node) [member function] - cls.add_method('SetNode', - 'void', - [param('ns3::Ptr< ns3::Node >', 'node')]) - ## ipv4-global-routing.h: ns3::Ptr 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')]) diff --git a/doc/build.txt b/doc/build.txt index 984e809d4..d56554d4f 100644 --- a/doc/build.txt +++ b/doc/build.txt @@ -36,7 +36,7 @@ The resulting binaries are placed in build//srcpath. Other waf usages include: - 1. ./waf check + 1. ./waf --check Runs the unit tests 2. ./waf --doxygen diff --git a/doc/main.h b/doc/main.h index 7dba8c51a..ce9d233e0 100644 --- a/doc/main.h +++ b/doc/main.h @@ -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 diff --git a/doc/manual/new-models.texi b/doc/manual/new-models.texi index a73e3e201..71f75c506 100644 --- a/doc/manual/new-models.texi +++ b/doc/manual/new-models.texi @@ -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 diff --git a/doc/release_steps.txt b/doc/release_steps.txt index f4d666be4..d46761fe6 100644 --- a/doc/release_steps.txt +++ b/doc/release_steps.txt @@ -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" diff --git a/doc/tutorial/building-topologies.texi b/doc/tutorial/building-topologies.texi index 17d8156cb..010a55418 100644 --- a/doc/tutorial/building-topologies.texi +++ b/doc/tutorial/building-topologies.texi @@ -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. diff --git a/doc/tutorial/conceptual-overview.texi b/doc/tutorial/conceptual-overview.texi index cb38386bb..aa914c774 100644 --- a/doc/tutorial/conceptual-overview.texi +++ b/doc/tutorial/conceptual-overview.texi @@ -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. diff --git a/doc/tutorial/getting-started.texi b/doc/tutorial/getting-started.texi index a4bc52aac..8b9a49e1d 100644 --- a/doc/tutorial/getting-started.texi +++ b/doc/tutorial/getting-started.texi @@ -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 diff --git a/doc/tutorial/in-process/introduction.texi b/doc/tutorial/in-process/introduction.texi index 17cb4d7c9..58ff959bd 100644 --- a/doc/tutorial/in-process/introduction.texi +++ b/doc/tutorial/in-process/introduction.texi @@ -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 diff --git a/doc/tutorial/introduction.texi b/doc/tutorial/introduction.texi index 299264155..0fa1f05b3 100644 --- a/doc/tutorial/introduction.texi +++ b/doc/tutorial/introduction.texi @@ -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. diff --git a/doc/tutorial/tweaking.texi b/doc/tutorial/tweaking.texi index 8a7ebcbf5..ad25e14ff 100644 --- a/doc/tutorial/tweaking.texi +++ b/doc/tutorial/tweaking.texi @@ -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 @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. diff --git a/src/applications/packet-sink/packet-sink.cc b/src/applications/packet-sink/packet-sink.cc index 3a86f5416..a7e9b6db1 100644 --- a/src/applications/packet-sink/packet-sink.cc +++ b/src/applications/packet-sink/packet-sink.cc @@ -142,8 +142,7 @@ void PacketSink::HandleRead (Ptr 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); } diff --git a/src/applications/v4ping/v4ping.cc b/src/applications/v4ping/v4ping.cc index 9ad780b06..035d4744f 100644 --- a/src/applications/v4ping/v4ping.cc +++ b/src/applications/v4ping/v4ping.cc @@ -87,10 +87,11 @@ V4Ping::Receive (Ptr socket) if (echo.GetSequenceNumber () == (m_seq - 1) && echo.GetIdentifier () == 0) { - Ptr 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 ()) { diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 8bdc63455..ddbf8f800 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -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. ******************************************************/ diff --git a/src/common/buffer.h b/src/common/buffer.h index 4c65518de..3124b8d11 100644 --- a/src/common/buffer.h +++ b/src/common/buffer.h @@ -22,6 +22,7 @@ #include #include +#include #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 (); diff --git a/src/common/packet.cc b/src/common/packet.cc index 7edec23ab..13c024675 100644 --- a/src/common/packet.cc +++ b/src/common/packet.cc @@ -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 { diff --git a/src/common/packet.h b/src/common/packet.h index 90d3a0a73..a272eb2f6 100644 --- a/src/common/packet.h +++ b/src/common/packet.h @@ -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. diff --git a/src/common/pcap-writer.cc b/src/common/pcap-writer.cc index 6cb282727..e2cc36eb5 100644 --- a/src/common/pcap-writer.cc +++ b/src/common/pcap-writer.cc @@ -164,7 +164,7 @@ PcapWriter::WritePacket (Ptr 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 packet, uint16_t chann } // finally, write rest of packet - WriteData (packet->PeekData (), packet->GetSize ()); + packet->CopyData (m_writer, packet->GetSize ()); } diff --git a/src/contrib/wscript b/src/contrib/wscript index 806e433c3..046958dda 100644 --- a/src/contrib/wscript +++ b/src/contrib/wscript @@ -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']) diff --git a/src/core/test.cc b/src/core/test.cc index 6f0a7a7dd..165827a41 100644 --- a/src/core/test.cc +++ b/src/core/test.cc @@ -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); diff --git a/src/core/test.h b/src/core/test.h index 682983744..26caeae9c 100644 --- a/src/core/test.h +++ b/src/core/test.h @@ -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 (); diff --git a/src/core/wscript b/src/core/wscript index 60a63aff5..1c8a5de37 100644 --- a/src/core/wscript +++ b/src/core/wscript @@ -41,7 +41,7 @@ int main () conf.env['ENABLE_THREADING'], " 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') diff --git a/src/devices/bridge/bridge-channel.cc b/src/devices/bridge/bridge-channel.cc index b8b8b6bca..26ec993c9 100644 --- a/src/devices/bridge/bridge-channel.cc +++ b/src/devices/bridge/bridge-channel.cc @@ -29,7 +29,9 @@ TypeId BridgeChannel::GetTypeId (void) { static TypeId tid = TypeId ("ns3::BridgeChannel") - .SetParent (); + .SetParent () + .AddConstructor () + ; return tid; } diff --git a/src/devices/mesh/mesh-wifi-interface-mac.cc b/src/devices/mesh/mesh-wifi-interface-mac.cc index e2d21cad1..30db7fea3 100644 --- a/src/devices/mesh/mesh-wifi-interface-mac.cc +++ b/src/devices/mesh/mesh-wifi-interface-mac.cc @@ -46,12 +46,12 @@ MeshWifiInterfaceMac::GetTypeId () .SetParent () .AddConstructor () .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 () ) diff --git a/src/devices/wifi/mac-low.cc b/src/devices/wifi/mac-low.cc index 838cc31b8..c25958794 100644 --- a/src/devices/wifi/mac-low.cc +++ b/src/devices/wifi/mac-low.cc @@ -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) diff --git a/src/devices/wifi/wifi-net-device.cc b/src/devices/wifi/wifi-net-device.cc index d7dccc85d..2abe6200d 100644 --- a/src/devices/wifi/wifi-net-device.cc +++ b/src/devices/wifi/wifi-net-device.cc @@ -38,6 +38,7 @@ WifiNetDevice::GetTypeId (void) { static TypeId tid = TypeId ("ns3::WifiNetDevice") .SetParent () + .AddConstructor () .AddAttribute ("Channel", "The channel attached to this device", PointerValue (), MakePointerAccessor (&WifiNetDevice::DoGetChannel), diff --git a/src/helper/nqos-wifi-mac-helper.h b/src/helper/nqos-wifi-mac-helper.h index d582e3743..9800b6082 100644 --- a/src/helper/nqos-wifi-mac-helper.h +++ b/src/helper/nqos-wifi-mac-helper.h @@ -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); /** diff --git a/src/internet-stack/icmpv4.cc b/src/internet-stack/icmpv4.cc index b0b2cfec9..53fcffea6 100644 --- a/src/internet-stack/icmpv4.cc +++ b/src/internet-stack/icmpv4.cc @@ -108,7 +108,9 @@ Icmpv4Echo::SetSequenceNumber (uint16_t seq) void Icmpv4Echo::SetData (Ptr 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 -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 (buffer, size); - delete[] buffer; + m_dataSize = start.GetSize () - 4; + start.Read (m_data, m_dataSize); return start.GetSize (); } void diff --git a/src/internet-stack/icmpv4.h b/src/internet-stack/icmpv4.h index f8d224e51..ba69ff7ec 100644 --- a/src/internet-stack/icmpv4.h +++ b/src/internet-stack/icmpv4.h @@ -50,7 +50,7 @@ public: void SetData (Ptr data); uint16_t GetIdentifier (void) const; uint16_t GetSequenceNumber (void) const; - Ptr 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 m_data; + uint8_t m_data[16]; + uint32_t m_dataSize; }; class Icmpv4DestinationUnreachable : public Header diff --git a/src/internet-stack/ipv4-list-routing-impl.cc b/src/internet-stack/ipv4-list-routing-impl.cc index 539f4e976..466bda81f 100644 --- a/src/internet-stack/ipv4-list-routing-impl.cc +++ b/src/internet-stack/ipv4-list-routing-impl.cc @@ -35,6 +35,7 @@ Ipv4ListRoutingImpl::GetTypeId (void) { static TypeId tid = TypeId ("ns3::Ipv4ListRoutingImpl") .SetParent () + .AddConstructor () ; return tid; } diff --git a/src/internet-stack/ipv4-static-routing-impl.cc b/src/internet-stack/ipv4-static-routing-impl.cc index ef15f5337f..65aff1474 100644 --- a/src/internet-stack/ipv4-static-routing-impl.cc +++ b/src/internet-stack/ipv4-static-routing-impl.cc @@ -36,6 +36,7 @@ Ipv4StaticRoutingImpl::GetTypeId (void) { static TypeId tid = TypeId ("ns3::Ipv4StaticRoutingImpl") .SetParent () + .AddConstructor () ; return tid; } diff --git a/src/internet-stack/nsc-tcp-socket-impl.cc b/src/internet-stack/nsc-tcp-socket-impl.cc index 7abd834d0..69f4a68b7 100644 --- a/src/internet-stack/nsc-tcp-socket-impl.cc +++ b/src/internet-stack/nsc-tcp-socket-impl.cc @@ -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 (); diff --git a/src/internet-stack/tcp-test.cc b/src/internet-stack/tcp-test.cc index 1d83e08d8..0eeac0c6b 100644 --- a/src/internet-stack/tcp-test.cc +++ b/src/internet-stack/tcp-test.cc @@ -189,7 +189,7 @@ TcpSocketImplTest::Test1_HandleRecv (Ptr sock) { rxBytes1 += sz; rxPayload = new uint8_t[sz]; - memcpy (rxPayload, p->PeekData(), sz); + p->CopyData (rxPayload, sz); } else { diff --git a/src/internet-stack/wscript b/src/internet-stack/wscript index 16eb5a5fd..c9a4d2f7e 100644 --- a/src/internet-stack/wscript +++ b/src/internet-stack/wscript @@ -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', diff --git a/src/node/ipv4-list-routing.h b/src/node/ipv4-list-routing.h index b6447d4c3..79f49edcf 100644 --- a/src/node/ipv4-list-routing.h +++ b/src/node/ipv4-list-routing.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 diff --git a/src/node/ipv4-route.h b/src/node/ipv4-route.h index 40950a08c..d58f9bb87 100644 --- a/src/node/ipv4-route.h +++ b/src/node/ipv4-route.h @@ -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) */ diff --git a/src/node/ipv4-routing-protocol.h b/src/node/ipv4-routing-protocol.h index 1b950fb39..faeb52985 100644 --- a/src/node/ipv4-routing-protocol.h +++ b/src/node/ipv4-routing-protocol.h @@ -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, diff --git a/src/node/ipv4-routing-table-entry.h b/src/node/ipv4-routing-table-entry.h index 7211e412d..b4597afde 100644 --- a/src/node/ipv4-routing-table-entry.h +++ b/src/node/ipv4-routing-table-entry.h @@ -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 */ diff --git a/src/node/ipv4-static-routing.h b/src/node/ipv4-static-routing.h index 897675dbe..076ed6f05 100644 --- a/src/node/ipv4-static-routing.h +++ b/src/node/ipv4-static-routing.h @@ -44,7 +44,7 @@ class Ipv4RoutingTableEntry; class Ipv4MulticastRoutingTableEntry; /** - * \ingroup ipv4-routing + * \ingroup ipv4Routing * * \brief Static routing protocol for IP version 4 stacks. * diff --git a/src/node/socket.cc b/src/node/socket.cc index e13dcf43e..093c501d7 100644 --- a/src/node/socket.cc +++ b/src/node/socket.cc @@ -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 (); } diff --git a/src/routing/global-routing/global-route-manager-impl.cc b/src/routing/global-routing/global-route-manager-impl.cc index 9587dd441..d311026c9 100644 --- a/src/routing/global-routing/global-route-manager-impl.cc +++ b/src/routing/global-routing/global-route-manager-impl.cc @@ -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"); diff --git a/src/internet-stack/ipv4-global-routing.cc b/src/routing/global-routing/ipv4-global-routing.cc similarity index 100% rename from src/internet-stack/ipv4-global-routing.cc rename to src/routing/global-routing/ipv4-global-routing.cc diff --git a/src/internet-stack/ipv4-global-routing.h b/src/routing/global-routing/ipv4-global-routing.h similarity index 100% rename from src/internet-stack/ipv4-global-routing.h rename to src/routing/global-routing/ipv4-global-routing.h diff --git a/src/routing/global-routing/wscript b/src/routing/global-routing/wscript index 483e5b5d0..22c62947c 100644 --- a/src/routing/global-routing/wscript +++ b/src/routing/global-routing/wscript @@ -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' diff --git a/src/simulator/wscript b/src/simulator/wscript index a14cf2480..505b3b264 100644 --- a/src/simulator/wscript +++ b/src/simulator/wscript @@ -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", diff --git a/utils/run-tests.cc b/utils/run-tests.cc index 0e1d3ef91..2533b8806 100644 --- a/utils/run-tests.cc +++ b/utils/run-tests.cc @@ -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; } + diff --git a/waf b/waf index fc98af278..ca4d42c18 100755 Binary files a/waf and b/waf differ diff --git a/wscript b/wscript index 43452ed41..e0dda6565 100644 --- a/wscript +++ b/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):