Time Type to int

39 views
Skip to first unread message

netwo...@gmail.com

unread,
Jan 28, 2017, 12:36:22 AM1/28/17
to ns-3-users
hi,


i am working on some algorithm in which i need to play time simulation time and packet arrival time.
Time times = Simulator::Now();
This give us in nanoseconds and Time type id 
and i want it to convert in unsigned integer. 

i tried this 
long int t = static_cast<long int> time(times);
uint32_t now = int(Simulator::Now());

 it gives me error and i did understand that i cannot convert like this.

so is there any other way, in which i can get Simulator::Now() in integer type so that i can apply mathematics on it.

Thank you

Regards

Konstantinos

unread,
Jan 28, 2017, 8:54:57 AM1/28/17
to ns-3-users
Hi,

The ns3::Time class provides an extensive API with Get() methods that some return integer values.
https://www.nsnam.org/docs/doxygen/classns3_1_1_time.html

For example you can have 
int64_t now = Simulator::Now().GetNanoSeconds();

Regards
K

netwo...@gmail.com

unread,
Jan 28, 2017, 10:58:49 PM1/28/17
to ns-3-users
Thank you Mr. K

Regards 
V
Reply all
Reply to author
Forward
0 new messages