OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2010 Lalith Suresh |
| 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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
| 19 * Author: Faker Moatamri <faker.moatamri@sophia.inria.fr> |
| 20 * Author: Lalith Suresh <suresh.lalith@gmail.com> |
| 21 */ |
| 22 |
| 23 #ifdef NS3_CLICK |
| 24 |
| 25 #ifndef CLICK_INTERNET_STACK_HELPER_H |
| 26 #define CLICK_INTERNET_STACK_HELPER_H |
| 27 |
| 28 #include "ns3/node-container.h" |
| 29 #include "ns3/net-device-container.h" |
| 30 #include "ns3/packet.h" |
| 31 #include "ns3/ptr.h" |
| 32 #include "ns3/object-factory.h" |
| 33 #include "ns3/ipv4-l3-protocol.h" |
| 34 #include "ns3/ipv6-l3-protocol.h" |
| 35 #include "ns3/trace-helper.h" |
| 36 #include <map> |
| 37 |
| 38 namespace ns3 { |
| 39 |
| 40 class Node; |
| 41 class Ipv4RoutingHelper; |
| 42 |
| 43 /** |
| 44 * \brief aggregate Click/IP/TCP/UDP functionality to existing Nodes. |
| 45 * |
| 46 * This helper has been adapted from the InternetStackHelper class. |
| 47 * |
| 48 * This helper enables pcap and ascii tracing of events in the internet stack |
| 49 * associated with a node. This is substantially similar to the tracing |
| 50 * that happens in device helpers, but the important difference is that, well, |
| 51 * there is no device. This means that the creation of output file names will |
| 52 * change, and also the user-visible methods will not reference devices and |
| 53 * therefore the number of trace enable methods is reduced. |
| 54 * |
| 55 * Normally we eschew multiple inheritance, however, the classes· |
| 56 * PcapUserHelperForIpv4 and AsciiTraceUserHelperForIpv4 are |
| 57 * treated as "mixins". A mixin is a self-contained class that |
| 58 * encapsulates a general attribute or a set of functionality that |
| 59 * may be of interest to many other classes. |
| 60 */ |
| 61 class ClickInternetStackHelper : public PcapHelperForIpv4, public AsciiTraceHelp
erForIpv4 |
| 62 { |
| 63 public: |
| 64 /** |
| 65 * Create a new ClickInternetStackHelper which uses Ipv4ClickRouting for routi
ng |
| 66 */ |
| 67 ClickInternetStackHelper(void); |
| 68 |
| 69 /** |
| 70 * Destroy the ClickInternetStackHelper |
| 71 */ |
| 72 virtual ~ClickInternetStackHelper(void); |
| 73 ClickInternetStackHelper (const ClickInternetStackHelper &); |
| 74 ClickInternetStackHelper &operator = (const ClickInternetStackHelper &o); |
| 75 |
| 76 /** |
| 77 * Return helper internal state to that of a newly constructed one |
| 78 */ |
| 79 void Reset (void); |
| 80 |
| 81 /** |
| 82 * Aggregate implementations of the ns3::Ipv4, ns3::Udp, and ns3::Tcp classes |
| 83 * onto the provided node. This method will assert if called on a node that· |
| 84 * already has an Ipv4 object aggregated to it. |
| 85 *· |
| 86 * \param nodeName The name of the node on which to install the stack. |
| 87 */ |
| 88 void Install (std::string nodeName) const; |
| 89 |
| 90 /** |
| 91 * Aggregate implementations of the ns3::Ipv4, ns3::Udp, and ns3::Tcp classes |
| 92 * onto the provided node. This method will assert if called on a node that· |
| 93 * already has an Ipv4 object aggregated to it. |
| 94 *· |
| 95 * \param node The node on which to install the stack. |
| 96 */ |
| 97 void Install (Ptr<Node> node) const; |
| 98 |
| 99 /** |
| 100 * For each node in the input container, aggregate implementations of the· |
| 101 * ns3::Ipv4, ns3::Udp, and, ns3::Tcp classes. The program will assert· |
| 102 * if this method is called on a container with a node that already has |
| 103 * an Ipv4 object aggregated to it. |
| 104 *· |
| 105 * \param c NodeContainer that holds the set of nodes on which to install the |
| 106 * new stacks. |
| 107 */ |
| 108 void Install (NodeContainer c) const; |
| 109 |
| 110 /** |
| 111 * Aggregate IPv4, UDP, and TCP stacks to all nodes in the simulation |
| 112 */ |
| 113 void InstallAll (void) const; |
| 114 |
| 115 /** |
| 116 * \brief set the Tcp stack which will not need any other parameter. |
| 117 * |
| 118 * This function sets up the tcp stack to the given TypeId. It should not be· |
| 119 * used for NSC stack setup because the nsc stack needs the Library attribute |
| 120 * to be setup, please use instead the version that requires an attribute |
| 121 * and a value. If you choose to use this function anyways to set nsc stack |
| 122 * the default value for the linux library will be used: "liblinux2.6.26.so". |
| 123 * |
| 124 * \param tid the type id, typically it is set to "ns3::TcpL4Protocol" |
| 125 */ |
| 126 void SetTcp(std::string tid); |
| 127 |
| 128 /** |
| 129 * \brief This function is used to setup the Network Simulation Cradle stack w
ith library value. |
| 130 *· |
| 131 * Give the NSC stack a shared library file name to use when creating the· |
| 132 * stack implementation. The attr string is actually the attribute name to· |
| 133 * be setup and val is its value. The attribute is the stack implementation· |
| 134 * to be used and the value is the shared library name. |
| 135 *· |
| 136 * \param tid The type id, for the case of nsc it would be "ns3::NscTcpL4Proto
col"· |
| 137 * \param attr The attribute name that must be setup, for example "Library" |
| 138 * \param val The attribute value, which will be in fact the shared library na
me (example:"liblinux2.6.26.so") |
| 139 */ |
| 140 void SetTcp (std::string tid, std::string attr, const AttributeValue &val);· |
| 141 |
| 142 /** |
| 143 * \brief Set a Click file to be used for a group of nodes. |
| 144 * \param c NodeContainer of nodes |
| 145 * \param clickfile Click file to be used |
| 146 */ |
| 147 void SetClickFile (NodeContainer c, std::string clickfile); |
| 148 |
| 149 /** |
| 150 * \brief Set a Click file to be used for a group of nodes. |
| 151 * \param node Node for which Click file is to be set |
| 152 * \param clickfile Click file to be used |
| 153 */ |
| 154 void SetClickFile (Ptr<Node> node, std::string clickfile); |
| 155 |
| 156 /** |
| 157 * \brief Set a Click file to be used for a group of nodes. |
| 158 * \param c NodeContainer of nodes |
| 159 * \param rt Click file to be used |
| 160 */ |
| 161 void SetRoutingTableElement (NodeContainer c, std::string rt); |
| 162 |
| 163 /** |
| 164 * \brief Set a Click file to be used for a group of nodes. |
| 165 * \param node Node for which Click file is to be set |
| 166 * \param rt Click file to be used |
| 167 */ |
| 168 void SetRoutingTableElement (Ptr<Node> node, std::string rt); |
| 169 private: |
| 170 /** |
| 171 * @brief Enable pcap output the indicated Ipv4 and interface pair. |
| 172 * @internal |
| 173 * |
| 174 * @param prefix Filename prefix to use for pcap files. |
| 175 * @param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing. |
| 176 * @param interface Interface ID on the Ipv4 on which you want to enable traci
ng. |
| 177 */ |
| 178 virtual void EnablePcapIpv4Internal (std::string prefix,· |
| 179 Ptr<Ipv4> ipv4,· |
| 180 uint32_t interface, |
| 181 bool explicitFilename); |
| 182 |
| 183 /** |
| 184 * @brief Enable ascii trace output on the indicated Ipv4 and interface pair. |
| 185 * @internal |
| 186 * |
| 187 * @param stream An OutputStreamWrapper representing an existing file to use |
| 188 * when writing trace data. |
| 189 * @param prefix Filename prefix to use for ascii trace files. |
| 190 * @param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing. |
| 191 * @param interface Interface ID on the Ipv4 on which you want to enable traci
ng. |
| 192 */ |
| 193 virtual void EnableAsciiIpv4Internal (Ptr<OutputStreamWrapper> stream,· |
| 194 std::string prefix,· |
| 195 Ptr<Ipv4> ipv4,· |
| 196 uint32_t interface, |
| 197 bool explicitFilename); |
| 198 |
| 199 void Initialize (void); |
| 200 ObjectFactory m_tcpFactory; |
| 201 |
| 202 /** |
| 203 * \internal |
| 204 */ |
| 205 static void CreateAndAggregateObjectFromTypeId (Ptr<Node> node, const std::str
ing typeId); |
| 206 |
| 207 /** |
| 208 * \internal |
| 209 */ |
| 210 static void Cleanup (void); |
| 211 |
| 212 /** |
| 213 * \internal |
| 214 */ |
| 215 bool PcapHooked (Ptr<Ipv4> ipv4); |
| 216 |
| 217 /** |
| 218 * \internal |
| 219 */ |
| 220 bool AsciiHooked (Ptr<Ipv4> ipv4); |
| 221 |
| 222 /** |
| 223 * \brief IPv4 install state (enabled/disabled) ? |
| 224 */ |
| 225 bool m_ipv4Enabled; |
| 226 |
| 227 /** |
| 228 * \brief Node to Click file mapping |
| 229 */ |
| 230 std::map < Ptr<Node>, std::string > m_nodeToClickFileMap; |
| 231 |
| 232 /** |
| 233 * \brief Node to Routing Table Element mapping |
| 234 */ |
| 235 std::map < Ptr<Node>, std::string > m_nodeToRoutingTableElementMap; |
| 236 }; |
| 237 |
| 238 } // namespace ns3 |
| 239 |
| 240 #endif /* CLICK_INTERNET_STACK_HELPER_H */ |
| 241 |
| 242 #endif // NS3_CLICK |
OLD | NEW |