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/PassiveQueue.hh"
39 #include "PPI/Setup.hh"
41 //#include "ppitest.mpp"
43 ///////////////////////////////cc.p////////////////////////////////////////
45 namespace module = senf::ppi::module;
46 namespace connector = senf::ppi::connector;
47 namespace ppi = senf::ppi;
52 : public module::Module
54 SENF_PPI_MODULE(RateFilter);
57 connector::ActiveInput input;
58 connector::ActiveOutput output;
60 RateFilter(senf::ClockService::clock_type interval) : timer(interval) {
63 registerEvent(&RateFilter::timeout, timer);
71 ppi::IntervalTimer timer;
74 class CopyPacketGenerator
75 : public module::Module
77 SENF_PPI_MODULE(CopyPacketGenerator);
80 connector::PassiveOutput output;
82 CopyPacketGenerator(senf::Packet p) : packet(p) {
84 output.onRequest(&CopyPacketGenerator::request);
98 // 'O' = active connector
99 // '>' or '<' = input connector
101 // [ udpReader ] O--> [ queue ] -->O [ ]
102 // [ join ] -->O [ rateFilter] O--> [ udpWriter ]
103 // [ generator ] -->O [ ]
105 int main(int argc, char * argv[])
107 senf::UDPv4ClientSocketHandle inputSocket;
108 inputSocket.bind(senf::INet4SocketAddress("0.0.0.0:44344"));
110 senf::ConnectedUDPv4ClientSocketHandle outputSocket(
111 senf::INet4SocketAddress("localhost:44345"));
113 module::ActiveSocketReader<> udpReader (inputSocket);
114 module::PassiveQueue queue;
115 CopyPacketGenerator generator (senf::DataPacket::create(std::string("<idle>\n")));
116 module::PriorityJoin join;
117 RateFilter rateFilter (1000000000ul);
118 module::PassiveSocketWriter<> udpWriter (outputSocket);
120 ppi::connect( udpReader, queue );
121 ppi::connect( queue, join );
122 ppi::connect( generator, join );
123 ppi::connect( join, rateFilter );
124 ppi::connect( rateFilter, udpWriter );
131 ///////////////////////////////cc.e////////////////////////////////////////
133 //#include "ppitest.mpp"
139 // comment-column: 40
140 // c-file-style: "senf"
141 // indent-tabs-mode: nil
142 // ispell-local-dictionary: "american"
143 // compile-command: "scons -u"