4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief ppitest non-inline non-template implementation */
31 //#include "ppitest.hh"
32 //#include "ppitest.ih"
35 #include <senf/Socket/Protocols/INet.hh>
36 #include <senf/PPI.hh>
38 //#include "ppitest.mpp"
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
42 namespace module = senf::ppi::module;
43 namespace connector = senf::ppi::connector;
44 namespace ppi = senf::ppi;
46 //-////////////////////////////////////////////////////////////////////////
50 : public module::Module
52 SENF_PPI_MODULE(RateFilter);
55 connector::ActiveInput<> input;
56 connector::ActiveOutput<> output;
58 RateFilter(senf::ClockService::clock_type interval);
63 ppi::IntervalTimer timer;
66 RateFilter::RateFilter(senf::ClockService::clock_type interval)
71 registerEvent(timer, &RateFilter::timeout);
74 void RateFilter::timeout()
79 //-////////////////////////////////////////////////////////////////////////
83 module::ThrottleBarrier barrier;
84 module::PassiveQueue queue;
85 module::CloneSource generator;
86 module::PriorityJoin join;
87 RateFilter rateFilter;
90 connector::PassiveInput<> & input;
91 connector::ActiveOutput<> & output;
93 RateStuffer(senf::ClockService::clock_type interval,
101 rateFilter ( interval ),
102 input ( barrier.input ),
103 output ( rateFilter.output )
105 ppi::connect( barrier, queue );
106 ppi::connect( queue, join );
107 ppi::connect( generator, join );
108 ppi::connect( join, rateFilter );
110 queue.qdisc(ppi::ThresholdQueueing(high,low));
114 //-////////////////////////////////////////////////////////////////////////
115 //-////////////////////////////////////////////////////////////////////////
119 // 'O' = active connector
120 // '>' or '<' = input connector
122 // +----------------------------------------------------+
125 // [ udpSource ] O-->:---> [ queue ] -->O [ ] |
126 // | [ join ] -->O [ rateFilter] O-->:O--> [ udpSink ]
127 // | [ generator ] -->O [ ] |
129 // +----------------------------------------------------+
131 int main(int argc, char * argv[])
133 senf::UDPv4ClientSocketHandle inputSocket(
134 senf::INet4SocketAddress("0.0.0.0:44344"));
136 senf::ConnectedUDPv4ClientSocketHandle outputSocket(
137 senf::INet4SocketAddress("localhost:44345"));
139 module::ActiveSocketSource<> udpSource ( inputSocket );
140 RateStuffer stuffer ( 1000000000ul,
141 senf::DataPacket::create(std::string("<idle>\n")),
143 module::PassiveSocketSink<> udpSink ( outputSocket );
145 ppi::connect( udpSource, stuffer );
146 ppi::connect( stuffer, udpSink );
153 //-/////////////////////////////////////////////////////////////////////////////////////////////////
155 //#include "ppitest.mpp"
161 // comment-column: 40
162 // c-file-style: "senf"
163 // indent-tabs-mode: nil
164 // ispell-local-dictionary: "american"
165 // compile-command: "scons -u"