[Ns-bugs] [Bug 267] overload helpers that take NodeContainers to also take Ptr<Node>

bugzilla-daemon@nsnam-www.ece.gatech.edu bugzilla-daemon at nsnam-www.ece.gatech.edu
Fri Aug 1 08:56:24 PDT 2008


http://www.nsnam.org/bugzilla/show_bug.cgi?id=267





------- Comment #5 from craigdo at ee.washington.edu  2008-08-01 11:56 -------
The section of the tutorial referring to this idiom follows.  The detailed
explanation was removed and will end up in an appendix.

----------

The following lines of code in our example script, first.cc, are used to set up
a UDP echo server application on one of the nodes we have previously created. 

    UdpEchoServerHelper echoServer (9);

    ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
    serverApps.Start (Seconds (1.0));
    serverApps.Stop (Seconds (10.0));

The first line of code in the above snippet declares the UdpEchoServerHelper.
As usual, this isn't the application itself, it is an object used to help us
create the actual applications. One of our conventions is to place required
attributes in the helper constructor. In this case, the helper can't do
anything useful unless it is provided with a port number that the client also
knows about. Rather than just picking one and hoping it all works out, we
require the port number as a parameter to the constructor. The constructor, in
turn, simply does a SetAttribute with the passed value. You can, if desired,
set the "Port" attribute to another value later. 

Similar to many other helper objects, the UdpEchoServerHelper object has an
Install method. It is the execution of this method that actually causes the
underlying echo server application to be instantiated and attached to a node.
Interestingly, the Install method takes a NodeContainter as a parameter just as
the other Install methods we have seen. This is actually what is passed to the
method even though it doesn't look so in this case. There is a C++ implicit
conversion at work here. 


-- 
Configure bugmail: http://www.nsnam.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.


More information about the Ns-bugs mailing list