|
| 1 | +#ifndef CUSTOM_ONOFF_HELPER_H |
| 2 | +#define CUSTOM_ONOFF_HELPER_H |
| 3 | + |
| 4 | +#include <stdint.h> |
| 5 | +#include <string> |
| 6 | +#include "ns3/object-factory.h" |
| 7 | +#include "ns3/address.h" |
| 8 | +#include "ns3/attribute.h" |
| 9 | +#include "ns3/net-device.h" |
| 10 | +#include "ns3/node-container.h" |
| 11 | +#include "ns3/application-container.h" |
| 12 | +#include "ns3/onoff-application.h" |
| 13 | + |
| 14 | +namespace ns3 { |
| 15 | + |
| 16 | +class DataRate; |
| 17 | + |
| 18 | +/** |
| 19 | + * \ingroup onoff |
| 20 | + * \brief A helper to make it easier to instantiate an ns3::CustomOnOffApplication |
| 21 | + * on a set of nodes. |
| 22 | + */ |
| 23 | +class CustomOnOffHelper |
| 24 | +{ |
| 25 | +public: |
| 26 | + /** |
| 27 | + * Create an CustomOnOffHelper to make it easier to work with CustomOnOffApplications |
| 28 | + * |
| 29 | + * \param protocol the name of the protocol to use to send traffic |
| 30 | + * by the applications. This string identifies the socket |
| 31 | + * factory type used to create sockets for the applications. |
| 32 | + * A typical value would be ns3::UdpSocketFactory. |
| 33 | + * \param address the address of the remote node to send traffic |
| 34 | + * to. |
| 35 | + */ |
| 36 | + CustomOnOffHelper (std::string protocol, Address address); |
| 37 | + |
| 38 | + /** |
| 39 | + * Helper function used to set the underlying application attributes. |
| 40 | + * |
| 41 | + * \param name the name of the application attribute to set |
| 42 | + * \param value the value of the application attribute to set |
| 43 | + */ |
| 44 | + void SetAttribute (std::string name, const AttributeValue &value); |
| 45 | + |
| 46 | + /** |
| 47 | + * Helper function to set a constant rate source. Equivalent to |
| 48 | + * setting the attributes OnTime to constant 1000 seconds, OffTime to |
| 49 | + * constant 0 seconds, and the DataRate and PacketSize set accordingly |
| 50 | + * |
| 51 | + * \param dataRate DataRate object for the sending rate |
| 52 | + * \param packetSize size in bytes of the packet payloads generated |
| 53 | + */ |
| 54 | + void SetConstantRate (DataRate dataRate, uint32_t packetSize = 512); |
| 55 | + |
| 56 | + /** |
| 57 | + * Install an ns3::CustomOnOffApplication on each node of the input container |
| 58 | + * configured with all the attributes set with SetAttribute. |
| 59 | + * |
| 60 | + * \param c NodeContainer of the set of nodes on which an CustomOnOffApplication |
| 61 | + * will be installed. |
| 62 | + * \returns Container of Ptr to the applications installed. |
| 63 | + */ |
| 64 | + ApplicationContainer Install (NodeContainer c) const; |
| 65 | + |
| 66 | + /** |
| 67 | + * Install an ns3::CustomOnOffApplication on the node configured with all the |
| 68 | + * attributes set with SetAttribute. |
| 69 | + * |
| 70 | + * \param node The node on which an CustomOnOffApplication will be installed. |
| 71 | + * \returns Container of Ptr to the applications installed. |
| 72 | + */ |
| 73 | + ApplicationContainer Install (Ptr<Node> node) const; |
| 74 | + |
| 75 | + /** |
| 76 | + * Install an ns3::CustomOnOffApplication on the node configured with all the |
| 77 | + * attributes set with SetAttribute. |
| 78 | + * |
| 79 | + * \param nodeName The node on which an CustomOnOffApplication will be installed. |
| 80 | + * \returns Container of Ptr to the applications installed. |
| 81 | + */ |
| 82 | + ApplicationContainer Install (std::string nodeName) const; |
| 83 | + |
| 84 | + /** |
| 85 | + * Assign a fixed random variable stream number to the random variables |
| 86 | + * used by this model. Return the number of streams (possibly zero) that |
| 87 | + * have been assigned. The Install() method should have previously been |
| 88 | + * called by the user. |
| 89 | + * |
| 90 | + * \param stream first stream index to use |
| 91 | + * \param c NodeContainer of the set of nodes for which the CustomOnOffApplication |
| 92 | + * should be modified to use a fixed stream |
| 93 | + * \return the number of stream indices assigned by this helper |
| 94 | + */ |
| 95 | + int64_t AssignStreams (NodeContainer c, int64_t stream); |
| 96 | + |
| 97 | +private: |
| 98 | + /** |
| 99 | + * Install an ns3::CustomOnOffApplication on the node configured with all the |
| 100 | + * attributes set with SetAttribute. |
| 101 | + * |
| 102 | + * \param node The node on which an CustomOnOffApplication will be installed. |
| 103 | + * \returns Ptr to the application installed. |
| 104 | + */ |
| 105 | + Ptr<Application> InstallPriv (Ptr<Node> node) const; |
| 106 | + |
| 107 | + ObjectFactory m_factory; //!< Object factory. |
| 108 | +}; |
| 109 | + |
| 110 | +} // namespace ns3 |
| 111 | + |
| 112 | +#endif // CUSTOM_ONOFF_HELPER_H |
0 commit comments