4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief ppitest non-inline non-template implementation */
26 //#include "ppitest.hh"
27 //#include "ppitest.ih"
30 #include <senf/Socket/Protocols/INet.hh>
31 #include <senf/PPI.hh>
33 //#include "ppitest.mpp"
35 ///////////////////////////////cc.p////////////////////////////////////////
37 namespace module = senf::ppi::module;
38 namespace connector = senf::ppi::connector;
39 namespace ppi = senf::ppi;
41 // ////////////////////////////////////////////////////////////////////////
45 : public module::Module
47 SENF_PPI_MODULE(RateFilter);
50 connector::ActiveInput<> input;
51 connector::ActiveOutput<> output;
53 RateFilter(senf::ClockService::clock_type interval);
58 ppi::IntervalTimer timer;
61 RateFilter::RateFilter(senf::ClockService::clock_type interval)
66 registerEvent(timer, &RateFilter::timeout);
69 void RateFilter::timeout()
74 // ////////////////////////////////////////////////////////////////////////
78 module::ThrottleBarrier barrier;
79 module::PassiveQueue queue;
80 module::CloneSource generator;
81 module::PriorityJoin join;
82 RateFilter rateFilter;
85 connector::PassiveInput<> & input;
86 connector::ActiveOutput<> & output;
88 RateStuffer(senf::ClockService::clock_type interval,
96 rateFilter ( interval ),
97 input ( barrier.input ),
98 output ( rateFilter.output )
100 ppi::connect( barrier, queue );
101 ppi::connect( queue, join );
102 ppi::connect( generator, join );
103 ppi::connect( join, rateFilter );
105 queue.qdisc(ppi::ThresholdQueueing(high,low));
109 // ////////////////////////////////////////////////////////////////////////
110 // ////////////////////////////////////////////////////////////////////////
114 // 'O' = active connector
115 // '>' or '<' = input connector
117 // +----------------------------------------------------+
120 // [ udpSource ] O-->:---> [ queue ] -->O [ ] |
121 // | [ join ] -->O [ rateFilter] O-->:O--> [ udpSink ]
122 // | [ generator ] -->O [ ] |
124 // +----------------------------------------------------+
126 int main(int argc, char * argv[])
128 senf::UDPv4ClientSocketHandle inputSocket(
129 senf::INet4SocketAddress("0.0.0.0:44344"));
131 senf::ConnectedUDPv4ClientSocketHandle outputSocket(
132 senf::INet4SocketAddress("localhost:44345"));
134 module::ActiveSocketSource<> udpSource ( inputSocket );
135 RateStuffer stuffer ( 1000000000ul,
136 senf::DataPacket::create(std::string("<idle>\n")),
138 module::PassiveSocketSink<> udpSink ( outputSocket );
140 ppi::connect( udpSource, stuffer );
141 ppi::connect( stuffer, udpSink );
148 ///////////////////////////////cc.e////////////////////////////////////////
150 //#include "ppitest.mpp"
156 // comment-column: 40
157 // c-file-style: "senf"
158 // indent-tabs-mode: nil
159 // ispell-local-dictionary: "american"
160 // compile-command: "scons -u"