-
Notifications
You must be signed in to change notification settings - Fork 82
/
randomsource.hh
104 lines (70 loc) · 2.3 KB
/
randomsource.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
#ifndef CLICK_RANDOMSOURCE_HH
#define CLICK_RANDOMSOURCE_HH
#include "infinitesource.hh"
CLICK_DECLS
/*
* =c
* RandomSource(LENGTH [, LIMIT, BURST, ACTIVE, I<KEYWORDS>])
* =s basicsources
* generates random packets whenever scheduled
* =d
*
* Creates packets, of the indicated length, filled with random bytes.
* Packets' timestamp annotations are set to the current time. 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 LIMIT is -1 (send packets
* forever). Default BURST is 1.
Keyword arguments are:
=over 8
=item LENGTH
Integer. The outgoing packet will have this length.
=item LIMIT
Integer. Same as the LIMIT argument.
=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.
=e
RandomSource(64) -> Queue -> ...
=n
Useful for profiling and experiments. Packets' timestamp annotations are set
to the current time.
RandomSource 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 RandomSource will then
generate another LIMIT packets (if it is active).
=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
InfiniteSource */
class RandomSource : public InfiniteSource { public:
RandomSource() CLICK_COLD;
const char *class_name() const override { return "RandomSource"; }
void add_handlers() CLICK_COLD;
int configure(Vector<String> &, ErrorHandler *) CLICK_COLD;
bool run_task(Task *);
Packet *pull(int);
protected:
Packet *make_packet();
};
CLICK_ENDDECLS
#endif