1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 /* 3 * Copyright (c) 2008 University of Washington 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License version 2 as 7 * published by the Free Software Foundation; 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * 18 * Author: Leonard Tracy <lentracy@u.washington.edu> 19 */ 20 21 #ifndef UAN_HELPER_H 22 #define UAN_HELPER_H 23 24 #include <string> 25 #include "ns3/attribute.h" 26 #include "ns3/object-factory.h" 27 #include "ns3/node-container.h" 28 #include "ns3/net-device-container.h" 29 #include "ns3/uan-net-device.h" 30 31 namespace ns3 { 32 33 class UanChannel; 34 35 /** 36 * \ingroup uan 37 * 38 * UAN configuration helper. 39 */ 40 class UanHelper 41 { 42 public: 43 UanHelper (); //!< Default constructor. 44 virtual ~UanHelper (); //!< Destructor. 45 46 /** 47 * Set MAC attributes. 48 * 49 * \param type The type of ns3::UanMac to create. 50 * \param n0 The name of the attribute to set. 51 * \param v0 The value of the attribute to set. 52 * \param n1 The name of the attribute to set. 53 * \param v1 The value of the attribute to set. 54 * \param n2 The name of the attribute to set. 55 * \param v2 The value of the attribute to set. 56 * \param n3 The name of the attribute to set. 57 * \param v3 The value of the attribute to set. 58 * \param n4 The name of the attribute to set. 59 * \param v4 The value of the attribute to set. 60 * \param n5 The name of the attribute to set. 61 * \param v5 The value of the attribute to set. 62 * \param n6 The name of the attribute to set. 63 * \param v6 The value of the attribute to set. 64 * \param n7 The name of the attribute to set. 65 * \param v7 The value of the attribute to set. 66 * 67 * All the attributes specified in this method should exist 68 * in the requested mac. 69 */ 70 void SetMac (std::string type, 71 std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), 72 std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), 73 std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), 74 std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), 75 std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), 76 std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), 77 std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), 78 std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); 79 80 81 /** 82 * Set PHY attributes. 83 * 84 * \param phyType The type of ns3::UanPhy to create. 85 * \param n0 The name of the attribute to set. 86 * \param v0 The value of the attribute to set. 87 * \param n1 The name of the attribute to set. 88 * \param v1 The value of the attribute to set. 89 * \param n2 The name of the attribute to set. 90 * \param v2 The value of the attribute to set. 91 * \param n3 The name of the attribute to set. 92 * \param v3 The value of the attribute to set. 93 * \param n4 The name of the attribute to set. 94 * \param v4 The value of the attribute to set. 95 * \param n5 The name of the attribute to set. 96 * \param v5 The value of the attribute to set. 97 * \param n6 The name of the attribute to set. 98 * \param v6 The value of the attribute to set. 99 * \param n7 The name of the attribute to set. 100 * \param v7 The value of the attribute to set. 101 * 102 * All the attributes specified in this method should exist 103 * in the requested Phy. 104 */ 105 void SetPhy (std::string phyType, 106 std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), 107 std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), 108 std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), 109 std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), 110 std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), 111 std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), 112 std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), 113 std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); 114 115 116 /** 117 * Set the transducer attributes. 118 * 119 * \param type The type of ns3::Transducer to create. 120 * \param n0 The name of the attribute to set. 121 * \param v0 The value of the attribute to set. 122 * \param n1 The name of the attribute to set. 123 * \param v1 The value of the attribute to set. 124 * \param n2 The name of the attribute to set. 125 * \param v2 The value of the attribute to set. 126 * \param n3 The name of the attribute to set. 127 * \param v3 The value of the attribute to set. 128 * \param n4 The name of the attribute to set. 129 * \param v4 The value of the attribute to set. 130 * \param n5 The name of the attribute to set. 131 * \param v5 The value of the attribute to set. 132 * \param n6 The name of the attribute to set. 133 * \param v6 The value of the attribute to set. 134 * \param n7 The name of the attribute to set. 135 * \param v7 The value of the attribute to set. 136 * 137 * All the attributes specified in this method should exist 138 * in the requested transducer. 139 */ 140 void SetTransducer (std::string type, 141 std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), 142 std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), 143 std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), 144 std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), 145 std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), 146 std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), 147 std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), 148 std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); 149 /** 150 * Enable ascii output on the specified deviceid within the 151 * specified nodeid if it is of type ns3::UanNetDevice and dump 152 * that to the specified stdc++ output stream. 153 * 154 * \param os Output stream. 155 * \param nodeid The id of the node to generate ascii output for. 156 * \param deviceid The id of the device to generate ascii output for. 157 */ 158 static void EnableAscii (std::ostream &os, uint32_t nodeid, uint32_t deviceid); 159 /** 160 * Enable ascii output on each device which is of the 161 * ns3::UanNetDevice type and which is located in the input 162 * device container and dump that to the specified 163 * stdc++ output stream. 164 * 165 * \param os Output stream. 166 * \param d Device container. 167 */ 168 static void EnableAscii (std::ostream &os, NetDeviceContainer d); 169 /** 170 * Enable ascii output on each device which is of the 171 * ns3::UanNetDevice type and which is located in one 172 * of the input node and dump that to the specified 173 * stdc++ output stream. 174 * 175 * \param os Output stream. 176 * \param n Node container. 177 */ 178 static void EnableAscii (std::ostream &os, NodeContainer n); 179 /** 180 * Enable ascii output on each device which is of the 181 * ns3::UanNetDevice type and dump that to the specified 182 * stdc++ output stream. 183 * 184 * \param os Output stream. 185 */ 186 static void EnableAsciiAll (std::ostream &os); 187 188 /** 189 * This method creates a simple ns3::UanChannel (with a default 190 * ns3::UanNoiseModelDefault and ns3::UanPropModelIdeal) and 191 * creates, for each of the input nodes, a new ns3::UanNetDevice 192 * attached to this shared channel. Each ns3::UanNetDevice is also 193 * configured with an ns3::UanTransducerHd, ns3::UanMac, and, 194 * ns3::UanPhy, all of which are created based on the user-specified 195 * attributes specified in UanHelper::SetTransducer, 196 * UanHelper::SetMac, and, UanHelper::SetPhy. 197 * 198 * \param c A set of nodes. 199 * \return The installed netdevices. 200 */ 201 NetDeviceContainer Install (NodeContainer c) const; 202 203 /** 204 * For each of the input nodes, a new ns3::UanNetDevice is attached 205 * to the shared input channel. Each ns3::UanNetDevice is also 206 * configured with an ns3::UanTransducerHd, a ns3::UanMac, and ns3::UanPhy, 207 * all of which are created based on the user-specified attributes 208 * specified in UanHelper::SetTransducer, UanHelper::SetMac, and 209 * UanHelper::SetPhy. 210 * 211 * \param c A set of nodes. 212 * \param channel A channel to use. 213 * \return The installed netdevices. 214 */ 215 NetDeviceContainer Install (NodeContainer c, Ptr<UanChannel> channel) const; 216 217 /** 218 * Create a default an stack. 219 * 220 * The stack includes: 221 * - default channel, ideal propagation and default noise model. 222 * - default physical layer, with UanPhyGen. 223 * - default transducer, half duplex acoustic modem with UanTransducerHd. 224 * - default MAC layer, with UanMacAloha. 225 * 226 * Channel, physical layer, transducer and mac layer are added to the 227 * UanNetDevice and then added to the node. 228 * 229 * \param node A node where to install the uan components. 230 * \param channel A channel to use. 231 * \return The installed UanNetDevice. 232 */ 233 Ptr<UanNetDevice> Install (Ptr<Node> node, Ptr<UanChannel> channel) const; 234 235 /** 236 * Assign a fixed random variable stream number to the random variables 237 * used by this model. Return the number of streams (possibly zero) that 238 * have been assigned. The Install() method should have previously been 239 * called by the user. 240 * 241 * \param c NetDeviceContainer of the set of net devices for which the 242 * UanNetDevice should be modified to use a fixed stream. 243 * \param stream First stream index to use. 244 * \return The number of stream indices assigned by this helper. 245 */ 246 int64_t AssignStreams (NetDeviceContainer c, int64_t stream); 247 248 private: 249 ObjectFactory m_device; //!< The device. 250 ObjectFactory m_mac; //!< The MAC layer. 251 ObjectFactory m_phy; //!< The PHY layer. 252 ObjectFactory m_transducer; //!< The transducer. 253 254 }; 255 256 257 } // end namespace ns3 258 259 #endif /* UAN_HELPER_H */ 260