26 #include "ns3/address.h"    27 #include "ns3/inet-socket-address.h"    28 #include "ns3/inet6-socket-address.h"    29 #include "ns3/packet-socket-address.h"    31 #include "ns3/nstime.h"    32 #include "ns3/data-rate.h"    33 #include "ns3/random-variable-stream.h"    34 #include "ns3/socket.h"    35 #include "ns3/simulator.h"    36 #include "ns3/socket-factory.h"    37 #include "ns3/packet.h"    38 #include "ns3/uinteger.h"    39 #include "ns3/trace-source-accessor.h"    41 #include "ns3/udp-socket-factory.h"    42 #include "ns3/string.h"    43 #include "ns3/pointer.h"    56     .SetGroupName(
"Applications")
    58     .AddAttribute (
"DataRate", 
"The data rate in on state.",
    62     .AddAttribute (
"PacketSize", 
"The size of packets sent in on state",
    65                    MakeUintegerChecker<uint32_t> (1))
    66     .AddAttribute (
"Remote", 
"The address of the destination",
    70     .AddAttribute (
"OnTime", 
"A RandomVariableStream used to pick the duration of the 'On' state.",
    71                    StringValue (
"ns3::ConstantRandomVariable[Constant=1.0]"),
    73                    MakePointerChecker <RandomVariableStream>())
    74     .AddAttribute (
"OffTime", 
"A RandomVariableStream used to pick the duration of the 'Off' state.",
    75                    StringValue (
"ns3::ConstantRandomVariable[Constant=1.0]"),
    77                    MakePointerChecker <RandomVariableStream>())
    78     .AddAttribute (
"MaxBytes", 
    79                    "The total number of bytes to send. Once these bytes are sent, "    80                    "no packet is sent again, even in on state. The value zero means "    81                    "that there is no limit.",
    84                    MakeUintegerChecker<uint64_t> ())
    85     .AddAttribute (
"Protocol", 
"The type of protocol to use. This should be "    86                    "a subclass of ns3::SocketFactory",
    91     .AddTraceSource (
"Tx", 
"A new packet is created and is sent",
    93                      "ns3::Packet::TracedCallback")
    94     .AddTraceSource (
"TxWithAddresses", 
"A new packet is created and is sent",
    96                      "ns3::Packet::TwoAddressTracedCallback")
   203       NS_LOG_WARN (
"OnOffApplication found null socket to close in StopApplication");
   294                    << 
"s on-off application sent "   295                    <<  packet->GetSize () << 
" bytes to "   304                    << 
"s on-off application sent "   305                    <<  packet->GetSize () << 
" bytes to " static TypeId GetTypeId(void)
Get the type ID. 
void StopSending()
Start an Off period. 
Simulation virtual time values and global simulation resolution. 
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream. 
virtual void StartApplication(void)
Application specific startup code. 
EventId m_sendEvent
Event id of pending "send packet" event. 
Ptr< Socket > GetSocket(void) const
Return a pointer to associated socket. 
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system. 
Ipv6Address GetIpv6(void) const
Get the IPv6 address. 
uint32_t m_pktSize
Size of packets. 
virtual int Bind6()=0
Allocate a local IPv6 endpoint for this socket. 
Hold variables of type string. 
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed. 
High precision numerical type, implementing Q64.64 fixed precision. 
void ScheduleStartEvent()
Schedule the next On period start. 
void CancelEvents()
Cancel all pending events. 
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
static bool IsMatchingType(const Address &address)
Generate traffic to a single destination according to an OnOff pattern. 
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name. 
virtual int GetSockName(Address &address) const =0
Get socket address. 
virtual int ShutdownRecv(void)=0
void ScheduleStopEvent()
Schedule the next Off period start. 
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO. 
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate. 
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
uint64_t GetBitRate() const
Get the underlying bitrate. 
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method. 
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution. 
a polymophic address class 
Ptr< const AttributeChecker > MakeDataRateChecker(void)
  
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source. 
TracedCallback< Ptr< const Packet >, const Address &, const Address & > m_txTraceWithAddresses
Callbacks for tracing the packet Tx events, includes source and destination addresses. 
DataRate m_cbrRateFailSafe
Rate that data is generated (check copy) 
Class for representing data rates. 
virtual void DoDispose(void)
Destructor implementation. 
EventId m_startStopEvent
Event id for next start or stop event. 
Ptr< const AttributeAccessor > MakeAddressAccessor(T1 a1)
 Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void SendPacket()
Send a packet. 
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
 Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay. 
TypeId m_tid
Type of the socket used. 
The base class for all ns3 applications. 
Address m_peer
Peer address. 
DataRate m_cbrRate
Rate that data is generated. 
Hold an unsigned integer type. 
Ptr< RandomVariableStream > m_onTime
rng for On Time 
  AttributeValue implementation for TypeId. 
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
uint64_t m_totBytes
Total bytes sent so far. 
Ptr< Socket > m_socket
Associated socket. 
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
 Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Ptr< Node > GetNode() const
Ptr< RandomVariableStream > m_offTime
rng for Off Time 
void SetMaxBytes(uint64_t maxBytes)
Set the total number of bytes to send. 
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host. 
virtual void DoDispose(void)
Destructor implementation. 
TracedCallback< Ptr< const Packet > > m_txTrace
Traced Callback: transmitted packets. 
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket. 
Every class exported by the ns3 library is enclosed in the ns3 namespace. 
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address. 
void ScheduleNextTx()
Schedule the next packet transmission. 
uint16_t GetPort(void) const
void StartSending()
Start an On period. 
Ptr< const AttributeChecker > MakeAddressChecker(void)
  
static Time Now(void)
Return the current simulation virtual time. 
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
void ConnectionSucceeded(Ptr< Socket > socket)
Handle a Connection Succeed event. 
virtual ~OnOffApplication()
Time m_lastStartTime
Time last packet sent. 
Ptr< const AttributeAccessor > MakeTypeIdAccessor(T1 a1)
 Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
  AttributeValue implementation for Address. 
static TypeId GetTypeId(void)
Get the type ID. 
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN. 
  AttributeValue implementation for DataRate. 
Time Seconds(double value)
Construct a Time in the indicated unit. 
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress. 
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired(). 
static bool IsMatchingType(const Address &addr)
If the address match. 
void ConnectionFailed(Ptr< Socket > socket)
Handle a Connection Failed event. 
int64x64_t To(enum Unit unit) const
Get the Time value expressed in a particular unit. 
void SetConnectCallback(Callback< void, Ptr< Socket > > connectionSucceeded, Callback< void, Ptr< Socket > > connectionFailed)
Specify callbacks to allow the caller to determine if the connection succeeds of fails. 
bool m_connected
True if connected. 
virtual void StopApplication(void)
Application specific shutdown code. 
uint16_t GetPort(void) const
Get the port. 
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host. 
virtual int Close(void)=0
Close a socket. 
Ptr< const AttributeChecker > MakeTypeIdChecker(void)
  
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
 Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface. 
TypeId SetParent(TypeId tid)
Set the parent TypeId. 
uint32_t m_residualBits
Number of generated, but not sent, bits. 
uint64_t m_maxBytes
Limit total number of bytes sent. 
static bool IsMatchingType(const Address &address)
Ipv4Address GetIpv4(void) const
int64_t GetHigh(void) const
Get the integer portion.