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;
232 return static_cast<double>(bytes)*8/
m_bps;
280 is.setstate (std::ios_base::failbit);
bool operator==(const DataRate &rhs) const
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Simulation virtual time values and global simulation resolution.
bool operator!=(const DataRate &rhs) const
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type.
NS_DEPRECATED double CalculateTxTime(uint32_t bytes) const
Calculate transmission time.
bool operator>(const DataRate &rhs) const
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
bool operator<=(const DataRate &rhs) const
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
uint64_t m_bps
data rate [bps]
bool operator<(const DataRate &rhs) const
static bool DoParse(const std::string s, uint64_t *v)
Parse a string representing a DataRate into an uint64_t.
uint64_t GetBitRate() const
Get the underlying bitrate.
Class for representing data rates.
int64x64_t operator*(const int64x64_t &lhs, const int64x64_t &rhs)
Multiplication operator.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time CalculateBitsTxTime(uint32_t bits) const
Calculate transmission time.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
bool operator>=(const DataRate &rhs) const