![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2009 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 #ifndef COPPER_RECEIVER_HPP 00029 #define COPPER_RECEIVER_HPP 00030 00031 #include <COPPER/Transmission.hpp> 00032 #include <COPPER/ReceiverInterface.hpp> 00033 00034 #include <WNS/service/phy/copper/Handler.hpp> 00035 #include <WNS/service/phy/copper/CarrierSensing.hpp> 00036 #include <WNS/service/phy/copper/Notification.hpp> 00037 #include <WNS/service/dll/Address.hpp> 00038 #include <WNS/distribution/Distribution.hpp> 00039 #include <WNS/logger/Logger.hpp> 00040 #include <WNS/pyconfig/View.hpp> 00041 #include <WNS/Subject.hpp> 00042 00043 namespace copper { 00044 00045 class WireInterface; 00046 00053 class Receiver : 00054 virtual public wns::service::phy::copper::Notification, 00055 virtual public ReceiverInterface 00056 { 00057 typedef wns::service::phy::copper::Handler 00058 Handler; 00059 00060 typedef wns::service::phy::copper::CarrierSensing 00061 CarrierSensing; 00062 00066 struct OnData 00067 { 00068 OnData(const wns::osi::PDUPtr& _pdu, double _ber, bool _collision) : 00069 pdu(_pdu), 00070 ber(_ber), 00071 collision(_collision) 00072 { 00073 } 00074 00075 void 00076 operator()(Handler* handler) 00077 { 00078 handler->onData(this->pdu, this->ber, this->collision); 00079 } 00080 00081 private: 00082 wns::osi::PDUPtr pdu; 00083 double ber; 00084 bool collision; 00085 }; 00086 00087 public: 00091 Receiver(const wns::pyconfig::View& _pyco, WireInterface* _wire); 00092 00096 virtual 00097 ~Receiver(); 00098 00103 virtual bool 00104 onData(const UnicastTransmissionPtr& transmission); 00105 00106 virtual bool 00107 onData(const BroadcastTransmissionPtr& transmission); 00108 00109 virtual void 00110 onCopperFree(); 00111 00112 virtual void 00113 onCopperBusy(); 00114 00115 virtual void 00116 onCollision(); 00118 00123 virtual void 00124 setDLLUnicastAddress(const wns::service::dll::UnicastAddress& _macAddress); 00126 00127 private: 00131 wns::service::dll::UnicastAddress macAddress; 00132 00136 WireInterface* wire; 00137 00141 wns::distribution::Distribution* berDist; 00142 00149 simTimeType sensingTime; 00150 00154 wns::logger::Logger logger; 00155 }; 00156 } 00157 00158 #endif // NOT defined COPPER_RECEIVER_HPP 00159 00160
1.5.5