getting the neighbours

47 views
Skip to first unread message

Doaa

unread,
Feb 15, 2016, 3:00:06 PM2/15/16
to ns-3-users
Hi all

however, I was not able to run the code, I got this error " C2039: 'Unref' : is not a member of 'ns3::Ipv4Address"

Below is what I tried:

for  (NodeContainer::Iterator j=  wifiStaNodes.Begin(); j!= wifiStaNodes.End(); j++)
{
Ptr<Node> nodeobject = *j;

Ptr<Ipv4Address> ip;
ip = nodeobject->GetObject<Ipv4L3Protocol> ();

Ipv4L3Protocol co;
uint32_t v;
v= co.GetInterfaceForAddress(*ip);
}

Tommaso Pecorella

unread,
Feb 15, 2016, 3:09:55 PM2/15/16
to ns-3-users
In 7 lines (9 if you count the braces) i can count 2 big mistakes and several lines that could be suppressed.
Mind to look at your code before asking for help ? It's a simple matter of function signature (i.e., you're calling the functions with the wrong parameters and/or assigning the return value to the wrong kind of object).

T.

Doaa Terri

unread,
Feb 15, 2016, 3:34:47 PM2/15/16
to ns-3-users
Thank you Tommaso for your reply 

I got the first error and I change 
Ptr<Ipv4L3Protocol> ip;
ip = nodeobject->GetObject<Ipv4L3Protocol> ();

now to call GetInterfaceForAddress function, I need the ip address of type Ipv4Address, how can I get it? I think this is the step that I miss and could not find it in the link I shared while ago. 
int32_t ns3::Ipv4L3Protocol::GetInterfaceForAddress(Ipv4Address address)const

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/0UMsxwBrM-w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Tommaso Pecorella

unread,
Feb 15, 2016, 4:13:28 PM2/15/16
to ns-3-users
Perhaps you misunderstood the old thread problem.
The method is to find out the node ID (or pointer) if you know the node IP address.
I.e., you know the node's IP address, and you want to find the node's ID.
This is something you could want to do if you have a neighbor table holding the neighbors addresses and you want their node IDs (even though I'd rather not know what the purpose of this is).


T.
Reply all
Reply to author
Forward
0 new messages