-
Notifications
You must be signed in to change notification settings - Fork 78
/
infinitesource.hh
163 lines (114 loc) · 3.58 KB
/
infinitesource.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#ifndef CLICK_INFINITESOURCE_HH
#define CLICK_INFINITESOURCE_HH
#include <click/batchelement.hh>
#include <click/task.hh>
#include <click/notifier.hh>
CLICK_DECLS
class HandlerCall;
/*
=c
InfiniteSource([DATA, LIMIT, BURST, ACTIVE, I<keywords>])
=s basicsources
generates packets whenever scheduled
=d
Creates packets consisting of DATA. Pushes BURST such packets out its single
output every time it is scheduled (which will be often). Stops sending after
LIMIT packets are generated; but if LIMIT is negative, sends packets forever.
Will send packets only if ACTIVE is true. (ACTIVE is true by default.) Default
DATA is at least 64 bytes long. Default LIMIT is -1 (send packets forever).
Default BURST is 1.
Keyword arguments are:
=over 8
=item DATA
String. Same as the DATA argument.
=item LENGTH
Integer. If set, the outgoing packet will have this length.
=item LIMIT
Integer. Same as the LIMIT argument.
=item HEADROOM
Integer. Sets the amount of headroom on generated packets. Default is
the default packet headroom.
=item BURST
Integer. Same as the BURST argument.
=item ACTIVE
Boolean. Same as the ACTIVE argument.
=item STOP
Boolean. If true, then stop the driver once LIMIT packets are sent. Default is
false.
=item END_CALL
A write handler called once LIMIT packets are sent. END_CALL and
STOP are mutually exclusive.
=item TIMESTAMP
Boolean. If false, do not set the timestamp annotation on generated
packets. Defaults to true.
=back
To generate a particular traffic pattern, use this element and RatedSource
in conjunction with Script.
=e
InfiniteSource(\<0800>) -> Queue -> ...
=n
Useful for profiling and experiments. Packets' timestamp annotations are set
to the current time.
InfiniteSource listens for downstream full notification.
=h count read-only
Returns the total number of packets that have been generated.
=h reset write-only
Resets the number of generated packets to 0. The InfiniteSource will then
generate another LIMIT packets (if it is active).
=h data read/write
Returns or sets the DATA parameter.
=h length read/write
Returns or sets the LENGTH parameter.
=h limit read/write
Returns or sets the LIMIT parameter.
=h burst read/write
Returns or sets the BURST parameter.
=h active read/write
Makes the element active or inactive.
=a
RatedSource, Script */
class InfiniteSource : public BatchElement, public ActiveNotifier { public:
InfiniteSource() CLICK_COLD;
const char *class_name() const override { return "InfiniteSource"; }
void *cast(const char *);
const char *port_count() const override { return PORTS_0_1; }
const char *flags() const { return "S1"; }
void add_handlers() CLICK_COLD;
int configure(Vector<String> &, ErrorHandler *) CLICK_COLD;
int initialize(ErrorHandler *) CLICK_COLD;
bool can_live_reconfigure() const { return true; }
void cleanup(CleanupStage) CLICK_COLD;
bool run_task(Task *);
Packet *pull(int);
#if HAVE_BATCH
PacketBatch* pull_batch(int, unsigned);
#endif
protected:
#if HAVE_INT64_TYPES
typedef uint64_t ucounter_t;
typedef int64_t counter_t;
#else
typedef uint32_t ucounter_t;
typedef int32_t counter_t;
#endif
void setup_packet();
Packet *_packet;
unsigned _burstsize;
counter_t _limit;
ucounter_t _count;
int _datasize;
bool _active;
bool _timestamp;
int _headroom;
Task _task;
String _data;
NotifierSignal _nonfull_signal;
HandlerCall *_end_h;
enum {
h_data, h_limit, h_burst, h_active, h_reset, h_count, h_length,
h_notifier
};
static int change_param(const String &, Element *, void *, ErrorHandler *);
};
CLICK_ENDDECLS
#endif