FlowStatistics.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 
14 #ifndef HH_SENF_Utils_FlowStatistics_
15 #define HH_SENF_Utils_FlowStatistics_ 1
16 
17 // Custom includes
19 #include <senf/Utils/Statistics.hh>
20 
22 namespace senf {
23 
24  namespace Detail {
26  {
27  public:
28  DifferenceSigned(std::uint8_t bits) :
29  mask_(std::uint64_t(1 << bits) - 1),
30  limit_(1 << (bits-1))
31  {
32  }
33 
34  std::int32_t difference(std::uint32_t current, std::uint32_t last)
35  {
36  return std::int32_t(((current - last) & mask_) ^ limit_) - limit_;
37  }
38 
39  private:
40  std::uint32_t const mask_;
41  std::uint32_t const limit_;
42  };
43  }
44 
47  {
48  public:
49  SequenceNumberStatistics(std::uint8_t bits, std::int32_t maxLate);
51 
52  virtual void clear();
53  virtual void reset();
54 
55  bool update(std::uint32_t seqNo, std::uint32_t payloadSize);
56 
57  void dump(std::ostream & os, ClockService::clock_type const & period = ClockService::clock_type(0)) const;
58 
59  std::int32_t maxLate() const;
60 
61  protected:
62  void countGood(std::uint32_t payloadSize);
63 
64  public:
65  std::uint32_t good;
66  std::uint32_t goodBytes;
67  std::uint32_t duplicate;
68  std::uint32_t late;
69  std::uint32_t lateMax;
70  std::uint32_t lost;
71  std::uint32_t lostLate;
72  std::uint32_t resyncs;
73  std::uint64_t goodTotal;
74  std::uint64_t goodBytesTotal;
75 
76  private:
77  std::int32_t const maxLate_;
78  std::uint32_t last_;
79  bool firstUpdateAfterReset_;
80  };
81 
84  {
85  public:
86  TimestampStatistics(std::uint8_t bits);
87  virtual ~TimestampStatistics() {};
88 
89  virtual void clear();
90  virtual void reset();
91 
92  void update(std::uint32_t txTStamp, std::uint32_t rxTStamp, bool updateDelay);
93 
94  public:
97  // no unsigned here!
98  std::int32_t lastPD_;
99 
100  private:
101  bool firstUpdateAfterReset_;
102  };
103 }
104 
106 #include "FlowStatistics.cci"
107 //#include "FlowStatistics.ct"
108 //#include "FlowStatistics.cti"
109 #endif
config::time_type clock_type
DifferenceSigned(std::uint8_t bits)
STL namespace.
StatisticAccumulator< std::uint32_t > pdv
Statistics public header.
void dump(std::ostream &os, DirectoryNode &dir=root())
StatisticAccumulator< std::int32_t > delay
::phoenix::function< detail::clear > const clear
clear phoenix functor
Definition: Phoenix.hh:46
std::int32_t difference(std::uint32_t current, std::uint32_t last)