Create adjustable ip address

25 views
Skip to first unread message

Kevin Connaughton

unread,
Nov 21, 2021, 4:25:30 PM11/21/21
to ns-3-users
Hello, 

I am new to NS3 and find myself stuck at one point. 

I am trying to modify the below bit of code to make a unique ip address for a variable amount of wifi users.

Config::Set ("/NodeList/*/ApplicationList/*/$Sender/Destination",
               Ipv4AddressValue ("192.168.0.1"));

I have tried to set a loop like this:

for (uint32_t i=1; i<nUsers; i++)
{
text = "192.168.0.";
    text += std::to_string(i);
    Config::Set ("/NodeList/*/ApplicationList/*/$Sender/Destination",
               Ipv4AddressValue (text));
NS_LOG_INFO ("ip addresses "<< text << " .");
}

text appears to generate correctly but I get errors trying to set.

error: no matching function for call to ‘ns3::Ipv4AddressValue::Ipv4AddressValue(std::string&)’
  210 |                Ipv4AddressValue (text));
      |                                                             ^

I was wondering if anybody would be able to point me in the right direction to fix this. 

Kind regards,

Kevin.

Shilpi Mittal

unread,
Nov 21, 2021, 9:29:02 PM11/21/21
to ns-3-...@googlegroups.com
Check the value of IP address in text variable. Last value is missing. It should be 
192.168.0.1

.1 missing.



--
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 the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/167c9f55-9d42-475c-a597-df7e779e8d76n%40googlegroups.com.

Kevin Connaughton

unread,
Nov 22, 2021, 11:11:44 AM11/22/21
to ns-3-users
Thanks,

The next line adds the last value. I have the log info there to make sure that it is formatted correctly i.e 192.168.0.1, 192.168.0.2 etc. . . 

Reply all
Reply to author
Forward
0 new messages