00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2008 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 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #ifndef YANS_WIFI_HELPER_H 00021 #define YANS_WIFI_HELPER_H 00022 00023 #include "wifi-helper.h" 00024 #include "ns3/yans-wifi-channel.h" 00025 00026 namespace ns3 { 00027 00028 /** 00029 * \brief manage and create wifi channel objects for the yans model. 00030 * 00031 * The intent of this class is to make it easy to create a channel object 00032 * which implements the yans channel model. The yans channel model is described 00033 * in "Yet Another Network Simulator", http://cutebugs.net/files/wns2-yans.pdf 00034 */ 00035 class YansWifiChannelHelper 00036 { 00037 public: 00038 /** 00039 * Create a channel helper without any parameter set. The user must set 00040 * them all to be able to call Create later. 00041 */ 00042 YansWifiChannelHelper (); 00043 00044 /** 00045 * Create a channel helper in a default working state. By default, we create 00046 * a channel model with a propagation delay equal to a constant, the speed of light, 00047 * and a propagation loss based on a log distance model with a reference loss of 46.6777 dB 00048 * at reference distance of 1m. 00049 */ 00050 static YansWifiChannelHelper Default (void); 00051 00052 /** 00053 * \param name the name of the model to add 00054 * \param n0 the name of the attribute to set 00055 * \param v0 the value of the attribute to set 00056 * \param n1 the name of the attribute to set 00057 * \param v1 the value of the attribute to set 00058 * \param n2 the name of the attribute to set 00059 * \param v2 the value of the attribute to set 00060 * \param n3 the name of the attribute to set 00061 * \param v3 the value of the attribute to set 00062 * \param n4 the name of the attribute to set 00063 * \param v4 the value of the attribute to set 00064 * \param n5 the name of the attribute to set 00065 * \param v5 the value of the attribute to set 00066 * \param n6 the name of the attribute to set 00067 * \param v6 the value of the attribute to set 00068 * \param n7 the name of the attribute to set 00069 * \param v7 the value of the attribute to set 00070 * 00071 * Add a propagation loss model to the set of currently-configured loss models. 00072 * This method is additive to allow you to construct complex propagation loss models 00073 * such as a log distance + jakes model, etc. 00074 */ 00075 void AddPropagationLoss (std::string name, 00076 std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), 00077 std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), 00078 std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), 00079 std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), 00080 std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), 00081 std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), 00082 std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), 00083 std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); 00084 /** 00085 * \param name the name of the model to set 00086 * \param n0 the name of the attribute to set 00087 * \param v0 the value of the attribute to set 00088 * \param n1 the name of the attribute to set 00089 * \param v1 the value of the attribute to set 00090 * \param n2 the name of the attribute to set 00091 * \param v2 the value of the attribute to set 00092 * \param n3 the name of the attribute to set 00093 * \param v3 the value of the attribute to set 00094 * \param n4 the name of the attribute to set 00095 * \param v4 the value of the attribute to set 00096 * \param n5 the name of the attribute to set 00097 * \param v5 the value of the attribute to set 00098 * \param n6 the name of the attribute to set 00099 * \param v6 the value of the attribute to set 00100 * \param n7 the name of the attribute to set 00101 * \param v7 the value of the attribute to set 00102 * 00103 * Configure a propagation delay for this channel. 00104 */ 00105 void SetPropagationDelay (std::string name, 00106 std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), 00107 std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), 00108 std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), 00109 std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), 00110 std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), 00111 std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), 00112 std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), 00113 std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); 00114 00115 /** 00116 * \returns a new channel 00117 * 00118 * Create a channel based on the configuration parameters set previously. 00119 */ 00120 Ptr<YansWifiChannel> Create (void) const; 00121 00122 private: 00123 std::vector<ObjectFactory> m_propagationLoss; 00124 ObjectFactory m_propagationDelay; 00125 }; 00126 00127 /** 00128 * \brief Make it easy to create and manager PHY objects for the yans model. 00129 * 00130 * The yans PHY model is described in "Yet Another Network Simulator", 00131 * http://cutebugs.net/files/wns2-yans.pdf 00132 * 00133 * The Pcap and ascii traces generated by the EnableAscii and EnablePcap methods defined 00134 * in this class correspond to PHY-level traces. That is, they capture traffic 00135 * at the top of the PHY layer, just below the MAC layer. 00136 */ 00137 class YansWifiPhyHelper : public WifiPhyHelper 00138 { 00139 public: 00140 /** 00141 * Create a phy helper without any parameter set. The user must set 00142 * them all to be able to call Install later. 00143 */ 00144 YansWifiPhyHelper (); 00145 00146 /** 00147 * Create a phy helper in a default working state. 00148 */ 00149 static YansWifiPhyHelper Default (void); 00150 00151 /** 00152 * \param channel the channel to associate to this helper 00153 * 00154 * Every PHY created by a call to Install is associated to this channel. 00155 */ 00156 void SetChannel (Ptr<YansWifiChannel> channel); 00157 /** 00158 * \param name the name of the attribute to set 00159 * \param v the value of the attribute 00160 * 00161 * Set an attribute of the underlying PHY object. 00162 */ 00163 void Set (std::string name, const AttributeValue &v); 00164 /** 00165 * \param name the name of the error rate model to set. 00166 * \param n0 the name of the attribute to set 00167 * \param v0 the value of the attribute to set 00168 * \param n1 the name of the attribute to set 00169 * \param v1 the value of the attribute to set 00170 * \param n2 the name of the attribute to set 00171 * \param v2 the value of the attribute to set 00172 * \param n3 the name of the attribute to set 00173 * \param v3 the value of the attribute to set 00174 * \param n4 the name of the attribute to set 00175 * \param v4 the value of the attribute to set 00176 * \param n5 the name of the attribute to set 00177 * \param v5 the value of the attribute to set 00178 * \param n6 the name of the attribute to set 00179 * \param v6 the value of the attribute to set 00180 * \param n7 the name of the attribute to set 00181 * \param v7 the value of the attribute to set 00182 * 00183 * Set the error rate model and its attributes to use when Install is called. 00184 */ 00185 void SetErrorRateModel (std::string name, 00186 std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), 00187 std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), 00188 std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), 00189 std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), 00190 std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), 00191 std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), 00192 std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), 00193 std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); 00194 00195 /** 00196 * \param filename filename prefix to use for pcap files. 00197 * \param nodeid the id of the node to generate pcap output for. 00198 * \param deviceid the id of the device to generate pcap output for. 00199 * 00200 * Generate a pcap file which contains the link-level data observed 00201 * by the specified deviceid within the specified nodeid. The pcap 00202 * data is stored in the file prefix-nodeid-deviceid.pcap. 00203 * 00204 * This method should be invoked after the network topology has 00205 * been fully constructed. 00206 */ 00207 static void EnablePcap (std::string filename, uint32_t nodeid, uint32_t deviceid); 00208 /** 00209 * \param filename filename prefix to use for pcap files. 00210 * \param d container of devices of type ns3::WifiNetDevice 00211 * 00212 * Enable pcap output on each input device which is of the 00213 * ns3::WifiNetDevice type. 00214 */ 00215 static void EnablePcap (std::string filename, NetDeviceContainer d); 00216 /** 00217 * \param filename filename prefix to use for pcap files. 00218 * \param n container of nodes. 00219 * 00220 * Enable pcap output on each device which is of the 00221 * ns3::WifiNetDevice type and which is located in one of the 00222 * input nodes. 00223 */ 00224 static void EnablePcap (std::string filename, NodeContainer n); 00225 /** 00226 * \param filename filename prefix to use for pcap files. 00227 * 00228 * Enable pcap output on each device which is of the 00229 * ns3::WifiNetDevice type 00230 */ 00231 static void EnablePcapAll (std::string filename); 00232 00233 /** 00234 * \param os output stream 00235 * \param nodeid the id of the node to generate ascii output for. 00236 * \param deviceid the id of the device to generate ascii output for. 00237 * 00238 * Enable ascii output on the specified deviceid within the 00239 * specified nodeid if it is of type ns3::WifiNetDevice and dump 00240 * that to the specified stdc++ output stream. 00241 */ 00242 static void EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid); 00243 /** 00244 * \param os output stream 00245 * \param d device container 00246 * 00247 * Enable ascii output on each device which is of the 00248 * ns3::WifiNetDevice type and which is located in the input 00249 * device container and dump that to the specified 00250 * stdc++ output stream. 00251 */ 00252 static void EnableAscii (std::ostream &os, NetDeviceContainer d); 00253 /** 00254 * \param os output stream 00255 * \param n node container 00256 * 00257 * Enable ascii output on each device which is of the 00258 * ns3::WifiNetDevice type and which is located in one 00259 * of the input node and dump that to the specified 00260 * stdc++ output stream. 00261 */ 00262 static void EnableAscii (std::ostream &os, NodeContainer n); 00263 /** 00264 * \param os output stream 00265 * 00266 * Enable ascii output on each device which is of the 00267 * ns3::WifiNetDevice type and dump that to the specified 00268 * stdc++ output stream. 00269 */ 00270 static void EnableAsciiAll (std::ostream &os); 00271 00272 private: 00273 /** 00274 * \param node the node on which we wish to create a wifi PHY 00275 * \param device the device within which this PHY will be created 00276 * \returns a newly-created PHY object. 00277 * 00278 * This method implements the pure virtual method defined in \ref ns3::WifiPhyHelper. 00279 */ 00280 virtual Ptr<WifiPhy> Create (Ptr<Node> node, Ptr<WifiNetDevice> device) const; 00281 00282 ObjectFactory m_phy; 00283 ObjectFactory m_errorRateModel; 00284 Ptr<YansWifiChannel> m_channel; 00285 }; 00286 00287 } // namespace ns3 00288 00289 #endif /* YANS_WIFI_HELPER_H */