📄 counter.hh
字号:
// -*- mode: c++; c-basic-offset: 4 -*-#ifndef CLICK_COUNTER_HH#define CLICK_COUNTER_HH#include <click/element.hh>#include <click/ewma.hh>#include <click/llrpc.h>CLICK_DECLSclass HandlerCall;/*=cCounter([I<keywords COUNT_CALL, BYTE_COUNT_CALL>])=s measurementmeasures packet count and rate=dPasses packets unchanged from its input to its output, maintaining statisticsinformation about packet count and packet rate.Keyword arguments are:=over 8=item COUNT_CALLArgument is `I<N> I<HANDLER> [I<VALUE>]'. When the packet count reaches I<N>,call the write handler I<HANDLER> with value I<VALUE>.=item BYTE_COUNT_CALLArgument is `I<N> I<HANDLER> [I<VALUE>]'. When the byte count reaches orexceeds I<N>, call the write handler I<HANDLER> with value I<VALUE>.=back=h count read-onlyReturns the number of packets that have passed through since the last reset.=h byte_count read-onlyReturns the number of bytes that have passed through since the last reset.=h rate read-onlyReturns the recent arrival rate, measured by exponentialweighted moving average, in packets per second.=h reset_counts write-onlyResets the counts and rates to zero.=h reset write-onlySame as 'reset_counts'.=h count_call write-onlyWrites a new COUNT_CALL argument. The handler can be omitted.=h byte_count_call write-onlyWrites a new BYTE_COUNT_CALL argument. The handler can be omitted.=h CLICK_LLRPC_GET_RATE llrpcArgument is a pointer to an integer that must be 0. Returns the recentarrival rate (measured by exponential weighted moving average) inpackets per second. =h CLICK_LLRPC_GET_COUNT llrpcArgument is a pointer to an integer that must be 0 (packet count) or 1 (bytecount). Returns the current packet or byte count.=h CLICK_LLRPC_GET_COUNTS llrpcArgument is a pointer to a click_llrpc_counts_st structure (see<click/llrpc.h>). The C<keys> components must be 0 (packet count) or 1 (bytecount). Stores the corresponding counts in the corresponding C<values>components.*/class Counter : public Element { public: Counter(); ~Counter(); const char *class_name() const { return "Counter"; } const char *processing() const { return AGNOSTIC; } void reset(); int configure(Vector<String> &, ErrorHandler *); int initialize(ErrorHandler *); void add_handlers(); int llrpc(unsigned, void *); Packet *simple_action(Packet *); private:#ifdef HAVE_INT64_TYPES typedef uint64_t counter_t;#else typedef uint32_t counter_t;#endif counter_t _count; counter_t _byte_count; RateEWMA _rate; counter_t _count_trigger; HandlerCall *_count_trigger_h; counter_t _byte_trigger; HandlerCall *_byte_trigger_h; bool _count_triggered : 1; bool _byte_triggered : 1; static String read_handler(Element *, void *); static int write_handler(const String&, Element*, void*, ErrorHandler*);};CLICK_ENDDECLS#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -