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;
49 // ////////////////////////////////////////////////////////////////////////
53 : public module::Module
55 SENF_PPI_MODULE(RateFilter);
58 connector::ActiveInput input;
59 connector::ActiveOutput output;
61 RateFilter(senf::ClockService::clock_type interval);
66 ppi::IntervalTimer timer;
69 RateFilter::RateFilter(senf::ClockService::clock_type interval)
74 registerEvent(&RateFilter::timeout, timer);
77 void RateFilter::timeout()
82 // ////////////////////////////////////////////////////////////////////////
83 // CopyPacketGenerator
85 class CopyPacketGenerator
86 : public module::Module
88 SENF_PPI_MODULE(CopyPacketGenerator);
91 connector::PassiveOutput output;
93 CopyPacketGenerator(senf::Packet p);
101 CopyPacketGenerator::CopyPacketGenerator(senf::Packet p)
105 output.onRequest(&CopyPacketGenerator::request);
108 void CopyPacketGenerator::request()
113 // ////////////////////////////////////////////////////////////////////////
114 // ////////////////////////////////////////////////////////////////////////
118 // 'O' = active connector
119 // '>' or '<' = input connector
121 // [ udpReader ] O--> [ queue ] -->O [ ]
122 // [ join ] -->O [ rateFilter] O--> [ udpWriter ]
123 // [ generator ] -->O [ ]
125 int main(int argc, char * argv[])
127 senf::UDPv4ClientSocketHandle inputSocket;
128 inputSocket.bind(senf::INet4SocketAddress("0.0.0.0:44344"));
130 senf::ConnectedUDPv4ClientSocketHandle outputSocket(
131 senf::INet4SocketAddress("localhost:44345"));
133 module::ActiveSocketReader<> udpReader (inputSocket);
134 module::PassiveQueue queue;
135 CopyPacketGenerator generator (senf::DataPacket::create(std::string("<idle>\n")));
136 module::PriorityJoin join;
137 RateFilter rateFilter (1000000000ul);
138 module::PassiveSocketWriter<> udpWriter (outputSocket);
140 ppi::connect( udpReader, queue );
141 ppi::connect( queue, join );
142 ppi::connect( generator, join );
143 ppi::connect( join, rateFilter );
144 ppi::connect( rateFilter, udpWriter );
151 ///////////////////////////////cc.e////////////////////////////////////////
153 //#include "ppitest.mpp"
159 // comment-column: 40
160 // c-file-style: "senf"
161 // indent-tabs-mode: nil
162 // ispell-local-dictionary: "american"
163 // compile-command: "scons -u"