LEFT | RIGHT |
(no file at all) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2014 Universita' di Firenze |
| 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: Tommaso Pecorella <tommaso.pecorella@unifi.it> |
| 19 */ |
| 20 #ifndef SIMPLE_NETDEVICE_HELPER_H |
| 21 #define SIMPLE_NETDEVICE_HELPER_H |
| 22 |
| 23 #include <string> |
| 24 |
| 25 #include "ns3/attribute.h" |
| 26 #include "ns3/object-factory.h" |
| 27 #include "ns3/net-device-container.h" |
| 28 #include "ns3/node-container.h" |
| 29 #include "ns3/simple-channel.h" |
| 30 #include "ns3/deprecated.h" |
| 31 |
| 32 namespace ns3 { |
| 33 |
| 34 /** |
| 35 * \brief build a set of SimpleNetDevice objects |
| 36 */ |
| 37 class SimpleNetDeviceHelper |
| 38 { |
| 39 public: |
| 40 /** |
| 41 * Construct a SimpleNetDeviceHelper. |
| 42 */ |
| 43 SimpleNetDeviceHelper (); |
| 44 virtual ~SimpleNetDeviceHelper () {} |
| 45 |
| 46 /** |
| 47 * Each net device must have a queue to pass packets through. |
| 48 * This method allows one to set the type of the queue that is automatically |
| 49 * created when the device is created and attached to a node. |
| 50 * |
| 51 * \param type the type of queue |
| 52 * \param n1 the name of the attribute to set on the queue |
| 53 * \param v1 the value of the attribute to set on the queue |
| 54 * \param n2 the name of the attribute to set on the queue |
| 55 * \param v2 the value of the attribute to set on the queue |
| 56 * \param n3 the name of the attribute to set on the queue |
| 57 * \param v3 the value of the attribute to set on the queue |
| 58 * \param n4 the name of the attribute to set on the queue |
| 59 * \param v4 the value of the attribute to set on the queue |
| 60 * |
| 61 * Set the type of queue to create and associated to each |
| 62 * SimpleNetDevice created through SimpleNetDeviceHelper::Install. |
| 63 */ |
| 64 void SetQueue (std::string type, |
| 65 std::string n1 = "", const AttributeValue &v1 = EmptyAttributeV
alue (), |
| 66 std::string n2 = "", const AttributeValue &v2 = EmptyAttributeV
alue (), |
| 67 std::string n3 = "", const AttributeValue &v3 = EmptyAttributeV
alue (), |
| 68 std::string n4 = "", const AttributeValue &v4 = EmptyAttributeV
alue ()); |
| 69 |
| 70 /** |
| 71 * Each net device must have a channel to pass packets through. |
| 72 * This method allows one to set the type of the channel that is automatically |
| 73 * created when the device is created and attached to a node. |
| 74 * |
| 75 * \param type the type of queue |
| 76 * \param n1 the name of the attribute to set on the queue |
| 77 * \param v1 the value of the attribute to set on the queue |
| 78 * \param n2 the name of the attribute to set on the queue |
| 79 * \param v2 the value of the attribute to set on the queue |
| 80 * \param n3 the name of the attribute to set on the queue |
| 81 * \param v3 the value of the attribute to set on the queue |
| 82 * \param n4 the name of the attribute to set on the queue |
| 83 * \param v4 the value of the attribute to set on the queue |
| 84 * |
| 85 * Set the type of channel to create and associated to each |
| 86 * SimpleNetDevice created through SimpleNetDeviceHelper::Install. |
| 87 */ |
| 88 void SetChannel (std::string type, |
| 89 std::string n1 = "", const AttributeValue &v1 = EmptyAttribut
eValue (), |
| 90 std::string n2 = "", const AttributeValue &v2 = EmptyAttribut
eValue (), |
| 91 std::string n3 = "", const AttributeValue &v3 = EmptyAttribut
eValue (), |
| 92 std::string n4 = "", const AttributeValue &v4 = EmptyAttribut
eValue ()); |
| 93 |
| 94 |
| 95 /** |
| 96 * \param n1 the name of the attribute to set |
| 97 * \param v1 the value of the attribute to set |
| 98 * |
| 99 * Set these attributes on each ns3::SimpleNetDevice created |
| 100 * by SimpleNetDeviceHelper::Install |
| 101 */ |
| 102 void SetDeviceAttribute (std::string n1, const AttributeValue &v1); |
| 103 |
| 104 /** |
| 105 * \param n1 the name of the attribute to set |
| 106 * \param v1 the value of the attribute to set |
| 107 * |
| 108 * Set these attributes on each ns3::CsmaChannel created |
| 109 * by SimpleNetDeviceHelper::Install |
| 110 */ |
| 111 void SetChannelAttribute (std::string n1, const AttributeValue &v1); |
| 112 |
| 113 /** |
| 114 * SimpleNetDevice is Broadcast capable and ARP needing. This function |
| 115 * limits the number of SimpleNetDevices on one channel to two, disables |
| 116 * Broadcast and ARP and enables PointToPoint mode. |
| 117 * |
| 118 * \warning It must be used before installing a NetDevice on a node. |
| 119 * |
| 120 * \param pointToPointMode True for PointToPoint SimpleNetDevice |
| 121 */ |
| 122 void SetNetDevicePointToPointMode (bool pointToPointMode); |
| 123 |
| 124 /** |
| 125 * This method creates an ns3::SimpleChannel with the attributes configured by |
| 126 * SimpleNetDeviceHelper::SetChannelAttribute, an ns3::SimpleNetDevice with th
e attributes |
| 127 * configured by SimpleNetDeviceHelper::SetDeviceAttribute and then adds the d
evice |
| 128 * to the node and attaches the channel to the device. |
| 129 * |
| 130 * \param node The node to install the device in |
| 131 * \returns A container holding the added net device. |
| 132 */ |
| 133 NetDeviceContainer Install (Ptr<Node> node) const; |
| 134 |
| 135 /** |
| 136 * This method creates an ns3::SimpleNetDevice with the attributes configured
by |
| 137 * SimpleNetDeviceHelper::SetDeviceAttribute and then adds the device to the n
ode and |
| 138 * attaches the provided channel to the device. |
| 139 * |
| 140 * \param node The node to install the device in |
| 141 * \param channel The channel to attach to the device. |
| 142 * \returns A container holding the added net device. |
| 143 */ |
| 144 NetDeviceContainer Install (Ptr<Node> node, Ptr<SimpleChannel> channel) const; |
| 145 |
| 146 /** |
| 147 * This method creates an ns3::SimpleChannel with the attributes configured by |
| 148 * SimpleNetDeviceHelper::SetChannelAttribute. For each Ptr<node> in the prov
ided |
| 149 * container: it creates an ns3::SimpleNetDevice (with the attributes |
| 150 * configured by SimpleNetDeviceHelper::SetDeviceAttribute); adds the device t
o the |
| 151 * node; and attaches the channel to the device. |
| 152 * |
| 153 * \param c The NodeContainer holding the nodes to be changed. |
| 154 * \returns A container holding the added net devices. |
| 155 */ |
| 156 NetDeviceContainer Install (const NodeContainer &c) const; |
| 157 |
| 158 /** |
| 159 * For each Ptr<node> in the provided container, this method creates an |
| 160 * ns3::SimpleNetDevice (with the attributes configured by |
| 161 * SimpleNetDeviceHelper::SetDeviceAttribute); adds the device to the node; an
d attaches |
| 162 * the provided channel to the device. |
| 163 * |
| 164 * \param c The NodeContainer holding the nodes to be changed. |
| 165 * \param channel The channel to attach to the devices. |
| 166 * \returns A container holding the added net devices. |
| 167 */ |
| 168 NetDeviceContainer Install (const NodeContainer &c, Ptr<SimpleChannel> channel
) const; |
| 169 |
| 170 private: |
| 171 /** |
| 172 * This method creates an ns3::SimpleNetDevice with the attributes configured
by |
| 173 * SimpleNetDeviceHelper::SetDeviceAttribute and then adds the device to the n
ode and |
| 174 * attaches the provided channel to the device. |
| 175 * |
| 176 * \param node The node to install the device in |
| 177 * \param channelName The name of the channel to attach to the device. |
| 178 * \returns The new net device. |
| 179 */ |
| 180 Ptr<NetDevice> InstallPriv (Ptr<Node> node, Ptr<SimpleChannel> channel) const; |
| 181 |
| 182 ObjectFactory m_queueFactory; //!< Queue factory |
| 183 ObjectFactory m_deviceFactory; //!< NetDevice factory |
| 184 ObjectFactory m_channelFactory; //!< Channel factory |
| 185 bool m_pointToPointMode; //!< Install PointToPoint SimpleNetDevice or Broadcas
t ones |
| 186 |
| 187 }; |
| 188 |
| 189 } // namespace ns3 |
| 190 |
| 191 #endif /* SIMPLE_NETDEVICE_HELPER_H */ |
LEFT | RIGHT |