PacketDropper.cc
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 #include "PacketDropper.hh"
18 //#include "PacketDropper.ih"
19 
20 // Custom includes
21 
22 #define prefix_
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 {
26  route( input, output);
28  lossRate( rate);
29 }
30 
32 {
33  lossRate_ = lossRate;
34  if (lossRate == 0) {
35  input.onRequest( &PacketDropper::onRequest_forwardAll);
36  return;
37  }
38  if (lossRate >= 1) {
39  input.onRequest( &PacketDropper::onRequest_discardAll);
40  return;
41  }
42  input.onRequest( &PacketDropper::onRequest_random);
43  randomDistribution_.reset( new RandomDistribution(lossRate));
44  randomGenerator_.reset( new RandomGenerator(randomEngine_, *randomDistribution_));
45 }
46 
48  const
49 {
50  return lossRate_;
51 }
52 
53 
54 //-/////////////////////////////////////////////////////////////////////////////////////////////////
55 #undef prefix_
56 
57 
58 // Local Variables:
59 // mode: c++
60 // fill-column: 100
61 // comment-column: 40
62 // c-file-style: "senf"
63 // indent-tabs-mode: nil
64 // ispell-local-dictionary: "american"
65 // compile-command: "scons -u test"
66 // End:
Route< connector::InputConnector, connector::OutputConnector > & route(connector::InputConnector &input, connector::OutputConnector &output)
PacketDropper public header.
#define prefix_
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_nanoseconds(clock_type const &v)
ppi::connector::ActiveOutput output
static clock_type now()
ppi::connector::PassiveInput input