22#include "ns3/fatal-error.h"
24#include "ns3/nstime.h"
38 std::string::size_type n = s.find_first_not_of(
"0123456789.");
39 if (n != std::string::npos)
41 std::istringstream iss;
42 iss.str(s.substr(0, n));
45 std::string trailer = s.substr(n, std::string::npos);
51 else if (trailer ==
"b/s")
56 else if (trailer ==
"Bps")
59 *v = (uint64_t)(r * 8);
61 else if (trailer ==
"B/s")
64 *v = (uint64_t)(r * 8);
66 else if (trailer ==
"kbps")
69 *v = (uint64_t)(r * 1000);
71 else if (trailer ==
"kb/s")
74 *v = (uint64_t)(r * 1000);
76 else if (trailer ==
"Kbps")
79 *v = (uint64_t)(r * 1000);
81 else if (trailer ==
"Kb/s")
84 *v = (uint64_t)(r * 1000);
86 else if (trailer ==
"kBps")
89 *v = (uint64_t)(r * 8000);
91 else if (trailer ==
"kB/s")
94 *v = (uint64_t)(r * 8000);
96 else if (trailer ==
"KBps")
99 *v = (uint64_t)(r * 8000);
101 else if (trailer ==
"KB/s")
104 *v = (uint64_t)(r * 8000);
106 else if (trailer ==
"Kib/s")
109 *v = (uint64_t)(r * 1024);
111 else if (trailer ==
"KiB/s")
114 *v = (uint64_t)(r * 8192);
116 else if (trailer ==
"Mbps")
119 *v = (uint64_t)(r * 1000000);
121 else if (trailer ==
"Mb/s")
124 *v = (uint64_t)(r * 1000000);
126 else if (trailer ==
"MBps")
129 *v = (uint64_t)(r * 8000000);
131 else if (trailer ==
"MB/s")
134 *v = (uint64_t)(r * 8000000);
136 else if (trailer ==
"Mib/s")
139 *v = (uint64_t)(r * 1048576);
141 else if (trailer ==
"MiB/s")
144 *v = (uint64_t)(r * 1048576 * 8);
146 else if (trailer ==
"Gbps")
149 *v = (uint64_t)(r * 1000000000);
151 else if (trailer ==
"Gb/s")
154 *v = (uint64_t)(r * 1000000000);
156 else if (trailer ==
"GBps")
159 *v = (uint64_t)(r * 8 * 1000000000);
161 else if (trailer ==
"GB/s")
164 *v = (uint64_t)(r * 8 * 1000000000);
166 else if (trailer ==
"Gib/s")
169 *v = (uint64_t)(r * 1048576 * 1024);
171 else if (trailer ==
"GiB/s")
174 *v = (uint64_t)(r * 1048576 * 1024 * 8);
182 std::istringstream iss;
339 is.setstate(std::ios_base::failbit);
Class for representing data rates.
DataRate & operator*=(double rhs)
Scales the DataRate.
bool operator==(const DataRate &rhs) const
bool operator<(const DataRate &rhs) const
bool operator>(const DataRate &rhs) const
bool operator!=(const DataRate &rhs) const
bool operator>=(const DataRate &rhs) const
DataRate operator-(DataRate rhs) const
Time CalculateBitsTxTime(uint32_t bits) const
Calculate transmission time.
static bool DoParse(const std::string s, uint64_t *v)
Parse a string representing a DataRate into an uint64_t.
uint64_t m_bps
data rate [bps]
uint64_t GetBitRate() const
Get the underlying bitrate.
bool operator<=(const DataRate &rhs) const
DataRate & operator+=(DataRate rhs)
DataRate operator+(DataRate rhs) const
DataRate operator*(double rhs) const
Scales the DataRate.
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
DataRate & operator-=(DataRate rhs)
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
High precision numerical type, implementing Q64.64 fixed precision.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
int64x64_t operator*(const int64x64_t &lhs, const int64x64_t &rhs)
Multiplication operator.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
std::istream & operator>>(std::istream &is, Angles &a)