User Manual, Developers Guide and API Documentation

Fixed.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  * This file is part of openWNS (open Wireless Network Simulator)
00003  * _____________________________________________________________________________
00004  *
00005  * Copyright (C) 2004-2007
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 5, D-52074 Aachen, Germany
00008  * phone: ++49-241-80-27910,
00009  * fax: ++49-241-80-22242
00010  * email: info@openwns.org
00011  * www: http://www.openwns.org
00012  * _____________________________________________________________________________
00013  *
00014  * openWNS is free software; you can redistribute it and/or modify it under the
00015  * terms of the GNU Lesser General Public License version 2 as published by the
00016  * Free Software Foundation;
00017  *
00018  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00019  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00020  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00021  * details.
00022  *
00023  * You should have received a copy of the GNU Lesser General Public License
00024  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00025  *
00026  ******************************************************************************/
00027 
00028 #include <WNS/ldk/sar/Fixed.hpp>
00029 #include <WNS/ldk/Layer.hpp>
00030 #include <WNS/Assure.hpp>
00031 #include <WNS/Ttos.hpp>
00032 
00033 using namespace wns::ldk;
00034 using namespace wns::ldk::sar;
00035 
00036 STATIC_FACTORY_REGISTER_WITH_CREATOR(Fixed, FunctionalUnit, "wns.sar.Fixed", FUNConfigCreator);
00037 
00038 Fixed::Fixed(fun::FUN* fuNet, const wns::pyconfig::View& config) :
00039         SAR<SARCommand>(fuNet, config),
00040         HasReceptor<>(),
00041         HasConnector<>(),
00042         HasDeliverer<>(),
00043         Delayed<Fixed>(),
00044         Cloneable<Fixed>(),
00045         incoming(),
00046         fragmentNumber(0)
00047 {} // SimpleSAR
00048 
00049 void
00050 Fixed::processIncoming(const CompoundPtr& compound)
00051 {
00052     incoming.push_back(compound);
00053 
00054     SARCommand* command = getCommand(compound->getCommandPool());
00055 
00056     MESSAGE_BEGIN(NORMAL, logger, m, "");
00057     m << "received fragment number " << command->magic.fragmentNumber
00058       << " pos: "
00059       << command->magic.pos
00060       << " lastFragment: "
00061       << ( command->peer.lastFragment ? "yes" : "no" )
00062         ;
00063     MESSAGE_END();
00064 
00065     assure(command->magic.fragmentNumber == fragmentNumber,
00066            "Missing fragment number: " + wns::Ttos(fragmentNumber) +
00067            ", received fragment number: " + wns::Ttos(command->magic.fragmentNumber));
00068 
00069     if(!command->peer.lastFragment)
00070     {
00071         ++fragmentNumber;
00072         return;
00073     }
00074 
00075     MESSAGE_BEGIN(NORMAL, logger, m, "");
00076     m << "-> compound complete, starting reassembly";
00077     MESSAGE_END();
00078 
00079     CommandPool* reassembledPCI = getFUN()->createCommandPool();
00080     getFUN()->getProxy()->partialCopy(this, reassembledPCI, compound->getCommandPool());
00081     CompoundPtr reassembled(new Compound(reassembledPCI, compound->getData()));
00082 
00083     incoming.clear();
00084     fragmentNumber = 0;
00085 
00086     getDeliverer()->getAcceptor(reassembled)->onData(reassembled);
00087 } // processIncoming
00088 
00089 
00090 

Generated on Sun May 27 03:31:38 2012 for openWNS by  doxygen 1.5.5