A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
data-rate.h
Go to the documentation of this file.
1//
2// Copyright (c) 2006 Georgia Tech Research Corporation
3//
4// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License version 2 as
6// published by the Free Software Foundation;
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// Author: Rajib Bhattacharjea<raj.b@gatech.edu>
18//
19
20#ifndef DATA_RATE_H
21#define DATA_RATE_H
22
23#include "ns3/attribute-helper.h"
24#include "ns3/attribute.h"
25#include "ns3/nstime.h"
26
27#include <iostream>
28#include <stdint.h>
29#include <string>
30
31namespace ns3
32{
33
89{
90 public:
91 DataRate();
100 DataRate(uint64_t bps);
119 DataRate(std::string rate);
120
126 DataRate operator+(DataRate rhs) const;
127
134
140 DataRate operator-(DataRate rhs) const;
141
148
158 DataRate operator*(double rhs) const;
159
169 DataRate& operator*=(double rhs);
170
178 DataRate operator*(uint64_t rhs) const;
179
187 DataRate& operator*=(uint64_t rhs);
188
194 bool operator<(const DataRate& rhs) const;
195
201 bool operator<=(const DataRate& rhs) const;
202
208 bool operator>(const DataRate& rhs) const;
209
215 bool operator>=(const DataRate& rhs) const;
216
222 bool operator==(const DataRate& rhs) const;
223
229 bool operator!=(const DataRate& rhs) const;
230
239
248
253 uint64_t GetBitRate() const;
254
255 private:
270 static bool DoParse(const std::string s, uint64_t* v);
271
272 // Uses DoParse
273 friend std::istream& operator>>(std::istream& is, DataRate& rate);
274
275 uint64_t m_bps;
276};
277
285std::ostream& operator<<(std::ostream& os, const DataRate& rate);
286
294std::istream& operator>>(std::istream& is, DataRate& rate);
295
297
306double operator*(const DataRate& lhs, const Time& rhs);
315double operator*(const Time& lhs, const DataRate& rhs);
316
317namespace TracedValueCallback
318{
319
327typedef void (*DataRate)(DataRate oldValue, DataRate newValue);
328
329} // namespace TracedValueCallback
330
331} // namespace ns3
332
333#endif /* DATA_RATE_H */
Class for representing data rates.
Definition: data-rate.h:89
DataRate & operator*=(double rhs)
Scales the DataRate.
Definition: data-rate.cc:235
bool operator==(const DataRate &rhs) const
Definition: data-rate.cc:279
bool operator<(const DataRate &rhs) const
Definition: data-rate.cc:255
bool operator>(const DataRate &rhs) const
Definition: data-rate.cc:267
bool operator!=(const DataRate &rhs) const
Definition: data-rate.cc:285
bool operator>=(const DataRate &rhs) const
Definition: data-rate.cc:273
DataRate operator-(DataRate rhs) const
Definition: data-rate.cc:214
Time CalculateBitsTxTime(uint32_t bits) const
Calculate transmission time.
Definition: data-rate.cc:298
static bool DoParse(const std::string s, uint64_t *v)
Parse a string representing a DataRate into an uint64_t.
Definition: data-rate.cc:35
uint64_t m_bps
data rate [bps]
Definition: data-rate.h:275
uint64_t GetBitRate() const
Get the underlying bitrate.
Definition: data-rate.cc:305
bool operator<=(const DataRate &rhs) const
Definition: data-rate.cc:261
DataRate & operator+=(DataRate rhs)
Definition: data-rate.cc:207
DataRate operator+(DataRate rhs) const
Definition: data-rate.cc:201
DataRate operator*(double rhs) const
Scales the DataRate.
Definition: data-rate.cc:229
Time CalculateBytesTxTime(uint32_t bytes) const
Calculate transmission time.
Definition: data-rate.cc:291
DataRate & operator-=(DataRate rhs)
Definition: data-rate.cc:221
friend std::istream & operator>>(std::istream &is, DataRate &rate)
Stream extraction operator.
Definition: data-rate.cc:331
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
#define ATTRIBUTE_HELPER_HEADER(type)
Declare the attribute value, accessor and checkers for class type
int64x64_t operator*(const int64x64_t &lhs, const int64x64_t &rhs)
Multiplication operator.
Definition: int64x64.h:118
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:153