12#include "ns3/socket.h"
13#include "ns3/uinteger.h"
26 TypeId(
"ns3::SinkApplication")
28 .SetGroupName(
"Applications")
31 "The Address on which to Bind the rx socket. "
32 "If it is not specified, it will listen to any address.",
38 "Port on which the application listens for incoming packets.",
43 "A packet has been received",
45 "ns3::Packet::AddressTracedCallback")
46 .AddTraceSource(
"RxWithoutAddress",
47 "A packet has been received from a given address",
49 "ns3::Packet::TracedCallback");
144 const auto ret = socket->Close();
a polymophic address class
AttributeValue implementation for Address.
void DoDispose() override
Destructor implementation.
Ptr< Node > GetNode() const
Smart pointer class similar to boost::intrusive_ptr.
Base class for sink applications.
static constexpr uint32_t INVALID_PORT
invalid port
virtual void SetLocal(const Address &addr)
set the local address
ns3::TracedCallback< Ptr< const Packet > > m_rxTraceWithoutAddress
Callbacks for tracing the packet Rx events.
Ptr< Socket > m_socket6
IPv6 Socket (used if only port is specified).
void StopApplication() override
Application specific shutdown code.
void DoDispose() override
Destructor implementation.
TypeId m_protocolTid
Protocol TypeId value.
SinkApplication(uint16_t defaultPort=0)
Constructor.
virtual void DoStartApplication()
Application specific startup code for child subclasses.
Address GetLocal() const
get the local address
~SinkApplication() override
uint32_t GetPort() const
get the server port
virtual void DoStopApplication()
Application specific shutdown code for child subclasses.
void StartApplication() override
Application specific startup code.
static TypeId GetTypeId()
Get the type ID.
Address m_local
Local address to bind to (address and port).
Ptr< Socket > m_socket
Socket (IPv4 or IPv6, depending on local address).
bool CloseSocket(Ptr< Socket > socket)
Close the socket.
uint32_t m_port
Local port to bind to.
virtual void SetPort(uint32_t port)
set the server port
bool CloseAllSockets()
Close all the sockets.
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced Callback: received packets, source address.
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...
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_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.