11#include "ns3/fatal-error.h"
13#include "ns3/nstime.h"
27 std::string::size_type n = s.find_first_not_of(
"0123456789.");
28 if (n != std::string::npos)
30 std::istringstream iss;
31 iss.str(s.substr(0, n));
34 std::string trailer = s.substr(n, std::string::npos);
35 if (trailer ==
"bps" || trailer ==
"b/s")
40 else if (trailer ==
"Bps" || trailer ==
"B/s")
43 *v = (uint64_t)(r * 8);
45 else if (trailer ==
"kbps" || trailer ==
"kb/s" || trailer ==
"Kbps" || trailer ==
"Kb/s")
48 *v = (uint64_t)(r * 1000);
50 else if (trailer ==
"kBps" || trailer ==
"kB/s" || trailer ==
"KBps" || trailer ==
"KB/s")
53 *v = (uint64_t)(r * 8000);
55 else if (trailer ==
"Kib/s")
58 *v = (uint64_t)(r * 1024);
60 else if (trailer ==
"KiB/s")
63 *v = (uint64_t)(r * 8192);
65 else if (trailer ==
"Mbps" || trailer ==
"Mb/s")
68 *v = (uint64_t)(r * 1000000);
70 else if (trailer ==
"MBps" || trailer ==
"MB/s")
73 *v = (uint64_t)(r * 8000000);
75 else if (trailer ==
"Mib/s")
78 *v = (uint64_t)(r * 1048576);
80 else if (trailer ==
"MiB/s")
83 *v = (uint64_t)(r * 1048576 * 8);
85 else if (trailer ==
"Gbps" || trailer ==
"Gb/s")
88 *v = (uint64_t)(r * 1000000000);
90 else if (trailer ==
"GBps" || trailer ==
"GB/s")
93 *v = (uint64_t)(r * 8 * 1000000000);
95 else if (trailer ==
"Gib/s")
98 *v = (uint64_t)(r * 1048576 * 1024);
100 else if (trailer ==
"GiB/s")
103 *v = (uint64_t)(r * 1048576 * 1024 * 8);
111 std::istringstream iss;
268 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)