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
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
15 \brief EmulatedInterface internal header */
17 #ifndef IH_SENF_Ext_NetEmu_EmulatedInterface_
18 #define IH_SENF_Ext_NetEmu_EmulatedInterface_ 1
21 #include <senf/PPI/MonitorModule.hh>
22 #include <senf/PPI/IntervalTimer.hh>
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
30 class EmulatedReceiver;
31 class EmulatedTransmitter;
32 class ChannelGroupTable;
36 /** \brief Internal: Emulated interface receive filter */
37 class EmulatedInterfaceReceiveFilter
38 : public ppi::module::Module
40 SENF_PPI_MODULE(EmulatedInterfaceReceiveFilter);
42 ppi::connector::PassiveInput<PacketHeader> input;
43 ppi::connector::ActiveOutput<> output;
45 explicit EmulatedInterfaceReceiveFilter(EmulatedReceiver & receiver);
50 EmulatedReceiver & receiver_;
53 /** \brief Internal: Emulated interface transmit filter */
54 class EmulatedInterfaceTransmitFilter
55 : public ppi::module::Module
57 SENF_PPI_MODULE(EmulatedInterfaceTransmitFilter);
59 ppi::connector::PassiveInput<> input;
60 ppi::connector::ActiveOutput<PacketHeader> output;
62 explicit EmulatedInterfaceTransmitFilter(EmulatedTransmitter & transmitter);
70 EmulatedTransmitter & transmitter_;
75 /** \brief Sequence number validation
77 This module will validate the sequence number of all packets. The sequence number is
78 monitored for each peer. If sequence numbers are reversed or missing the module generates an
81 class DroppedPacketChecker
82 : public ppi::module::MonitorModule<PacketHeader>
84 SENF_PPI_MODULE(DroppedPacketChecker);
85 SENF_LOG_CLASS_AREA();
87 DroppedPacketChecker();
89 unsigned droppedPackets() const; ///< Number of dropped packets
91 /** \brief DroppedPacketChecker statistics
92 \see DroppedPacketChecker */
94 boost::signals2::signal<void (float)> droppedPacketsPerSecond;
95 boost::signals2::signal<void (unsigned)> numPeers;
98 void startStatistics(ClockService::clock_type pollInterval);
99 ///< Start statistics generation or change interval
102 virtual void v_handlePacket(PacketHeader const & p) override;
103 void statisticsUpdate();
105 typedef std::map<std::pair<unsigned,unsigned>, boost::uint32_t> SeqNoMap;
107 unsigned droppedPackets_;
108 ppi::IntervalTimer statisticsTimer_;
109 unsigned lastDroppedPackets_;
113 /** \brief Check raw packet transmit time
115 This module will check the time each packet takes from the time it is sent until it is
116 received against a maximum value. Excessively delayed packets will be logged.
118 class DelayTimeChecker
119 : public ppi::module::MonitorModule<PacketHeader>
121 SENF_PPI_MODULE(DelayTimeChecker);
122 SENF_LOG_CLASS_AREA();
125 ClockService::clock_type maxDelay = ClockService::milliseconds(10));
127 void maxDelay(ClockService::clock_type maxDelay);
128 ///< Set maximum allowed packet delay
129 ClockService::clock_type maxDelay() const;
130 ///< Get current maxDelay() value
132 unsigned delayedPackets() const; ///< Number of packets with delay > maxDelay()
133 ClockService::clock_type maxPacketDelay() const;
134 ///< Maximum packet delay encountered
136 /** \brief DelayTimeChecker statistics
137 \see DelayTimeChecker */
139 boost::signals2::signal<void (float,float,float)> packetDelay;
142 void startStatistics(ClockService::clock_type pollInterval);
145 virtual void v_handlePacket(PacketHeader const & p) override;
146 void statisticsUpdate();
148 ClockService::clock_type maxDelay_;
149 unsigned delayedPackets_;
150 ClockService::clock_type maxPacketDelay_;
151 ppi::IntervalTimer statisticsTimer_;
152 ClockService::clock_type minDelayStat_, totalDelayStat_, maxDelayStat_;
157 : public ppi::module::Module
159 SENF_PPI_MODULE(AdvancePacket);
161 ppi::connector::PassiveInput<PacketHeader> input;
162 ppi::connector::ActiveOutput<> output;
172 //-/////////////////////////////////////////////////////////////////////////////////////////////////
179 // comment-column: 40
180 // c-file-style: "senf"
181 // indent-tabs-mode: nil
182 // ispell-local-dictionary: "american"
183 // compile-command: "scons -u test"