[Ns-developers] [ns3] topology API

Mathieu Lacage mathieu.lacage at sophia.inria.fr
Tue Jan 15 08:38:21 PST 2008


On Tue, 2008-01-15 at 13:52 +0000, Gustavo Carneiro wrote:

>         // setup the geographical applications.
>         c = NodeContainer ();
>         c.Add (mobility.GetByBoundingBox (NodeList::Begin (),
>         NodeList::End (),
>         BoundingBox (0.0, 0.0, 100.0, 100.0)));
>         application.AddOnOff (c, ...);
> 
> In the above example shouldnd't "NodeList::Begin (), NodeList::End ()"
> be "c.Begin(), c.End()" ?  Surely you want to iterate over nodes of
> the containter, not all nodes... 

Well, joseph's use-case was that he wanted to geographically partition
_all_ nodes.

> 
> This example seems a bit inconsistent.  On one hand you have
> container.Add (mobility.GetByBoundingBox (...)), on the other hand
> application.AddOnOff(container, ...), two different styles... which
> one is it?

I am not really sure I understand this comment: I fail to see what is
different between these two styles:
  - GetByBoundingBox returns a NodeContainer and we invoke
NodeContainer::Add (const NodeContainer & c) to add it to the original
container.
  - ApplicationHelper::AddOnOff does just like every other helper: its
first argument is a node container.

[snip]

> I see your proposal, but I find it is not as simple as it could be.
> This expression:
> 
>   mobility.GetByBoundingBox (NodeList::Begin (), NodeList::End
> (),BoundingBox (0.0, 0.0, 100.0, 100.0))
> 
> what does it return?  A list of mobility models, or...?  I think it is

It returns a Node container.

>  simpler to just add a Container.ForEach (Callback<void, Container&,
> Node&> callback) API, and let the user do whatever he/she likes. 

Of course, you want to be able to iterate over the node list if you need
it. However, GetByBoundingBox is just a conveniance function.

> IMHO the best way to manage complexity is to _reduce_ the number of
> API entry points, not increase it like it seems to be happening here.
> The way to reduce API size is to find the optimum tradeoff between API
> call simplicity and flexibility. 

Sure. The goal, here, however, is to provide syntactical conveniance. If
you want "simplicity", you can use the low-level API.

> 
> We should also think of Python scripting.  Some things, like callbacks
> and for loops, appear cumbersome  from C++, but are trivial and easy
> to learn from Python.

I fully agree but we are trying to build a C++ API here.

> Finally I prefer the naming NodeGroup rather than NodeContainer
> because container sounds like simulating a physical entity that
> actually contains nodes, while group is obviously a purely logical
> entity. 

I don't really agree but I don't feel very strongly about it.

Mathieu


More information about the Ns-developers mailing list