11#include "ns3/inet-socket-address.h"
12#include "ns3/inet6-socket-address.h"
14#include "ns3/packet-socket-address.h"
15#include "ns3/socket.h"
16#include "ns3/uinteger.h"
29 TypeId(
"ns3::SourceApplication")
31 .SetGroupName(
"Applications")
34 "The address of the destination, made of the remote IP address and the "
39 .AddAttribute(
"Local",
40 "The Address on which to bind the socket. If not set, it is generated "
41 "automatically when needed by the application.",
46 "The Type of Service used to send IPv4 packets. "
47 "All 8 bits of the TOS byte are set (including ECN bits).",
54 "ns3::Packet::TracedCallback")
55 .AddTraceSource(
"ConnectionSucceeded",
56 "Succeeded to establish connection",
58 "ns3::SourceApplication::ConnectionEventCallback")
59 .AddTraceSource(
"ConnectionFailed",
60 "Failed to establish connection",
62 "ns3::SourceApplication::ConnectionEventCallback");
122 "Incompatible peer and local address IP version");
a polymophic address class
AttributeValue implementation for Address.
void DoDispose() override
Destructor implementation.
Ptr< Node > GetNode() const
static bool IsMatchingType(const Address &addr)
If the address match.
static bool IsMatchingType(const Address &address)
static bool IsMatchingType(const Address &address)
Smart pointer class similar to boost::intrusive_ptr.
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...
Base class for source applications.
TracedCallback< Ptr< Socket >, const Address &, const Address & > m_connectionFailure
Traced Callback: connection failure event.
TypeId m_protocolTid
Protocol TypeId value.
void StopApplication() override
Application specific shutdown code.
~SourceApplication() override
Address m_local
Local address to bind to.
Address GetRemote() const
get the remote address
SourceApplication(bool allowPacketSocket=true)
Constructor.
void ConnectionFailed(Ptr< Socket > socket)
Handle a Connection Failed event.
Ptr< Socket > m_socket
Socket.
TracedCallback< Ptr< Socket >, const Address &, const Address & > m_connectionSuccess
Traced Callback: connection success event.
void DoDispose() override
Destructor implementation.
Ptr< Socket > GetSocket() const
Get the socket this application is attached to.
void ConnectionSucceeded(Ptr< Socket > socket)
Handle a Connection Succeed event.
virtual void DoConnectionFailed(Ptr< Socket > socket)
Application specific code for child subclasses upon a Connection Failed event.
virtual void DoStopApplication()
Application specific shutdown code for child subclasses.
virtual void SetRemote(const Address &addr)
set the remote address
virtual void CancelEvents()=0
Cancel all pending events.
TracedCallback< Ptr< const Packet > > m_txTrace
Traced Callback: transmitted packets.
uint8_t m_tos
The packets Type of Service.
void StartApplication() override
Application specific startup code.
bool m_connected
flag whether socket is connected
bool m_allowPacketSocket
Allow use of packet socket.
static TypeId GetTypeId()
Get the type ID.
Address m_peer
Peer address.
bool CloseSocket()
Close the socket.
virtual void DoStartApplication()
Application specific startup code for child subclasses.
virtual void DoConnectionSucceeded(Ptr< Socket > socket)
Application specific code for child subclasses upon a Connection Succeed event.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
Ptr< const AttributeChecker > MakeAddressChecker()
Ptr< const AttributeAccessor > MakeAddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Callback< R, Args... > MakeNullCallback()
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...