How to get the init link parameters using c++?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get the init link parameters using c++?

王刚-2


Hi,I want to do some simulation about qos routing,and in c++ I need to know the link bandwidth and link delay,which is set in tcl topology script.
For example,

set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n1 1.5Mb 10ms DropTail
$ns duplex-link $n1 $n2 1.6Mb 10ms DropTail
$ns duplex-link $n1 $n3 1.7Mb 10ms DropTail

my question is that in c++ ,how to get the bandwidth and delay of link{(n0,n1),(n1,n2),(n1,n3)}.

Any advice will be appriciated.

Best wishes!

                        Sincerely
                        Gang Wang

Reply | Threaded
Open this post in threaded view
|

Re: How to get the init link parameters using c++?

王刚-2


Brad,
    Thank you very much!

    By searching in the archive, I know the bandwidth and delay of link are stored in a array,i.e. link_ array.But I don't know how to get this array.
    What I really mean is to get the link delay and bandwidth in c++ program,not in tcl.
A compromise methord ,I think, is to call tcl command in c++ program.However this may cause inefficient.
For example:

tcl.evalc("Simulator set NumberInterfaces_");
tcl.evalc("set a [[Simulator link $n0 $n1] link]");
tcl.evalc("$a set bandwidth_");
char *mybw = tcl.result();
tcl.evalc("$a set delay_");
char *mydelay = tcl.result();

My simulation need to read the link parameters frequently.We know that frequent switching between c++ and tcl are inefficient.
I wonder if there is a methord to get the link_ array in c++ program,not in tcl.
Can we call the link_ array directly,e.g. link_(sid,did) ?


Wish for your help,thank you in advance!

                                                Sincerely
                                                Gang Wang
----- Original Message -----
From: "brad montgomery" <[hidden email]>
To: "忘8制" <[hidden email]>
Sent: Monday, July 31, 2006 9:35 PM
Subject: Re: [ns] How to get the init link parameters using c++?


Gang,

I'm still relatively new to ns, but what I've done to pass Tcl values to C++
is write a command (in C++) for my Agent that can be called from Tcl. For
example, if you had an agent called MyAgent, you could do something like
this:

int MyAgent::command(int argc, const char*const* argv) {
   if (argc == 3) {
      if (strcmp(argv[1], "get-bw-and-delay") == 0) {
         bw = argv[2];    // bw would be declared in myagent.h
         delay = argv[3]; // delay would be declared in myagent.h
         return(TCL_OK);
      }
} // end MyAgent

Then, from Tcl, the instance of your MyAgent class could call the
get-bw-and-delay function:

$myagent get-bw-and-delay 1.5 10

You may have to do some type-checking, but that's the basic idea.

Hope it helps.
Brad

On 4/1/06 2:20 AM, "王刚" <[hidden email]> wrote:

>
> Hi,I want to do some simulation about qos routing,and in c++ I need to know
> the link bandwidth and link delay,which is set in tcl topology script.
> For example,
>
> set n0 [$ns node]
> set n1 [$ns node]
> set n2 [$ns node]
> set n3 [$ns node]
> $ns duplex-link $n0 $n1 1.5Mb 10ms DropTail
> $ns duplex-link $n1 $n2 1.6Mb 10ms DropTail
> $ns duplex-link $n1 $n3 1.7Mb 10ms DropTail
>
> my question is that in c++ ,how to get the bandwidth and delay of
> link{(n0,n1),(n1,n2),(n1,n3)}.
>
> Any advice will be appriciated.
>
> Best wishes!
>
>                         Sincerely
>                         Gang Wang
>