-
Notifications
You must be signed in to change notification settings - Fork 82
/
ratedsplitter.hh
98 lines (84 loc) · 2.63 KB
/
ratedsplitter.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// -*- c-basic-offset: 4 -*-
#ifndef CLICK_RATEDSPLITTER_HH
#define CLICK_RATEDSPLITTER_HH
#include <click/element.hh>
#include <click/batchelement.hh>
#include <click/tokenbucket.hh>
CLICK_DECLS
/*
* =c
* RatedSplitter(RATE, I[<KEYWORDS>])
* =s shaping
* splits flow of packets at specified rate
* =processing
* Push
* =d
*
* RatedSplitter has two output ports. All incoming packets up to a maximum of
* RATE packets per second are emitted on output port 0. Any remaining packets
* are emitted on output port 1. Unlike Meter, RATE packets per second are
* emitted on output port 0 even when the input rate is greater than RATE.
*
* Like RatedUnqueue, RatedSplitter is implemented using a token bucket that
* defaults to a capacity of 20ms * RATE. The capacity can be changed with the
* BURST_DURATION and BURST_SIZE keyword configuration parameters.
*
* =e
* rs :: RatedSplitter(2000);
* Split packets on port 0 at 2000 packets per second.
*
* elementclass RatedSampler {
* input -> rs :: RatedSplitter(2000);
* rs [0] -> t :: Tee;
* t [0] -> [0] output;
* t [1] -> [1] output;
* rs [1] -> [0] output;
* };
*
* In the above example, RatedSampler is a compound element that samples input
* packets at 2000 packets per second. All traffic is emitted on output 0; a
* maximum of 2000 packets per second are emitted on output 1 as well.
*
* Keyword arguments are:
*
* =over 8
*
* =item RATE
*
* Integer. Token bucket fill rate in packets per second.
*
* =item BURST_DURATION
*
* Time. If specified, the capacity of the token bucket is calculated as
* rate * burst_duration.
*
* =item BURST_SIZE
*
* Integer. If specified, the capacity of the token bucket is set to this
* value.
*
* =h rate read/write
* rate of splitting
*
* =a BandwidthRatedSplitter, ProbSplitter, Meter, Shaper, RatedUnqueue, Tee */
class RatedSplitter : public BatchElement { public:
RatedSplitter() CLICK_COLD;
const char *class_name() const override { return "RatedSplitter"; }
const char *port_count() const override { return PORTS_1_1X2; }
const char *processing() const override { return PUSH; }
bool is_bandwidth() const { return class_name()[0] == 'B'; }
int configure(Vector<String> &, ErrorHandler *) CLICK_COLD;
bool can_live_reconfigure() const { return true; }
void add_handlers() CLICK_COLD;
void push(int port, Packet *);
#if HAVE_BATCH
void push_batch(int, PacketBatch *);
#endif
protected:
TokenBucket _tb;
static String read_handler(Element *, void *) CLICK_COLD;
private:
inline int smaction(Packet *p) CLICK_WARN_UNUSED_RESULT;
};
CLICK_ENDDECLS
#endif