[Ns-developers] Bug 215 Name Container

Mathieu Lacage mathieu.lacage at sophia.inria.fr
Mon Dec 1 11:50:03 PST 2008


On Sun, 2008-11-30 at 19:07 -0800, craigdo at ee.washington.edu wrote:
> Hi All,
> 
> regarding bug 215 (http://www.nsnam.org/bugzilla/show_bug.cgi?id=215) I have
> added a patch that implements a simple bidirectional map of ns3::Object vs.
> std::string to begin to address the name container issue.
> 
> It's really just a simple beginning and is not completely integrated with
> the rest of the system yet, but it does give us a basic naming
> functionality.

Comments below:

> 
> Here are some snippets from csma-one-subet.cc which I taught about names ...
> 
> ---------- Begin Included Code ----------
> 
>   NameList::Add (devices.Get (0), "Node 0/eth0");
>   NameList::Add (devices.Get (1), "Node 1/eth0");
>   NameList::Add (devices.Get (3), "Node 3/eth0");
> 
> [ ... ]
> 
>   ApplicationContainer app = onoff.Install (NameList::GetObjectOfName<Node>
> ("Node 0"));

I would tend to use a shorter method name instead:
NameList::Find<Node> ("Node 0");
Just because it's more convenient and I am in a very lazy mood.

> 
> [ ... ]
> 
>   CsmaHelper::EnablePcap ("csma-one-subnet", "Node 0/eth0");
>   CsmaHelper::EnablePcap ("csma-one-subnet", "Node 1/eth0");
>   CsmaHelper::EnablePcap ("csma-one-subnet", "Node 3/eth0");
> 
> ---------- End Included Code ----------
> 
> To be honest, I'm not sure that this is well-enough thought through to go in
> this release.  One example of an inconsistency is the trace file names.
> They will still come out like "csma-one-subnet-0-0.pcap" when I think they
> really should come out "csma-one-subnet-Node 0-eth0.pcap" or something
> similar.
> 
> Also, there isn't good integration with attributes/tracing at a low level.
> For example, it would be nice to be able to refer to an attribute using the
> name list translation
> 
>   "Node 0/eth0/EncapsulationMode"

The above is not really compatible with the tracing/attribute stuff: '/'
is a reserved character. On the other
hand, /NameList/xxx/EncapsulationMode where xxx is a name in the name
and does not contain any slash is trivial to integrate in the
tracing/config infrastructure later.

> But this isn't implemented nor really thought through.
> 
> What are your thoughts about pushing this into ns-3.3?

The patch attached to bug 215 looks good to me if you add a check
in ::Add to assert if the name contains '/'. I think that it would also
make sense to assert in case we find a duplicate name rather than return
false because there is zero chance anyone will ever write code to check
the return value of ::Add.

Finally,
+      Ptr<Object> object = i->first;
+      i->first = 0;
+    }
The first line looks like something you forgot to remove.

regards,
Mathieu



More information about the Ns-developers mailing list