Counts the datagrams exchanged with one peer, by direction and packet type.
More...
#include <aegis2d/net/traffic.hpp>
|
| using | Clock = std::chrono::steady_clock |
| | Clock of the one-second windows.
|
| |
|
| void | record (Direction direction, PacketType type, std::size_t bytes, Clock::time_point now) noexcept |
| | Records a datagram whose header was read.
|
| |
| void | record (Direction direction, std::size_t bytes, Clock::time_point now) noexcept |
| | Records a datagram of unknown type, such as one too short for a header.
|
| |
| TrafficCount | total (Direction direction) const noexcept |
| | Every datagram of a direction since the counters were created.
|
| |
| TrafficCount | total (Direction direction, PacketType type) const noexcept |
| | The datagrams of one type and direction since the counters were created.
|
| |
| TrafficCount | last_second (Direction direction, Clock::time_point now) const noexcept |
| | Every datagram of a direction during the last whole second.
|
| |
| TrafficCount | last_second (Direction direction, PacketType type, Clock::time_point now) const noexcept |
| | The datagrams of one type and direction during the last whole second.
|
| |
Counts the datagrams exchanged with one peer, by direction and packet type.
One per peer, like ReliableChannel: record() each datagram sent or received. total() counts since the counters were created; last_second() counts the last whole second, from second boundaries counted from the first record(), so it reads 0 once a second went by without traffic. A datagram whose type is unknown (dropped before its header could be read) is counted in the direction totals only.
Not thread-safe: use it from the thread that sends and receives.
◆ Clock
Clock of the one-second windows.
◆ last_second() [1/2]
| TrafficCount aegis2d::net::TrafficCounters::last_second |
( |
Direction |
direction, |
|
|
Clock::time_point |
now |
|
) |
| const |
|
noexcept |
Every datagram of a direction during the last whole second.
- Parameters
-
| direction | Sent or received. |
| now | Current time. |
- Returns
- The count: datagrams and bytes per second.
◆ last_second() [2/2]
The datagrams of one type and direction during the last whole second.
- Parameters
-
| direction | Sent or received. |
| type | Packet type. |
| now | Current time. |
- Returns
- The count: datagrams and bytes per second.
◆ record() [1/2]
| void aegis2d::net::TrafficCounters::record |
( |
Direction |
direction, |
|
|
PacketType |
type, |
|
|
std::size_t |
bytes, |
|
|
Clock::time_point |
now |
|
) |
| |
|
noexcept |
Records a datagram whose header was read.
- Parameters
-
| direction | Sent or received. |
| type | Type of the datagram. |
| bytes | Size of the datagram, header included. |
| now | Time of the send or of the arrival. |
◆ record() [2/2]
| void aegis2d::net::TrafficCounters::record |
( |
Direction |
direction, |
|
|
std::size_t |
bytes, |
|
|
Clock::time_point |
now |
|
) |
| |
|
noexcept |
Records a datagram of unknown type, such as one too short for a header.
- Parameters
-
| direction | Sent or received. |
| bytes | Size of the datagram. |
| now | Time of the send or of the arrival. |
◆ total() [1/2]
Every datagram of a direction since the counters were created.
- Parameters
-
| direction | Sent or received. |
- Returns
- The count, datagrams of unknown type included.
◆ total() [2/2]
The datagrams of one type and direction since the counters were created.
- Parameters
-
| direction | Sent or received. |
| type | Packet type. |
- Returns
- The count.
The documentation for this class was generated from the following file: