[Ns-developers] ns-3-nsc sysctl attribute support
Florian Westphal
fw at strlen.de
Mon Jul 7 11:52:51 PDT 2008
Mathieu Lacage <mathieu.lacage at sophia.inria.fr> wrote:
> > int sysctl_getnum(size_t idx, char *name, size_t len);
> >
> > It will return -1 if the given index is out of range, so one can
> > iterate through the list, e.g.:
> > char buf[256]
> > for (i=0; sysctl_getnum(i, buf, sizeof(buf)) > 0 ;i++)
> > puts(buf);
>
> ok. I would have expected to be able to query for the number of sysctls
> but, I suspect that this kind of API aligns with kernel-API style,
> right ?
It aligns with my personal taste; i generally try to come up with a
pragmatic/minimalistic API.
But if all that you need is the ability to query the number of sysctls,
i have no problem adding it...
> Ok. Clearly, the code you showed below won't work, mostly because
> mutating the TypeId of an object after it was created does not work
> unless you override ObjectBase::GetInstanceTypeId, and even if you do
> this, it is not trivial to get it right mostly because the ns3 object
> system was never designed to allow mutating object types.
>
> [code elided]
>
> Here is an untested but potentially working solution.
First of all, thank you very much for working on this.
> First, we need an attribute accessor which can remember the name of the
> attribute it is accessing to pass it down to Nsc:
[..]
> Then, you need an object which represents the underlying nsc stack,
> which is aggregated to a Node object, and which provides access to the
> sysctls of the nsc stack through attributes.
>
> class Ns3NscStack : public Object
I tried this before, this results in:
Object::AggregateObject(): Multiple aggregation of objects of type ns3::Object
Command ['/home/fw/hg/ns-3-nsc/build/debug/examples/tcp-large-transfer'] exited with code -5
The code leading up to this looks like this:
Ptr<Ns3NscStack> nscStack = Create<Ns3NscStack> ();
nscStack->SetStack (m_nscStack);
node->AggregateObject (nscStack);
> // Now, we register a new TypeId for this stack which will look
> like a subclass of the Ns3NscStack. The class Ns3NscStack is effectively
> mutating into a subclass of itself from the point of view of the TypeId
> system _here_
> tid = TypeId (name);
> tid.SetParent<Ns3NscStack> ();
> char buf[256]
I get a compile error here:
debug/ns3/type-id.h: In member function `ns3::TypeId ns3::TypeId::SetParent() [with T = ns3::Ns3NscStack]':
../src/internet-stack/nsc-sysctl.cc:90: instantiated from here
debug/ns3/type-id.h:404: error: cannot call member function `ns3::TypeId ns3::Ns3NscStack::GetTypeId()' without object
Thanks again,
Florian
More information about the Ns-developers
mailing list