xrpld
Loading...
Searching...
No Matches
xrpl::TrafficCount Class Reference

TrafficCount is used to count ingress and egress wire bytes and number of messages. More...

#include <TrafficCount.h>

Collaboration diagram for xrpl::TrafficCount:

Classes

class  TrafficStats

Public Types

enum class  Category : std::size_t {
  Base , Cluster , Overlay , Manifests ,
  Transaction , TransactionDuplicate , Proposal , ProposalUntrusted ,
  ProposalDuplicate , Validation , ValidationUntrusted , ValidationDuplicate ,
  Validatorlist , Squelch , SquelchSuppressed , SquelchIgnored ,
  GetSet , ShareSet , LdTscGet , LdTscShare ,
  LdTxnGet , LdTxnShare , LdAsnGet , LdAsnShare ,
  LdGet , LdShare , GlTscShare , GlTscGet ,
  GlTxnShare , GlTxnGet , GlAsnShare , GlAsnGet ,
  GlShare , GlGet , ShareHashLedger , GetHashLedger ,
  ShareHashTx , GetHashTx , ShareHashTxnode , GetHashTxnode ,
  ShareHashAsnode , GetHashAsnode , ShareCasObject , GetCasObject ,
  ShareFetchPack , GetFetchPack , GetTransactions , ShareHash ,
  GetHash , ProofPathRequest , ProofPathResponse , ReplayDeltaRequest ,
  ReplayDeltaResponse , HaveTransactions , RequestedTransactions , Total ,
  Unknown
}

Public Member Functions

 TrafficCount ()=default
void addCount (Category cat, bool inbound, int bytes)
 Account for traffic associated with the given category.
auto const & getCounts () const
 An up-to-date copy of all the counters.

Static Public Member Functions

static Category categorize (::google::protobuf::Message const &message, protocol::MessageType type, bool inbound)
 Given a protocol message, determine which traffic category it belongs to.
static std::string toString (Category cat)

Protected Attributes

std::unordered_map< Category, TrafficStatscounts_

Detailed Description

TrafficCount is used to count ingress and egress wire bytes and number of messages.

The general intended usage is as follows:

  1. Determine the message category by callin TrafficCount::categorize
  2. Increment the counters for incoming or outgoing traffic by calling TrafficCount::addCount
  3. Optionally, TrafficCount::addCount can be called at any time to increment additional traffic categories, not captured by TrafficCount::categorize.

There are two special categories:

  1. category::total - this category is used to report the total traffic amount. It should be incremented once just after receiving a new message, and once just before sending a message to a peer. Messages whose category is not in TrafficCount::categorize are not included in the total.
  2. category::unknown - this category is used to report traffic for messages of unknown type.

Definition at line 29 of file TrafficCount.h.

Member Enumeration Documentation

◆ Category

Enumerator
Base 
Cluster 
Overlay 
Manifests 
Transaction 
TransactionDuplicate 
Proposal 
ProposalUntrusted 
ProposalDuplicate 
Validation 
ValidationUntrusted 
ValidationDuplicate 
Validatorlist 
Squelch 
SquelchSuppressed 
SquelchIgnored 
GetSet 
ShareSet 
LdTscGet 
LdTscShare 
LdTxnGet 
LdTxnShare 
LdAsnGet 
LdAsnShare 
LdGet 
LdShare 
GlTscShare 
GlTscGet 
GlTxnShare 
GlTxnGet 
GlAsnShare 
GlAsnGet 
GlShare 
GlGet 
ShareHashLedger 
GetHashLedger 
ShareHashTx 
GetHashTx 
ShareHashTxnode 
GetHashTxnode 
ShareHashAsnode 
GetHashAsnode 
ShareCasObject 
GetCasObject 
ShareFetchPack 
GetFetchPack 
GetTransactions 
ShareHash 
GetHash 
ProofPathRequest 
ProofPathResponse 
ReplayDeltaRequest 
ReplayDeltaResponse 
HaveTransactions 
RequestedTransactions 
Total 
Unknown 

Definition at line 66 of file TrafficCount.h.

Constructor & Destructor Documentation

◆ TrafficCount()

xrpl::TrafficCount::TrafficCount ( )
default

Member Function Documentation

◆ categorize()

TrafficCount::Category xrpl::TrafficCount::categorize ( ::google::protobuf::Message const & message,
protocol::MessageType type,
bool inbound )
static

Given a protocol message, determine which traffic category it belongs to.

Definition at line 31 of file TrafficCount.cpp.

◆ addCount()

void xrpl::TrafficCount::addCount ( Category cat,
bool inbound,
int bytes )

Account for traffic associated with the given category.

Definition at line 193 of file TrafficCount.h.

◆ getCounts()

auto const & xrpl::TrafficCount::getCounts ( ) const
nodiscard

An up-to-date copy of all the counters.

Returns
an object which satisfies the requirements of Container

Definition at line 221 of file TrafficCount.h.

◆ toString()

std::string xrpl::TrafficCount::toString ( Category cat)
static

Definition at line 227 of file TrafficCount.h.

Member Data Documentation

◆ counts_

std::unordered_map<Category, TrafficStats> xrpl::TrafficCount::counts_
protected

Definition at line 294 of file TrafficCount.h.