rippled
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
ripple::TrafficCount Class Reference

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

#include <TrafficCount.h>

Collaboration diagram for ripple::TrafficCount:
Collaboration graph
[legend]

Classes

class  TrafficStats
 

Public Types

enum  category : std::size_t {
  base , cluster , overlay , manifests ,
  transaction , transaction_duplicate , proposal , proposal_untrusted ,
  proposal_duplicate , validation , validation_untrusted , validation_duplicate ,
  validatorlist , squelch , squelch_suppressed , squelch_ignored ,
  get_set , share_set , ld_tsc_get , ld_tsc_share ,
  ld_txn_get , ld_txn_share , ld_asn_get , ld_asn_share ,
  ld_get , ld_share , gl_tsc_share , gl_tsc_get ,
  gl_txn_share , gl_txn_get , gl_asn_share , gl_asn_get ,
  gl_share , gl_get , share_hash_ledger , get_hash_ledger ,
  share_hash_tx , get_hash_tx , share_hash_txnode , get_hash_txnode ,
  share_hash_asnode , get_hash_asnode , share_cas_object , get_cas_object ,
  share_fetch_pack , get_fetch_pack , get_transactions , share_hash ,
  get_hash , proof_path_request , proof_path_response , replay_delta_request ,
  replay_delta_response , have_transactions , requested_transactions , 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 to_string (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 49 of file TrafficCount.h.

Member Enumeration Documentation

◆ category

Enumerator
base 
cluster 
overlay 
manifests 
transaction 
transaction_duplicate 
proposal 
proposal_untrusted 
proposal_duplicate 
validation 
validation_untrusted 
validation_duplicate 
validatorlist 
squelch 
squelch_suppressed 
squelch_ignored 
get_set 
share_set 
ld_tsc_get 
ld_tsc_share 
ld_txn_get 
ld_txn_share 
ld_asn_get 
ld_asn_share 
ld_get 
ld_share 
gl_tsc_share 
gl_tsc_get 
gl_txn_share 
gl_txn_get 
gl_asn_share 
gl_asn_get 
gl_share 
gl_get 
share_hash_ledger 
get_hash_ledger 
share_hash_tx 
get_hash_tx 
share_hash_txnode 
get_hash_txnode 
share_hash_asnode 
get_hash_asnode 
share_cas_object 
get_cas_object 
share_fetch_pack 
get_fetch_pack 
get_transactions 
share_hash 
get_hash 
proof_path_request 
proof_path_response 
replay_delta_request 
replay_delta_response 
have_transactions 
requested_transactions 
total 
unknown 

Definition at line 87 of file TrafficCount.h.

Constructor & Destructor Documentation

◆ TrafficCount()

ripple::TrafficCount::TrafficCount ( )
default

Member Function Documentation

◆ categorize()

TrafficCount::category ripple::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 52 of file TrafficCount.cpp.

◆ addCount()

void ripple::TrafficCount::addCount ( category  cat,
bool  inbound,
int  bytes 
)

Account for traffic associated with the given category.

Definition at line 214 of file TrafficCount.h.

◆ getCounts()

auto const & ripple::TrafficCount::getCounts ( ) const

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

Returns
an object which satisfies the requirements of Container

Definition at line 243 of file TrafficCount.h.

◆ to_string()

static std::string ripple::TrafficCount::to_string ( category  cat)
static

Definition at line 249 of file TrafficCount.h.

Member Data Documentation

◆ counts_

std::unordered_map<category, TrafficStats> ripple::TrafficCount::counts_
protected

Definition at line 316 of file TrafficCount.h.