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 ON_OFF_HELPER_H 00021 #define ON_OFF_HELPER_H 00022 00023 #include <stdint.h> 00024 #include <string> 00025 #include "ns3/object-factory.h" 00026 #include "ns3/address.h" 00027 #include "ns3/attribute.h" 00028 #include "ns3/net-device.h" 00029 #include "node-container.h" 00030 #include "application-container.h" 00031 00032 namespace ns3 { 00033 00034 /** 00035 * \brief instanciate an ns3::OnOffApplication on a set of nodes. 00036 */ 00037 class OnOffHelper 00038 { 00039 public: 00040 /** 00041 * \param protocol the name of the protocol to use to send traffic 00042 * by the applications. This string identifies the socket 00043 * factory type used to create sockets for the applications. 00044 * A typical value would be ns3::UdpSocketFactory. 00045 * \param address the address of the remote node to send traffic 00046 * to. 00047 */ 00048 OnOffHelper (std::string protocol, Address address); 00049 00050 /** 00051 * \param name the name of the application attribute to set 00052 * \param value the value of the application attribute to set 00053 */ 00054 void SetAttribute (std::string name, const AttributeValue &value); 00055 00056 /** 00057 * Install an ns3::OnOffApplication on each node of the input container 00058 * configured with all the attributes set with SetAttribute. 00059 * 00060 * \param c NodeContainer of the set of nodes on which an OnOffApplication 00061 * will be installed. 00062 * \returns Container of Ptr to the applications installed. 00063 */ 00064 ApplicationContainer Install (NodeContainer c) const; 00065 00066 /** 00067 * Install an ns3::OnOffApplication on the node configured with all the 00068 * attributes set with SetAttribute. 00069 * 00070 * \param node The node on which an OnOffApplication will be installed. 00071 * \returns Container of Ptr to the applications installed. 00072 */ 00073 ApplicationContainer Install (Ptr<Node> node) const; 00074 00075 private: 00076 /** 00077 * Install an ns3::OnOffApplication on the node configured with all the 00078 * attributes set with SetAttribute. 00079 * 00080 * \param node The node on which an OnOffApplication will be installed. 00081 * \returns Ptr to the application installed. 00082 */ 00083 Ptr<Application> InstallPriv (Ptr<Node> node) const; 00084 std::string m_protocol; 00085 Address m_remote; 00086 ObjectFactory m_factory; 00087 }; 00088 00089 } // namespace ns3 00090 00091 #endif /* ON_OFF_HELPER_H */ 00092