[Ns-developers] Bug 215 (Name List)

craigdo@ee.washington.edu craigdo at ee.washington.edu
Tue Jan 20 01:17:02 PST 2009

Hi All,

I've been playing with an object naming service for ns-3.4 to finally put
bug 215 out of its misery.  I have something that seems to be coming
together nicely, so I want to share the direction I'm headed in and see if
there are any comments.

The quickest intro seems to be by example.  I have an example file in the
repo http://code.nsnam.org/craigdo/ns-3-215 that shows how to use the naming
facility.  It's based on the trusty udp-echo example and is called names.cc
if you want to take a look.

Here's how you name objects in the root of the name space

  NodeContainer n;
  n.Create (4);

  // We're going to use the zeroth node in the container as the client, and
  // the first node as the server.  Add some "human readable" names for
  // nodes.  The first parameter specifies the root of the "/Names" name
  // as the destination, so these will go into the name system as
  // and "/Names/server".
  Names::Name ("/Names", "client", n.Get (0));
  Names::Name ("/Names", "server", n.Get (1));

Tom wanted to have multiple "eth0" names in the system, so here's how you
would name the devices associated with the client and server above as both
being "eth0."

  NetDeviceContainer d = csma.Install (n);

  // Add some human readable names for the devices we'll be interested in.
  // We add the names to the name space "under" the nodes we created above.
  // This has the effect of making "/Names/client/eth0" and
  // Note that the first parameter must reference a previously named object,
  // and we have, in fact, already named objects "/Names/client" and
  // "/Names/server"
  Names::Name ("/Names/client", "eth0", d.Get (0));
  Names::Name ("/Names/server", "eth0", d.Get (1));

You can look up named objects, of course.  Here I install the server app on
the node defined by its name and ditto for the client.

  ApplicationContainer apps = server.Install (Names::Find<Node>
  apps = client.Install (Names::Find<Node> ("/Names/client"));

Of course, this is all integrated into the Config system, so you can mix and
match named objects and attributes in your paths:

  Config::Connect ("/Names/client/eth0/Rx", MakeCallback (&RxEvent));

This is all modeled as a kind of a run-time analog of the Attribute system.
For example, in the call

  Names::Name ("/Names/server", "eth0", d.Get (1));

you can think of it as dynamically adding an Object pointer attribute named
"eth0" to the Object named "/Names/server" and setting the attribute to the
specified value (a Ptr<Object> returned from the Get (1).

See the files src/core/object-names.{h.cc} in the repo mentioned above for
details.  The changes required to hook the config path are trivial given the



-- Craig

More information about the Ns-developers mailing list