22 #include "ns3/nstime.h"
23 #include "ns3/fatal-error.h"
37 std::string::size_type n = s.find_first_not_of (
"0123456789.");
38 if (n != std::string::npos)
40 std::istringstream iss;
41 iss.str (s.substr (0, n));
44 std::string trailer = s.substr (n, std::string::npos);
50 else if (trailer ==
"b/s")
55 else if (trailer ==
"Bps")
58 *v = (uint64_t)(r * 8);
60 else if (trailer ==
"B/s")
63 *v = (uint64_t)(r * 8);
65 else if (trailer ==
"kbps")
68 *v = (uint64_t)(r * 1000);
70 else if (trailer ==
"kb/s")
73 *v = (uint64_t)(r * 1000);
75 else if (trailer ==
"Kbps")
78 *v = (uint64_t)(r * 1000);
80 else if (trailer ==
"Kb/s")
83 *v = (uint64_t)(r * 1000);
85 else if (trailer ==
"kBps")
88 *v = (uint64_t)(r * 8000);
90 else if (trailer ==
"kB/s")
93 *v = (uint64_t)(r * 8000);
95 else if (trailer ==
"KBps")
98 *v = (uint64_t)(r * 8000);
100 else if (trailer ==
"KB/s")
103 *v = (uint64_t)(r * 8000);
105 else if (trailer ==
"Kib/s")
108 *v = (uint64_t)(r * 1024);
110 else if (trailer ==
"KiB/s")
113 *v = (uint64_t)(r * 8192);
115 else if (trailer ==
"Mbps")
118 *v = (uint64_t)(r * 1000000);
120 else if (trailer ==
"Mb/s")
123 *v = (uint64_t)(r * 1000000);
125 else if (trailer ==
"MBps")
128 *v = (uint64_t)(r * 8000000);
130 else if (trailer ==
"MB/s")
133 *v = (uint64_t)(r * 8000000);
135 else if (trailer ==
"Mib/s")
138 *v = (uint64_t)(r * 1048576);
140 else if (trailer ==
"MiB/s")
143 *v = (uint64_t)(r * 1048576 * 8);
145 else if (trailer ==
"Gbps")
148 *v = (uint64_t)(r * 1000000000);
150 else if (trailer ==
"Gb/s")
153 *v = (uint64_t)(r * 1000000000);
155 else if (trailer ==
"GBps")
158 *v = (uint64_t)(r * 8*1000000000);
160 else if (trailer ==
"GB/s")
163 *v = (uint64_t)(r * 8*1000000000);
165 else if (trailer ==
"Gib/s")
168 *v = (uint64_t)(r * 1048576 * 1024);
170 else if (trailer ==
"GiB/s")
173 *v = (uint64_t)(r * 1048576 * 1024 * 8);
181 std::istringstream iss;
318 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
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*(double rhs)
Scales the DataRate.
DataRate operator+(DataRate rhs)
DataRate & operator+=(DataRate rhs)
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
DataRate & operator-=(DataRate rhs)
Simulation virtual time values and global simulation resolution.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
#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 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 ",...
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ATTRIBUTE_HELPER_CPP(Length)
std::istream & operator>>(std::istream &is, Angles &a)
std::ostream & operator<<(std::ostream &os, const Angles &a)