![]() |
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 #include <COPPER/Transmitter.hpp> 00029 #include <COPPER/Transmission.hpp> 00030 #include <COPPER/Wire.hpp> 00031 00032 using namespace copper; 00033 00034 Transmitter::Transmitter( 00035 const wns::pyconfig::View& pyco, 00036 WireInterface* w) : 00037 // init 00038 wire(w), 00039 dataRate(pyco.get<double>("dataRate")), 00040 sensingTime(pyco.get<double>("sensingTime")), 00041 logger(pyco.get("logger")) 00042 // body 00043 { 00044 } 00045 00046 00047 Transmitter::~Transmitter() 00048 { 00049 } 00050 00051 00052 void 00053 Transmitter::sendData( 00054 const wns::service::dll::BroadcastAddress& /*peerAddress*/, 00055 const wns::osi::PDUPtr& data) 00056 { 00057 BroadcastTransmissionPtr bt(new BroadcastTransmission(data, this)); 00058 00059 MESSAGE_SINGLE(NORMAL, this->logger, "sendData, broadcast"); 00060 00061 this->wire->sendData(bt, this->getDuration(data->getLengthInBits())); 00062 } 00063 00064 00065 void 00066 Transmitter::sendData( 00067 const wns::service::dll::UnicastAddress& peerAddress, 00068 const wns::osi::PDUPtr& data) 00069 { 00070 UnicastTransmissionPtr ut(new UnicastTransmission(peerAddress, data, this)); 00071 00072 MESSAGE_SINGLE(NORMAL, this->logger, "sendData, target's MAC address: " << peerAddress); 00073 00074 wire->sendData(ut, this->getDuration(data->getLengthInBits())); 00075 } 00076 00077 00078 void 00079 Transmitter::cancelData( 00080 const wns::osi::PDUPtr& pdu) 00081 { 00082 MESSAGE_SINGLE(NORMAL, this->logger, "stopping transmission"); 00083 this->wire->stopTransmission(pdu); 00084 } 00085 00086 00087 bool 00088 Transmitter::isFree( 00089 ) const 00090 { 00091 return wire->blockedSince() < this->sensingTime; 00092 } 00093 00094 void 00095 Transmitter::onDataSent(wns::osi::PDUPtr pdu) 00096 { 00097 this->sendNotifies( 00098 &wns::service::phy::copper::DataTransmissionFeedbackInterface::onDataSent, 00099 pdu); 00100 } 00101 00102 simTimeType 00103 Transmitter::getDuration( 00104 Bit len) 00105 { 00106 return len/this->dataRate; 00107 } 00108 00109 00110
1.5.5