finding position of neighbor nodes in a node

222 views
Skip to first unread message

bahar

unread,
Sep 3, 2010, 8:45:09 AM9/3/10
to ns-3-users
Hi all
I'm working on ns3 and I want to change the way we choose MPR set. for
this purpose I must have all neighbors position and their velocity in
a special node, but the only thing I have about those neighbors is
their address like nb_tuple. I'll be thankful if someone tell me the
way for finding velocity and position of those nodes.Thanks in
advance.
Bests
Bahar

Rafael Roque

unread,
Sep 3, 2010, 11:54:53 AM9/3/10
to ns-3-...@googlegroups.com
You can set the initial NodeContainter as static and use it. But keep in mind that in a real world you should implement something (not easy) to discover the nodes positions and velocities without this information.


--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.




--
Rafael Roque Aschoff

Researcher at Network and Telecommunication Research Group - www.gprt.ufpe.br
MSc in Computer Science / UFPE - www.cin.ufpe.br


bahar

unread,
Sep 3, 2010, 12:45:57 PM9/3/10
to ns-3-users
Hi
I was wondering if I can work with mobile nodes and also can find
their position. I know if I have a pointer to a node I can use
Getobject and find it's position, but I want to know is there any way
to find it without having a pointer to node.
Bests
Bahar

On Sep 3, 7:54 pm, Rafael Roque <roque.raf...@gmail.com> wrote:
> You can set the initial NodeContainter as static and use it. But keep in
> mind that in a real world you should implement something (not easy) to
> discover the nodes positions and velocities without this information.
>
>
>
> On Fri, Sep 3, 2010 at 9:45 AM, bahar <h.baharloi...@gmail.com> wrote:
> > Hi all
> > I'm working on ns3 and I want to change the way we choose MPR set. for
> > this purpose I must have all neighbors position and their velocity in
> > a special node, but the only thing I have about those neighbors is
> > their address like nb_tuple. I'll be thankful if someone tell me the
> > way for finding velocity and position of those nodes.Thanks in
> > advance.
> > Bests
> > Bahar
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "ns-3-users" group.
> > To post to this group, send email to ns-3-...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > ns-3-users+...@googlegroups.com<ns-3-users%2Bunsu...@googlegroups.com>
> > .

Mathieu Lacage

unread,
Sep 4, 2010, 2:29:18 AM9/4/10
to ns-3-...@googlegroups.com
On Fri, Sep 3, 2010 at 18:45, bahar <h.baha...@gmail.com> wrote:
> Hi
> I was wondering if I can work with mobile nodes and also can find
> their position. I know if I have a pointer to a node I can use
> Getobject and find it's position, but I want to know is there any way
> to find it without having a pointer to node.

No.

Mathieu
--
Mathieu Lacage <mathieu...@gmail.com>

bahar

unread,
Sep 4, 2010, 1:05:10 PM9/4/10
to ns-3-users
Hi
so mathieu how can I find nodes position I need it. I just need to
have the position of all neighbors of a node in OLSR so I can
calculate their distance and use neighbors velocity.
Thanks in advance.
Bests
Bahar

On Sep 4, 10:29 am, Mathieu Lacage <mathieu.lac...@gmail.com> wrote:
> On Fri, Sep 3, 2010 at 18:45, bahar <h.baharloi...@gmail.com> wrote:
> > Hi
> > I was wondering if I can work with mobile nodes and also can find
> > their position. I know if I have a pointer to a node I can use
> > Getobject and find it's position, but I want to know is there any way
> > to find it without having a pointer to node.
>
> No.
>
> Mathieu
> --
> Mathieu Lacage <mathieu.lac...@gmail.com>

bahar

unread,
Sep 4, 2010, 1:50:08 PM9/4/10
to ns-3-users
Hi
It should be sth like in real world which we can have all nodes
position. Also I need node's velocity and it's the base of my project
and without it I can't do anything. please give me a hint how to do
it. Thanks.

Mathieu Lacage

unread,
Sep 5, 2010, 7:50:12 AM9/5/10
to ns-3-...@googlegroups.com
On Sat, Sep 4, 2010 at 19:05, bahar <h.baha...@gmail.com> wrote:
> Hi
> so mathieu how can I find nodes position I need it. I just need to
> have the position of all neighbors of a node in OLSR so I can
> calculate their distance and use neighbors velocity.

Maybe you should iterate through the nodes in NodeList and get their
positiono until you find the one you want.

bahar

unread,
Sep 5, 2010, 1:23:32 PM9/5/10
to ns-3-users
Hi
I've already done it and it gave the error:NodeList not declared in
this scope.So I added the "ns3/node-module.h" and then it give me the
error:"Do not include ns3 module aggregator headers from other
modules; these are meant only for end user scripts."
so t seems this NodeList doesn't work in olsr-routing-protocol so
would you please tell me what can I do. Thanks in advance.
Bests
Bahar

On Sep 5, 3:50 pm, Mathieu Lacage <mathieu.lac...@gmail.com> wrote:
> On Sat, Sep 4, 2010 at 19:05, bahar <h.baharloi...@gmail.com> wrote:
> > Hi
> > so mathieu how can I find nodes position I need it. I just need to
> > have the position of all neighbors of a node in OLSR so I can
> > calculate their distance and use neighbors velocity.
>
> Maybe you should iterate through the nodes in NodeList and get their
> positiono until you find the one you want.
>
> Mathieu
> --
> Mathieu Lacage <mathieu.lac...@gmail.com>

Mathieu Lacage

unread,
Sep 5, 2010, 2:42:54 PM9/5/10
to ns-3-...@googlegroups.com
On Sun, Sep 5, 2010 at 19:23, bahar <h.baha...@gmail.com> wrote:
> I've already done it and it gave the error:NodeList not declared in
> this scope.So I added the "ns3/node-module.h" and then it give me the
> error:"Do not include ns3 module aggregator headers from other
> modules; these are meant only for end user scripts."

You should try this then:
#include "ns3/node-list.h"

> so t seems this NodeList doesn't work in olsr-routing-protocol so
> would you please tell me what can I do. Thanks in advance.

Mathieu
--
Mathieu Lacage <mathieu...@gmail.com>

bahar

unread,
Sep 6, 2010, 8:11:43 AM9/6/10
to ns-3-users
Hi
I added this :
for(int i=0 ;i<20 ; i++)
{
Ptr <Ipv4> myipv4= NodeList::GetNode(i)-
>GetObject<Ipv4>();
int Interface = myipv4-
>GetInterfaceForAddress( nb_tuple.neighborMainAddr) ;
if( Interface != -1)
{
Vector cPosition = myipv4->GetObject<MobilityModel> ()-
>GetPosition ();
cpx = myipv4->GetObject<MobilityModel> ()->GetPosition
().x;
cpy = myipv4->GetObject<MobilityModel> ()->GetPosition
().y;
cpz = myipv4->GetObject<MobilityModel> ()->GetPosition
().z;
float itVelocity = myipv4->GetObject<MobilityModel> ()-
>GetVelocity ();
}
}
and for line :int Interface = myipv4-
>GetInterfaceForAddress( nb_tuple.neighborMainAddr) ;
and gives me thi error:error: request for member ‘neighborMainAddr’ in
‘nb_tuple’, which is of non-class type ‘const
ns3::olsr::NeighborTuple*’
would you please help me with this error.Thanks in advance.
Bests
Bahar

On Sep 5, 10:42 pm, Mathieu Lacage <mathieu.lac...@gmail.com> wrote:
> Mathieu Lacage <mathieu.lac...@gmail.com>

Mathieu Lacage

unread,
Sep 6, 2010, 2:50:48 PM9/6/10
to ns-3-...@googlegroups.com
On Mon, Sep 6, 2010 at 14:11, bahar <h.baha...@gmail.com> wrote:
>             int Interface = myipv4-
>>GetInterfaceForAddress( nb_tuple.neighborMainAddr) ;

> and gives me thi error:error: request for member ‘neighborMainAddr’ in
> ‘nb_tuple’, which is of non-class type ‘const
> ns3::olsr::NeighborTuple*’

Read carefully the compiler messages and you will figure out what is
wrong: in this case, my vision goggles that can see through the
internet tell me that you should be using '->' instead of '.'

It really seems to me that starting to program C++ by using ns-3 is a
bad idea: you should seriously learn from a decent C++ book.

Reply all
Reply to author
Forward
0 new messages