00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2006,2007 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Based on yans-wifi-channel.h by 00019 * Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00020 */ 00021 #ifndef NS2EXT_WIFI_CHANNEL_H 00022 #define NS2EXT_WIFI_CHANNEL_H 00023 00024 #include <vector> 00025 #include <stdint.h> 00026 #include "ns3/packet.h" 00027 #include "wifi-channel.h" 00028 #include "wifi-mode.h" 00029 #include "wifi-preamble.h" 00030 00031 namespace ns3 { 00032 00033 class NetDevice; 00034 class PropagationLossModel; 00035 class PropagationDelayModel; 00036 class Ns2ExtWifiPhy; 00037 00038 /** 00039 * \brief A Ns2Ext wifi channel 00040 * 00041 * This wifi channel implements the propagation model described in 00042 * "Yet Another Network Simulator", (http://cutebugs.net/files/wns2-yans.pdf). 00043 * 00044 * This class is expected to be used in tandem with the ns3::Ns2ExtWifiPhy 00045 * class and contains a ns3::PropagationLossModel and a ns3::PropagationDelayModel. 00046 * By default, no propagation models are set so, it is the caller's responsability 00047 * to set them before using the channel. 00048 */ 00049 class Ns2ExtWifiChannel : public WifiChannel 00050 { 00051 public: 00052 static TypeId GetTypeId (void); 00053 00054 Ns2ExtWifiChannel (); 00055 virtual ~Ns2ExtWifiChannel (); 00056 00057 // inherited from Channel. 00058 virtual uint32_t GetNDevices (void) const; 00059 virtual Ptr<NetDevice> GetDevice (uint32_t i) const; 00060 00061 void Add (Ptr<Ns2ExtWifiPhy> phy); 00062 00063 /** 00064 * \param loss the new propagation loss model. 00065 */ 00066 void SetPropagationLossModel (Ptr<PropagationLossModel> loss); 00067 /** 00068 * \param delay the new propagation delay model. 00069 */ 00070 void SetPropagationDelayModel (Ptr<PropagationDelayModel> delay); 00071 00072 /** 00073 * \param sender the device from which the packet is originating. 00074 * \param packet the packet to send 00075 * \param txPowerDbm the tx power associated to the packet 00076 * \param wifiMode the tx mode associated to the packet 00077 * \param preamble the preamble associated to the packet 00078 * 00079 * This method should not be invoked by normal users. It is 00080 * currently invoked only from WifiPhy::Send. 00081 */ 00082 void Send (Ptr<Ns2ExtWifiPhy> sender, Ptr<const Packet> packet, double txPowerDbm, 00083 WifiMode wifiMode, WifiPreamble preamble) const; 00084 00085 private: 00086 typedef std::vector<Ptr<Ns2ExtWifiPhy> > PhyList; 00087 void Receive (uint32_t i, Ptr<Packet> packet, double rxPowerDbm, 00088 WifiMode txMode, WifiPreamble preamble) const; 00089 00090 00091 PhyList m_phyList; 00092 Ptr<PropagationLossModel> m_loss; 00093 Ptr<PropagationDelayModel> m_delay; 00094 }; 00095 00096 } // namespace ns3 00097 00098 00099 #endif /* NS2EXT_WIFI_CHANNEL_H */