RandomSplit splits and drop packets.
| 40 | |
| 41 | // RandomSplit splits and drop packets. |
| 42 | class RandomSplit final : public Module { |
| 43 | public: |
| 44 | RandomSplit() : Module() { max_allowed_workers_ = Worker::kMaxWorkers; } |
| 45 | |
| 46 | static const gate_idx_t kNumOGates = MAX_GATES; |
| 47 | static const Commands cmds; |
| 48 | |
| 49 | CommandResponse Init(const bess::pb::RandomSplitArg &arg); |
| 50 | CommandResponse CommandSetDroprate( |
| 51 | const bess::pb::RandomSplitCommandSetDroprateArg &arg); |
| 52 | CommandResponse CommandSetGates( |
| 53 | const bess::pb::RandomSplitCommandSetGatesArg &arg); |
| 54 | |
| 55 | void ProcessBatch(Context *ctx, bess::PacketBatch *batch) override; |
| 56 | |
| 57 | private: |
| 58 | Random rng_; // Random number generator |
| 59 | double drop_rate_; |
| 60 | gate_idx_t gates_[MAX_SPLIT_GATES]; |
| 61 | gate_idx_t ngates_; |
| 62 | }; |
| 63 | |
| 64 | #endif // BESS_MODULES_RANDOM_SPLIT_H_ |
no outgoing calls