📄 ratedsource.hh
字号:
#ifndef CLICK_RATEDSOURCE_HH#define CLICK_RATEDSOURCE_HH#include <click/element.hh>#include <click/gaprate.hh>#include <click/task.hh>CLICK_DECLS/*=cRatedSource([DATA, RATE, LIMIT, ACTIVE, I<KEYWORDS>])=s sourcesgenerates packets at specified rate=dCreates packets consisting of DATA, emitting at most LIMIT such packets outits single output at a rate of RATE packets per second. When used as a pushelement, RatedSource will send a maximum of one packet per scheduling, so veryhigh RATEs may not be achievable. If LIMIT is negative, sends packets forever.Will send packets only if ACTIVE is true. Default DATA is at least 64 byteslong. Default RATE is 10. Default LIMIT is -1 (send packets forever). DefaultACTIVE is true.Keyword arguments are:=over 8=item DATAString. Same as the DATA argument.=item DATASIZEInteger. If set, ensures the outgoing packet contains at least this many bytes.=item RATEInteger. Same as the RATE argument.=item LIMITInteger. Same as the LIMIT argument.=item ACTIVEBoolean. Same as the ACTIVE? argument.=item STOPBoolean. If true, then stop the driver once LIMIT packets are sent. Default isfalse.=backTo generate a particular repeatable traffic pattern, use this element'sB<rate> and B<active> handlers in conjunction with PokeHandlers.=e RatedSource(\<0800>, 10, 1000) -> Queue -> ...=h count read-onlyReturns the total number of packets that have been generated.=h reset write-onlyResets the number of generated packets to 0. The RatedSource will thengenerate another LIMIT packets (if it is active).=h data read/writeReturns or sets the DATA parameter.=h datasize read/writeReturns or sets the DATASIZE parameter.=h rate read/writeReturns or sets the RATE parameter.=h limit read/writeReturns or sets the LIMIT parameter. Negative numbers mean no limit.=h active read/writeMakes the element active or inactive.=aInfiniteSource, PokeHandlers */class RatedSource : public Element { public: RatedSource(); ~RatedSource(); const char *class_name() const { return "RatedSource"; } const char *processing() const { return AGNOSTIC; } void add_handlers(); int configure(Vector<String> &, ErrorHandler *); int initialize(ErrorHandler *); void cleanup(CleanupStage); bool run_task(); Packet *pull(int); protected: void setup_packet(); static const unsigned NO_LIMIT = 0xFFFFFFFFU; GapRate _rate; unsigned _count; unsigned _limit; int _datasize; bool _active : 1; bool _stop : 1; Packet *_packet; Task _task; String _data; static String read_param(Element *, void *); static int change_param(const String &, Element *, void *, ErrorHandler *); };CLICK_ENDDECLS#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -