A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
sink-application.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 DERONNE SOFTWARE ENGINEERING
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
9#include "sink-application.h"
10
11#include "ns3/log.h"
12#include "ns3/uinteger.h"
13
14namespace ns3
15{
16
17NS_LOG_COMPONENT_DEFINE("SinkApplication");
18
19NS_OBJECT_ENSURE_REGISTERED(SinkApplication);
20
21TypeId
23{
24 static TypeId tid =
25 TypeId("ns3::SinkApplication")
27 .SetGroupName("Applications")
28 .AddAttribute(
29 "Local",
30 "The Address on which to Bind the rx socket. "
31 "If it is not specified, it will listen to any address.",
35 .AddAttribute(
36 "Port",
37 "Port on which the application listens for incoming packets.",
41 return tid;
42}
43
45 : m_port{defaultPort}
46{
47 NS_LOG_FUNCTION(this << defaultPort);
48}
49
54
55void
57{
58 NS_LOG_FUNCTION(this << addr);
59 m_local = addr;
60}
61
64{
65 return m_local;
66}
67
68void
70{
71 NS_LOG_FUNCTION(this << port);
72 if (port == INVALID_PORT)
73 {
74 return;
75 }
76 m_port = port;
77}
78
81{
82 return m_port;
83}
84
85} // Namespace ns3
a polymophic address class
Definition address.h:90
AttributeValue implementation for Address.
Definition address.h:275
The base class for all ns3 applications.
Definition application.h:51
static constexpr uint32_t INVALID_PORT
invalid port
virtual void SetLocal(const Address &addr)
set the local address
SinkApplication(uint16_t defaultPort=0)
Constructor.
Address GetLocal() const
get the local address
uint32_t GetPort() const
get the server port
static TypeId GetTypeId()
Get the type ID.
Address m_local
Local address to bind to (address and port)
uint32_t m_port
Local port to bind to.
virtual void SetPort(uint32_t port)
set the server port
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
uint16_t port
Definition dsdv-manet.cc:33
Ptr< const AttributeChecker > MakeAddressChecker()
Definition address.cc:169
Ptr< const AttributeAccessor > MakeAddressAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition address.h:275
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition uinteger.h:35
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#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.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.