Class for representing data rates. More...
#include <data-rate.h>
Public Member Functions | |
DataRate (uint64_t bps) | |
Integer constructor. | |
double | CalculateTxTime (uint32_t bytes) const |
Calculate transmission time. | |
uint64_t | GetBitRate () const |
Class for representing data rates.
Allows for natural and familiar use of data rates. Allows construction from strings, natural multiplication e.g.:
DataRate x("56kbps"); double nBits = x*ns3::Seconds(19.2); uint32_t nBytes = 20; double txtime = x.CalclulateTxTime(nBytes);
This class also supports the regular comparison operators <, >, <=, >=, ==, and !=
ns3::DataRate::DataRate | ( | uint64_t | bps | ) |
Integer constructor.
Construct a data rate from an integer. This class only supports positive integer data rates in units of bits/s, meaning 1bit/s is the smallest non-trivial bitrate availiable.
double ns3::DataRate::CalculateTxTime | ( | uint32_t | bytes | ) | const |
Calculate transmission time.
Calculates the transmission time at this data rate
bytes | The number of bytes (not bits) for which to calculate |
uint64_t ns3::DataRate::GetBitRate | ( | ) | const |
Get the underlying bitrate