Re: [ns] How to set node frequency in C++ ?

2011-11-18 Thread Su Jinzhao

Hi:

As we know, before creating nodes in tcl script, we need to configure them
with various options like -macType -ifqType -phyType -channel and so on.  I
just want to know that after creating these nodes in tcl script, I want to
change some nodes frequency in C++ dynamically, I tried the following code
but failed:

Tcl& tcl = Tcl::instance();
tcl.evalf("$opt(netif) set freq_ newFreq);
if(tcl.result() != TCL_OK)
   cout << "set new freq failure." << endl;

So please help me what else should I do to make the change take effect.
Call node-config again or what else ?

Any suggestions will be appreciated, Thanks.


2011/11/16 苏金钊 

> The script is in tcl,while what I want is to implement it in c++.
>
>
>
>  原始邮件 
> 发件人:Mohamed Ibrahim Salman 
> 时间:2011-11-16 19:35
> 收件人:Su Jinzhao 
> 主题:Re: [ns] How to set node frequency in C++ ?
>
>  I think that script   "adhoc_tcp.tcl"  will be self explained
>
> *
> *
>
> --
> *From:* Su Jinzhao 
> *To:* Mohamed Ibrahim Salman 
> *Sent:* Wednesday, November 16, 2011 11:25 AM
> *Subject:* Re: [ns] How to set node frequency in C++ ?
>
> Thank you for you reply.
>
> I looked through what you suggest in samples folder of dei80211mr, and I
> am not sure whether I completely understand what you mean. I want to
> explain more clearly about what I want to you first:
>
>   Each node of my simulation network is configured with one interface and
> one channel, initially, all nodes work on the control channel. While
> running my mac protocol, I need to switch working frequency of some users
> to another channel with new center frequency in C++, instead of changing it
> in .tcl script file.
>
>  I have tried code like this:
>  Tcl& tcl = Tcl::instance
>  tcl.eval("$opt(netif) set freq_ newFreq");
>  if(tcl.result() != TCL_OK)
>  cout << "set freq error!" << endl;
>
>But I failed, here $opt(netif) is node interface variable defined in
> .tcl file, so is there any more suggestion or advice.
>
>  Thank you very much.
>
>
> On Wed, Nov 16, 2011 at 6:12 PM, Mohamed Ibrahim Salman <
> mohammad_w2...@yahoo.com> wrote:
>
> Hi,
> I think the package dei80211mr will benefit you it's already exist in ns-2
> all you need is to load the library and you can find samples in "sample"
> folder.
>
> good luck
>
>
> *
> *
>
> ------
> *From:* Su Jinzhao 
> *To:* ns-users@ISI.EDU
> *Sent:* Wednesday, November 16, 2011 2:38 AM
> *Subject:* Re: [ns] How to set node frequency in C++ ?
>
>
>
> Is there anybody kind to help me? waiting for your help...
>
> On Tue, Nov 15, 2011 at 9:06 AM, Su Jinzhao  wrote:
>
> > Hi All,
> >
> >  There is only one interface in my simulation network, I want to
> > switch some nodes frequency to another channel with new center frequency
> in
> > C++, my code snippet is like this:
> >
> >  Tcl& tcl = Tcl::instance();
> >tcl.evalf("$opt(netif) set freq_ %f",v[i].mid_freq);
> >        if(tcl.result() != TCL_OK)
> >  cout << "set freq error!" << endl;
> >
> >  Here the variable $opt(netif) is defined in my .tcl file, and the
> > result is print out "set freq error!", So How to set node frequency in
> C++
> > ? any suggestions is appreciated.
> >
> > --
> > Su Jinzhao(苏金钊)
> >
>
>
>
> --
> Su Jinzhao(苏金钊)
>
>
>
>
>
> --
> Su Jinzhao(苏金钊)
>
>
>


-- 
Su Jinzhao(苏金钊)


[ns] how to switch to a new frequency

2011-11-15 Thread Su Jinzhao

I encountered the same problem, is there anyone can help us? Thanks in
advance.

-- 
Su Jinzhao(苏金钊)


Re: [ns] How to set node frequency in C++ ?

2011-11-15 Thread Su Jinzhao

Is there anybody kind to help me? waiting for your help...

On Tue, Nov 15, 2011 at 9:06 AM, Su Jinzhao  wrote:

> Hi All,
>
>   There is only one interface in my simulation network, I want to
> switch some nodes frequency to another channel with new center frequency in
> C++, my code snippet is like this:
>
>  Tcl& tcl = Tcl::instance();
>tcl.evalf("$opt(netif) set freq_ %f",v[i].mid_freq);
>if(tcl.result() != TCL_OK)
>  cout << "set freq error!" << endl;
>
>   Here the variable $opt(netif) is defined in my .tcl file, and the
> result is print out "set freq error!", So How to set node frequency in C++
> ? any suggestions is appreciated.
>
> --
> Su Jinzhao(苏金钊)
>



-- 
Su Jinzhao(苏金钊)


[ns] How to set node frequency in C++ ?

2011-11-14 Thread Su Jinzhao

Hi All,

  There is only one interface in my simulation network, I want to
switch some nodes frequency to another channel with new center frequency in
C++, my code snippet is like this:

 Tcl& tcl = Tcl::instance();
   tcl.evalf("$opt(netif) set freq_ %f",v[i].mid_freq);
   if(tcl.result() != TCL_OK)
 cout << "set freq error!" << endl;

  Here the variable $opt(netif) is defined in my .tcl file, and the
result is print out "set freq error!", So How to set node frequency in C++
? any suggestions is appreciated.

-- 
Su Jinzhao(苏金钊)


[ns] Problem with timer and scheduler

2011-10-12 Thread Su Jinzhao

Hi, ALL.

I have two questions:

1. I start a timer in my program, after it starts, the scheduler doesn't
call the corresponding expire function. My timer starts by calling
sched(double time), the prompted message is :

   ns: scheduler going backwards in time from 0.500056 to 0.00.


I logged the uid_ of each event, the last message shows that the uid_ in
dispatch function of my timer becomes to 0: dispatch: uid_ = 0, t = 0

However, the uid_ of any event should not less than 1, which is defined
scheduler.cc: scheduler_uid_t Scheduler::uid_ = 1; and increased after
inserting new events.


2.  No matter I run my tcl file or wireless-simple-mac.tcl, the log file
looks both like this:

_sched: uid_ = 13, delay =
-26815615859885194199148049996411692254958731641184786755447122887443528060147093953603748596333806855380063716372972101707507765623893139892867298012168192.00,
time_ =
26815622157316114716836864794584393907134232303237611718236021617252959710777447636303506412841121867287875011897335326771847183507644871101570470356451328.00

the delay and time values seems so strange, but the log in dispatch function
is right : dispatch-2: uid_ = 13, t = 0.500055

So what's the reason ?

Thanks, any suggestions will be appreciated.

-- 
Su Jinzhao(苏金钊)


[ns] Fwd: NS2 stops simulation voluntarily.

2011-10-11 Thread Su Jinzhao

-- Forwarded message --
From: Su Jinzhao 
Date: Tue, Oct 11, 2011 at 7:15 PM
Subject: Re: [ns] NS2 stops simulation voluntarily.
To: rajiv chechi 


Thank you for you reply.

My simulation duration defined in tcl is 20s, However, it quits after about
less 3 second, and it writes nothing to my trace and nam file. I have just
checked that my tcl file should be OK, because it runs normally if I use the
MAC Simple which is supplied in NS2 with the same tcl file.

But I don't know what's wrong with my own mac implementation file, the log
file just showed me that it quits at about 3 second. Could you give me some
hints or introduce me some useful debug tools, I tried KDevelop, but it
seems helpless to debug this multiple processes program. Now, my debug is
just log the execution process.

On Tue, Oct 11, 2011 at 6:30 PM, rajiv chechi  wrote:

> hi dear
> ur simulation is working properly.
>
> it means simulation is over and u need to modify according to u.
> go to ur trace file nad nam file to check the results details
>
>
> Rajiv Chechi
> *Associate Professor and Head
> *Department of Electroncis & Communication Engg.
> Haryana college of technology & managment,kaithal,
> haryana(india)-136027
> mob-9896739386
> ph-280101-*214(office)
> Fax-01746-280711
> rajivche...@gmail.com
> rajivche...@facebook.com
>
>
>


-- 
Su Jinzhao(苏金钊)



-- 
Su Jinzhao(苏金钊)


[ns] NS2 stops simulation voluntarily.

2011-10-10 Thread Su Jinzhao

Hi All,

I am trying to do some simulation with NS2.34 on Ubuntu10.04, the
simulation duration I defined in the tcl file is 20s, However, it stops
after simulating about less than 3 seconds, then it quits after printing
messages like this:

INITIALIZE THE LIST xListHead
channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
highestAntennaZ_ = 1.5,  distCST_ = 689.6
SORTING LISTS ...DONE!

Could anyone be kind to tell me the possible reasons? thanks..

-- 
Su Jinzhao(苏金钊)


[ns] Questions on SORTING LISTS ...DONE!

2011-10-09 Thread Su Jinzhao

Hi,ALL.

 I am using ns-2.34 on Ubuntu10.04 to do some simulation on my own
mac protocol, after I run my tcl file, it prompted that:

 channel.cc:sendUp - Calc highestAntennaZ_ and distCST_
 highestAntennaZ_ = 1.5,  distCST_ = 689.6
 SORTING LISTS ...DONE!

  then it quits, everything seems normally, however, my timer can't
expire after I started.

  I searched on the internet(
http://www.baisi.net/thread-37834-1-1.html), it seems that this is a bug of
NS2, which is in relation with seed value while generating traffic with
cbrgen tool, is this right ? anyone who had encountered this problem please
help me, and any suggestions will be appreciated.

 Waiting for your reply and thank you very much!

-- 
Su Jinzhao(苏金钊)


[ns] What does member function "getMac" of Node/MobileNode mean ?

2011-09-23 Thread Su Jinzhao

Hi, all.

   I noticed that there is a "getMac" function while creating and
initializing wireless node, like the following code block:


for {set i 0} {$i < $opt(nn) } {incr i} {
  set node_($i) [$ns_ node]
  $node_($i) random-motion 0  ;# disable
random motion
set mac_($i) [$node_($i) getMac 0]

$mac_($i) set dataRate_ 54Mb
$mac_($i) set basicRate_ 24Mb
$mac_($i) set RTSThreshold_ 3000

$node_($i) set X_ 0.0
$node_($i) set Y_ 0.0
$node_($i) set Z_ 0.0
  }

and I looked up the function definition in ns-mobilenode.tcl file:

Node/MobileNode instproc getMac {param0} {
   $self instvar mac_
   return $mac_($param0)
 }

This seems nothing strange, so I want to know what's the purpose of command
"set mac_($i) [$node_($i) getMac 0]", I think that we should not set all
nodes mac address to be zero.

Thanks, any suggestions will be appreciated.
-- 
Su Jinzhao(苏金钊)


Re: [ns] Questions on difference about node position in nam file and those accessed in C++

2011-09-10 Thread Su Jinzhao

Hi All,
Thank Aslinda for his(her) reply.

I noticed that the argument type of function get_node_by_address() is
nsaddr_t,  which is defined:
  typedef int32_t nsaddr_t;
so I don't think that I passed a value "1" to the function is a problem.

 In fact, I defined a topology composed by 11 nodes in .tcl script file,
I just want to make a try how to access node coordination in C++, so pass
whatever value between 0-10 is OK. By the way, I want to know that is it
necessary that my Node class defined in my own C++ file has to inherit from
class Node(in ns-2.34/common/node.h) or MobileNode(in
ns-2.34/common/mobilenode.h) ?

 Could anyone be kind enough to tell the generic procedure of accessing
node coordination in C++ ?

Thank you very much and any suggestion will be appreciated!


On Sun, Sep 11, 2011 at 4:52 AM, Aslinda Hassan wrote:

> Hi..
>
> First of all, why did you put value 1 in the function
> get_node_by_address()? Is 1 is one of your mobilenode? If not, then you need
> to replace value 1 with a mobile node's address.  If you check aodv,cc for
> example, in AODV constructor, you could see that index is referring to
> node's address.
>
> At any rate, I have some experience in using methods in both links.
>  Although I did not receive the same problem as yours, I did encounter
> segmentation fault error when using getLoc() function.  My code managed to
> run smoothly when using method in the second link.
>
> Good luck
> Aslinda Hassan
> Computer Engineering Research Lab
> Faculty of Engineering and Applied Science
> Memorial University of Newfoundland
>
>
>
> -Original Message-
> From: ns-users-boun...@isi.edu [mailto:ns-users-boun...@isi.edu] On Behalf
> Of Su Jinzhao
> Sent: Saturday, September 10, 2011 11:58 AM
> To: ns-users@ISI.EDU
> Subject: [ns] Questions on difference about node position in nam file and
> those accessed in C++
>
>
> Hello, friends.
>
> I want to access node coordinates in C++ and node coordinates are initially
> defined in Otcl.
>
> I referenced these two articles on accessing node coordinates in C++:
>
>
> http://getch.wordpress.com/2011/02/10/finding-node-positionvelocity-and-speed-in-ns2-34/
>
>
> http://getch.wordpress.com/2011/02/08/obtaining-node-position-and-energy-dynamically-in-ns2/
>
> my .cc file is like this:
> double x,y,z;
> MobileNode *iNode = (MobileNode*)(Node::get_node_by_address(1));
> iNode->getLoc(&x,&y,&z);
>
>cout << "node1:" << x << " " << y << " " << z << endl;
>
>  And my tcl script is defined like this:
>
>set val(nn)11 ;#num of nodes
>set val(xLimit)100
>set val(yLimit)100
>
>for {set i 0} {$i < $val(nn)} {incr i} {
>set node_($i) [$ns node]
>$node_($i) set X_ [expr {$val(xLimit)*rand()}]
>$node_($i) set Y_ [expr {$val(yLimit)*rand()}]
>$node_($i) set Z_ 0.0
> }
>
>I expect that coordinates of node_(1) defined in my tcl script should be
> print out, however, the result is:
>node1:7.62437e-316 7.62415e-316 1.3793e-312
>
> So I am curious that why do these coordinates so small, is there
> anything wrong in my code?(I also searched the NS mail list, the code
> snippet is similar)
>
>Here is the part of coordinates in the nam trace file:
>n -t * -a 8 -s 8 -S UP -v circle -c black -i black -x 20.682385433783001
> -y 8.8519855909291589 -Z 0.0
>n -t * -a 4 -s 4 -S UP -v circle -c black -i black -x 69.835971468051881
> -y 33.172463547984357 -Z 0.0
>n -t * -a 0 -s 0 -S UP -v circle -c black -i black -x 84.052622403974013
> -y 72.424743591074247 -Z 0.0
>n -t * -a 10 -s 10 -S UP -v circle -c black -i black -x
> 65.31614762047127 -y 68.493057260519379 -Z 0.0
>n -t * -a 9 -s 9 -S UP -v circle -c black -i black -x 75.321826746371485
> -y 33.942126265700033 -Z 0.0
>n -t * -a 5 -s 5 -S UP -v circle -c black -i black -x 29.594850973037467
> -y 0.66030384072116755 -Z 0.0
>n -t * -a 1 -s 1 -S UP -v circle -c black -i black -x 42.665535184864666
> -y 79.649852020502948 -Z 0.0
>n -t * -a 6 -s 6 -S UP -v circle -c black -i black -x 97.726651000663011
> -y 91.823368143208029 -Z 0.0
>n -t * -a 2 -s 2 -S UP -v circle -c black -i black -x 75.062908593128867
> -y 82.3047247167233 -Z 0.0
>n -t * -a 7 -s 7 -S UP -v circle -c black -i black -x 75.348382897371607
> -y 80.271356124557258 -Z 0.0
>n -t * -a 3 -s 3 -S UP -v circle -c black -i black -x 95.508313968548691
> -y 8.232869397957284 -Z 0.0
>
>So I want to know that why does the coordinates accessed by
> get_node_by_address() function is not the same as those in nam trace file
> or in the nam GUI ?
>
> Thank you very much, any suggestions is appreciated.
>
> --
> Su Jinzhao(苏金钊)
>
>
> This electronic communication is governed by the terms and conditions at
> http://www.mun.ca/cc/policies/electronic_communications_disclaimer_2011.php
>



-- 
Su Jinzhao(苏金钊)


[ns] Questions on difference about node position in nam file and those accessed in C++

2011-09-10 Thread Su Jinzhao

Hello, friends.

I want to access node coordinates in C++ and node coordinates are initially
defined in Otcl.

 I referenced these two articles on accessing node coordinates in C++:

http://getch.wordpress.com/2011/02/10/finding-node-positionvelocity-and-speed-in-ns2-34/

http://getch.wordpress.com/2011/02/08/obtaining-node-position-and-energy-dynamically-in-ns2/

 my .cc file is like this:
 double x,y,z;
 MobileNode *iNode = (MobileNode*)(Node::get_node_by_address(1));
 iNode->getLoc(&x,&y,&z);

cout << "node1:" << x << " " << y << " " << z << endl;

  And my tcl script is defined like this:

set val(nn)11 ;#num of nodes
set val(xLimit)100
set val(yLimit)100

for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
$node_($i) set X_ [expr {$val(xLimit)*rand()}]
$node_($i) set Y_ [expr {$val(yLimit)*rand()}]
$node_($i) set Z_ 0.0
}

I expect that coordinates of node_(1) defined in my tcl script should be
print out, however, the result is:
node1:7.62437e-316 7.62415e-316 1.3793e-312

 So I am curious that why do these coordinates so small, is there
anything wrong in my code?(I also searched the NS mail list, the code
snippet is similar)

Here is the part of coordinates in the nam trace file:
n -t * -a 8 -s 8 -S UP -v circle -c black -i black -x 20.682385433783001
-y 8.8519855909291589 -Z 0.0
n -t * -a 4 -s 4 -S UP -v circle -c black -i black -x 69.835971468051881
-y 33.172463547984357 -Z 0.0
n -t * -a 0 -s 0 -S UP -v circle -c black -i black -x 84.052622403974013
-y 72.424743591074247 -Z 0.0
n -t * -a 10 -s 10 -S UP -v circle -c black -i black -x
65.31614762047127 -y 68.493057260519379 -Z 0.0
n -t * -a 9 -s 9 -S UP -v circle -c black -i black -x 75.321826746371485
-y 33.942126265700033 -Z 0.0
n -t * -a 5 -s 5 -S UP -v circle -c black -i black -x 29.594850973037467
-y 0.66030384072116755 -Z 0.0
n -t * -a 1 -s 1 -S UP -v circle -c black -i black -x 42.665535184864666
-y 79.649852020502948 -Z 0.0
n -t * -a 6 -s 6 -S UP -v circle -c black -i black -x 97.726651000663011
-y 91.823368143208029 -Z 0.0
n -t * -a 2 -s 2 -S UP -v circle -c black -i black -x 75.062908593128867
-y 82.3047247167233 -Z 0.0
n -t * -a 7 -s 7 -S UP -v circle -c black -i black -x 75.348382897371607
-y 80.271356124557258 -Z 0.0
n -t * -a 3 -s 3 -S UP -v circle -c black -i black -x 95.508313968548691
-y 8.232869397957284 -Z 0.0

So I want to know that why does the coordinates accessed by
get_node_by_address() function is not the same as those in nam trace file or
in the nam GUI ?

Thank you very much, any suggestions is appreciated.

-- 
Su Jinzhao(苏金钊)


[ns] Questions on difference about node position in nam file and those accessed in C++

2011-09-07 Thread Su Jinzhao

Hello, friends.

I want to access node coordinates in C++ and node coordinates are initially
defined in Otcl.

 I referenced these two articles on accessing node coordinates in C++:

http://getch.wordpress.com/2011/02/10/finding-node-positionvelocity-and-speed-in-ns2-34/

http://getch.wordpress.com/2011/02/08/obtaining-node-position-and-energy-dynamically-in-ns2/

 my .cc file is like this:
 double x,y,z;
 MobileNode *iNode = (MobileNode*)(Node::get_node_by_address(1));
 iNode->getLoc(&x,&y,&z);

cout << "node1:" << x << " " << y << " " << z << endl;

  And my tcl script is defined like this:

set val(nn)11 ;#num of nodes
set val(xLimit)100
set val(yLimit)100

for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
$node_($i) set X_ [expr {$val(xLimit)*rand()}]
$node_($i) set Y_ [expr {$val(yLimit)*rand()}]
$node_($i) set Z_ 0.0
}

I expect that coordinates of node_(1) defined in my tcl script should be
print out, however, the result is:
node1:7.62437e-316 7.62415e-316 1.3793e-312

 So I am curious that why do these coordinates so small, is there
anything wrong in my code?(I also searched the NS mail list, the code
snippet is similar)

Here is the part of coordinates in the nam trace file:
n -t * -a 8 -s 8 -S UP -v circle -c black -i black -x 20.682385433783001
-y 8.8519855909291589 -Z 0.0
n -t * -a 4 -s 4 -S UP -v circle -c black -i black -x 69.835971468051881
-y 33.172463547984357 -Z 0.0
n -t * -a 0 -s 0 -S UP -v circle -c black -i black -x 84.052622403974013
-y 72.424743591074247 -Z 0.0
n -t * -a 10 -s 10 -S UP -v circle -c black -i black -x
65.31614762047127 -y 68.493057260519379 -Z 0.0
n -t * -a 9 -s 9 -S UP -v circle -c black -i black -x 75.321826746371485
-y 33.942126265700033 -Z 0.0
n -t * -a 5 -s 5 -S UP -v circle -c black -i black -x 29.594850973037467
-y 0.66030384072116755 -Z 0.0
n -t * -a 1 -s 1 -S UP -v circle -c black -i black -x 42.665535184864666
-y 79.649852020502948 -Z 0.0
n -t * -a 6 -s 6 -S UP -v circle -c black -i black -x 97.726651000663011
-y 91.823368143208029 -Z 0.0
n -t * -a 2 -s 2 -S UP -v circle -c black -i black -x 75.062908593128867
-y 82.3047247167233 -Z 0.0
n -t * -a 7 -s 7 -S UP -v circle -c black -i black -x 75.348382897371607
-y 80.271356124557258 -Z 0.0
n -t * -a 3 -s 3 -S UP -v circle -c black -i black -x 95.508313968548691
-y 8.232869397957284 -Z 0.0

So I want to know that why does the coordinates accessed by
get_node_by_address() function is not the same as those in nam trace file or
in the nam GUI ?

Thank you very much, any suggestions is appreciated.

-- 
Su Jinzhao