bahar
bahar

Reputation: 81

Problem with converting IP addresses in C++

I need to find the IP address of my node in my code. Currently, I have this line:this line:

IPv4Address addr = nb_ipv4->GetAddress (maininterface , 0);

In this line, I expect to get the IP address for my main interface, but instead I see this error:

error:conversion from 'ns3::Ipv4InterfaceAddress' to non-scalar type 'ns3::Ipv4Address' 

Can anyone help me to solve this error?

Upvotes: 1

Views: 372

Answers (1)

Luis G. Costantini R.
Luis G. Costantini R.

Reputation: 1128

I think that must be tagged as C++, and (if it is The ns-3 network simulator) you must do this:

IPv4Address addr = nb_ipv4->GetAddress(maininterface).GetLocal();

Upvotes: 3

Related Questions