How do I generate an Ip Address from a String?

133 views
Skip to first unread message

琳琅

unread,
Apr 6, 2023, 5:57:31 AM4/6/23
to ns-3-users
Hello, I want to use socket->SendTo (packet, 0, from); This method sends a Packet from this Address. 

According to the API manual, the type of from is address, but my current IP address is only an IPv4 address of String type, for example, std::string s = "10.1.1.2";  

Then I looked up the manual on Address and found that there was only one possible way to get the Address: ns3::Address::Address (uint8_t type, const uint8_t * buffer, uint8_t len), 

but I don't know what the three parameters mean and what the values of the three parameters should be?

That's why I'm asking for your help, Thank you for your help.

Tommaso Pecorella

unread,
Apr 6, 2023, 6:03:25 AM4/6/23
to ns-3-users
Use "Ipv4Address(string);", this can be converted into an Address.

琳琅

unread,
Apr 9, 2023, 10:40:53 PM4/9/23
to ns-3-users
Thank you for your help

琳琅

unread,
Apr 10, 2023, 5:33:27 AM4/10/23
to ns-3-users
How do I block NS-3?

I'm sorry to bother you. Now I have a problem again. I want to co-simulate ns-3 with another simulation software sumo, and I have difficulty in time synchronization.

As we know, NS-3 is a discrete event simulator. If the total simulation time is 100s and I only add one event in the 50s, then the middle 1-50s will be skipped directly. I want to suspend the operation of NS-3 after the execution of the event in the 50s, and then continue to run NS-3 again when appropriate.

May I ask how to achieve the above requirements? Thank you very much for your help!

在2023年4月6日星期四 UTC+8 18:03:25<Tommaso Pecorella> 写道:

Tommaso Pecorella

unread,
Apr 10, 2023, 5:37:49 AM4/10/23
to ns-3-users
Please start another thread, as per posting guidelines.

琳琅

unread,
Apr 10, 2023, 7:51:36 AM4/10/23
to ns-3-users
OK,thank you!
Reply all
Reply to author
Forward
0 new messages