4 // Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS)
5 // Kompetenzzentrum fuer Satelitenkommunikation (SatCom)
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 "../../Socket/Protocols/INet/UDPSocketHandle.hh"
31 #include "../../Socket/Protocols/INet/ConnectedUDPSocketHandle.hh"
32 #include "../../Socket/Protocols/INet/INetAddressing.hh"
33 #include "../../PPI/SocketReader.hh"
34 #include "../../PPI/SocketWriter.hh"
35 #include "../../PPI/Module.hh"
36 #include "../../PPI/IntervalTimer.hh"
37 #include "../../PPI/Joins.hh"
38 #include "../../PPI/ThrottleBarrier.hh"
39 #include "../../PPI/PassiveQueue.hh"
40 #include "../../PPI/Queueing.hh"
41 #include "../../PPI/CloneSource.hh"
42 #include "../../PPI/Setup.hh"
44 //#include "ppitest.mpp"
46 ///////////////////////////////cc.p////////////////////////////////////////
48 namespace module = senf::ppi::module;
49 namespace connector = senf::ppi::connector;
50 namespace ppi = senf::ppi;
52 // ////////////////////////////////////////////////////////////////////////
56 : public module::Module
58 SENF_PPI_MODULE(RateFilter);
61 connector::ActiveInput input;
62 connector::ActiveOutput output;
64 RateFilter(senf::ClockService::clock_type interval);
69 ppi::IntervalTimer timer;
72 RateFilter::RateFilter(senf::ClockService::clock_type interval)
77 registerEvent(&RateFilter::timeout, timer);
80 void RateFilter::timeout()
85 // ////////////////////////////////////////////////////////////////////////
89 module::ThrottleBarrier barrier;
90 module::PassiveQueue queue;
91 module::CloneSource generator;
92 module::PriorityJoin join;
93 RateFilter rateFilter;
96 connector::PassiveInput & input;
97 connector::ActiveOutput & output;
99 RateStuffer(senf::ClockService::clock_type interval,
105 generator ( packet ),
107 rateFilter ( interval ),
108 input ( barrier.input ),
109 output ( rateFilter.output )
111 ppi::connect( barrier, queue );
112 ppi::connect( queue, join );
113 ppi::connect( generator, join );
114 ppi::connect( join, rateFilter );
116 queue.qdisc(ppi::ThresholdQueueing(high,low));
120 // ////////////////////////////////////////////////////////////////////////
121 // ////////////////////////////////////////////////////////////////////////
125 // 'O' = active connector
126 // '>' or '<' = input connector
128 // +----------------------------------------------------+
131 // [ udpReader ] O-->:---> [ queue ] -->O [ ] |
132 // | [ join ] -->O [ rateFilter] O-->:O--> [ udpWriter ]
133 // | [ generator ] -->O [ ] |
135 // +----------------------------------------------------+
137 int main(int argc, char * argv[])
139 senf::UDPv4ClientSocketHandle inputSocket;
140 inputSocket.bind(senf::INet4SocketAddress("0.0.0.0:44344"));
142 senf::ConnectedUDPv4ClientSocketHandle outputSocket(
143 senf::INet4SocketAddress("localhost:44345"));
145 module::ActiveSocketReader<> udpReader ( inputSocket );
146 RateStuffer stuffer ( 1000000000ul,
147 senf::DataPacket::create(std::string("<idle>\n")),
149 module::PassiveSocketWriter<> udpWriter ( outputSocket );
151 ppi::connect( udpReader, stuffer );
152 ppi::connect( stuffer, udpWriter );
159 ///////////////////////////////cc.e////////////////////////////////////////
161 //#include "ppitest.mpp"
167 // comment-column: 40
168 // c-file-style: "senf"
169 // indent-tabs-mode: nil
170 // ispell-local-dictionary: "american"
171 // compile-command: "scons -u"