Changing nsc-related variables from ns-3 simulation scripts

70 views
Skip to first unread message

Chris Facchini

unread,
Nov 12, 2010, 4:28:50 AM11/12/10
to ns-3-users
Dear all,

I'm currently working with the Network Simulation Cradle (nsc).

I'd like to change some parameters of a protocol (say, for instance,
'beta' in tcp_cubic.c) and I'd like to do it from within ns-3. First
of all, is it possible?

A workaround I've thought of is to modify the parameter directly in
tcp_cubic.c and rebuild the library each time. However, besides being
time consuming, this would also be awkward. In fact, my ultimate
objective would be to change the parameter _in the middle of_ a
simulation.

Another solution (yet maybe unfeasible) would be to have the source
code in tcp_cubic.c read the parameter somewhere else (the most naive
solution is to read it from a file). What about it?

Similar in spirit, we could also think of using sysctl variables. The
downside is that sysctl seems not to be able to set variables once the
simulation has started (noticed some time ago, here:
http://groups.google.com/group/ns-3-users/browse_thread/thread/812ff82c4a76a43f
).

Any hint is most welcome!

Best,
Chris

Tom Henderson

unread,
Nov 15, 2010, 12:29:05 AM11/15/10
to ns-3-...@googlegroups.com

Have you looked at set_var() in sim_interface.h? We don't have any code
in ns-3 that I'm aware of that uses get_var and set_var, but they might
be the generic way to try to do what you want in NSC (don't know whether
NSC stacks need to be modified to provide hooks to the desired variables).

- Tom

Chris Facchini

unread,
Nov 16, 2010, 1:08:39 PM11/16/10
to ns-3-users
On Nov 15, 6:29 am, Tom Henderson <t...@tomh.org> wrote:
> Have you looked at set_var() in sim_interface.h?  We don't have any code
> in ns-3 that I'm aware of that uses get_var and set_var, but they might
> be the generic way to try to do what you want in NSC (don't know whether
> NSC stacks need to be modified to provide hooks to the desired variables).

Thanks for the pointer, Tom.
I'll give a look at it!

Best,
Chris

Chris Facchini

unread,
Nov 19, 2010, 10:42:13 AM11/19/10
to ns-3-users
On Nov 15, 6:29 am, Tom Henderson wrote:
> Have you looked at set_var() in sim_interface.h?

set_var seems actually a good way to change those variables.
As of now, though, I'm focusing on get_var(), basically because it's
already implemented (differently from set_var()).

So far I've understood that:
- get_var() and set_var() are virtual methods of the INetStack struct
- the LinuxStack class (<nsc>/<linux>/nsc/sim_support.cpp) inherits
from INetStack and redefines get_var()
- LinuxStack::get_var() calls nsc_get_tcp_var() passing also the
pointer to a TCP socket as an argument (and if I got it right, this
also means there's a 1:1 mapping between LinuxStack objects and TCP
sockets)
- nsc_get_tcp_var() (<nsc>/<linux>/nsc/support.c) can potentially get
hold of all the variables that belong to the tcp_sock struct (<nsc>/
<linux>/include/linux/tcp.h) but probably not (or, at least, not
straightforwardly) of the variables defined in a "particular TCP
version" (e.g., cubic, vegas, etc.), which instead are common for *all
the sockets*.

The question is:
how can I get hold of LinuxStack?
Since it doesn't inherit from the ns3::Object class, I cannot call
GetObject<>(). Besides, since there seems to be a LinuxStack for each
TCP socket, I couldn't probably do that anyway (but here things start
to get hazy for me, so I may be completely wrong).

The fact that get_var() can apparently be used to reach the parameters
of each single socket, but not the parameters common to all the
sockets opens another question:
is there a way to reach such variables (e.g., those in cubic_tcp.c
but also in <nsc>/<linux>/include/net/tcp.h)?
(sysctl has been ruled out, because it cannot be used for dynamic
reconfiguration:
http://groups.google.com/group/ns-3-users/tree/browse_frm/thread/812ff82c4a76a43f/fa77f4d8842624f9?rnum=1&_done=%2Fgroup%2Fns-3-users%2Fbrowse_frm%2Fthread%2F812ff82c4a76a43f%2Fcaa93f040e570b7e%3Ftvc%3D1%26#doc_caa93f040e570b7e
)

Best,
Chris

Chris Facchini

unread,
Dec 16, 2010, 11:11:34 AM12/16/10
to ns-3-users
Here's an update on the problem.

I managed to reach the INetStack of a node.
As a consequence, I have access to INetStack::get_var () and
INetStack::set_var ().

However, I have to reach said methods in a derived class, say
LinuxStack. Thus, I first need to cast INetStack to LinuxStack.
The problem is, the LinuxStack class is defined in nsc-0.5.2/linux*/
nsc/sim_support.cpp and I have no idea whatsoever how to include it in
my simulation script.

Does anybody have some suggestions?

TIA,
Chris
> reconfiguration:http://groups.google.com/group/ns-3-users/tree/browse_frm/thread/812f...
> )
>
> Best,
> Chris

Chris Facchini

unread,
Dec 20, 2010, 4:55:54 AM12/20/10
to ns-3-users
No cast is needed.
Turned out, I was modifying get_var() in src/internet-stack/
sim_interface.h
but the *right* function to modify is get_var() in nsc-0.5.2/sim/
sim_interface.h

Chris
Reply all
Reply to author
Forward
0 new messages