PacketDelayer.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Ext_NetEmu_Modules_PacketDelayer_
18 #define HH_SENF_Ext_NetEmu_Modules_PacketDelayer_ 1
19 
20 // Custom includes
21 #include <queue>
22 #include <random>
23 #include <senf/PPI/Module.hh>
24 #include <senf/PPI/Connectors.hh>
26 
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 
29 namespace senf {
30 namespace emu {
31 
33  : public ppi::module::Module
34  {
36 
37  public:
40 
41  PacketDelayer();
43 
46 
49 
50  template <class ThrottlingDisc>
51  void throttlingDisc(ThrottlingDisc const & disc);
52 
53  private:
54  scheduler::TimerEvent timer_;
56  ClockService::clock_type variation_;
57  std::unique_ptr<std::mt19937> rndEngine_;
58  std::unique_ptr<std::uniform_int_distribution<ClockService::int64_type> > rndDist_;
59  std::queue<ClockService::clock_type> queue_;
60 
61  void init();
62  void enableDelay(bool flag);
63  void onRequest_noDelay();
64  void onRequest_delay();
65  void timeout();
66  void throttleNotification();
67  void unthrottleNotification();
68  };
69 
70 }}
71 
72 //-/////////////////////////////////////////////////////////////////////////////////////////////////
73 #include "PacketDelayer.cci"
74 //#include "PacketDelayer.ct"
75 #include "PacketDelayer.cti"
76 #endif
77 
78 
79 // Local Variables:
80 // mode: c++
81 // fill-column: 100
82 // c-file-style: "senf"
83 // indent-tabs-mode: nil
84 // ispell-local-dictionary: "american"
85 // compile-command: "scons -u test"
86 // comment-column: 40
87 // End:
config::time_type clock_type
ppi::connector::PassiveInput input
#define SENF_PPI_MODULE(name)
ClockService::clock_type variation() const
ClockService::clock_type delay() const
ppi::connector::ActiveOutput output
void throttlingDisc(ThrottlingDisc const &disc)