A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
14
namespace
ns3
15
{
16
17
NS_LOG_COMPONENT_DEFINE
(
"SinkApplication"
);
18
19
NS_OBJECT_ENSURE_REGISTERED
(SinkApplication);
20
21
TypeId
22
SinkApplication::GetTypeId
()
23
{
24
static
TypeId
tid =
25
TypeId
(
"ns3::SinkApplication"
)
26
.
SetParent
<
Application
>()
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."
,
32
AddressValue
(),
33
MakeAddressAccessor
(&
SinkApplication::SetLocal
, &
SinkApplication::GetLocal
),
34
MakeAddressChecker
())
35
.AddAttribute(
36
"Port"
,
37
"Port on which the application listens for incoming packets."
,
38
UintegerValue
(
INVALID_PORT
),
39
MakeUintegerAccessor
(&
SinkApplication::SetPort
, &
SinkApplication::GetPort
),
40
MakeUintegerChecker<uint32_t>
());
41
return
tid;
42
}
43
44
SinkApplication::SinkApplication
(uint16_t defaultPort)
45
: m_port{defaultPort}
46
{
47
NS_LOG_FUNCTION
(
this
<< defaultPort);
48
}
49
50
SinkApplication::~SinkApplication
()
51
{
52
NS_LOG_FUNCTION
(
this
);
53
}
54
55
void
56
SinkApplication::SetLocal
(
const
Address
& addr)
57
{
58
NS_LOG_FUNCTION
(
this
<< addr);
59
m_local
= addr;
60
}
61
62
Address
63
SinkApplication::GetLocal
()
const
64
{
65
return
m_local
;
66
}
67
68
void
69
SinkApplication::SetPort
(
uint32_t
port
)
70
{
71
NS_LOG_FUNCTION
(
this
<<
port
);
72
if
(
port
==
INVALID_PORT
)
73
{
74
return
;
75
}
76
m_port
=
port
;
77
}
78
79
uint32_t
80
SinkApplication::GetPort
()
const
81
{
82
return
m_port
;
83
}
84
85
}
// Namespace ns3
ns3::Address
a polymophic address class
Definition
address.h:90
ns3::AddressValue
AttributeValue implementation for Address.
Definition
address.h:275
ns3::Application
The base class for all ns3 applications.
Definition
application.h:51
ns3::SinkApplication::INVALID_PORT
static constexpr uint32_t INVALID_PORT
invalid port
Definition
sink-application.h:55
ns3::SinkApplication::SetLocal
virtual void SetLocal(const Address &addr)
set the local address
Definition
sink-application.cc:56
ns3::SinkApplication::SinkApplication
SinkApplication(uint16_t defaultPort=0)
Constructor.
Definition
sink-application.cc:44
ns3::SinkApplication::GetLocal
Address GetLocal() const
get the local address
Definition
sink-application.cc:63
ns3::SinkApplication::~SinkApplication
~SinkApplication() override
Definition
sink-application.cc:50
ns3::SinkApplication::GetPort
uint32_t GetPort() const
get the server port
Definition
sink-application.cc:80
ns3::SinkApplication::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
sink-application.cc:22
ns3::SinkApplication::m_local
Address m_local
Local address to bind to (address and port)
Definition
sink-application.h:58
ns3::SinkApplication::m_port
uint32_t m_port
Local port to bind to.
Definition
sink-application.h:59
ns3::SinkApplication::SetPort
virtual void SetPort(uint32_t port)
set the server port
Definition
sink-application.cc:69
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
ns3::UintegerValue
Hold an unsigned integer type.
Definition
uinteger.h:34
uint32_t
port
uint16_t port
Definition
dsdv-manet.cc:33
ns3::MakeAddressChecker
Ptr< const AttributeChecker > MakeAddressChecker()
Definition
address.cc:169
ns3::MakeAddressAccessor
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
ns3::MakeUintegerChecker
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition
uinteger.h:85
ns3::MakeUintegerAccessor
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
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition
object-base.h:35
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
sink-application.h
src
applications
model
sink-application.cc
Generated on Thu Dec 12 2024 18:40:35 for ns-3 by
1.11.0