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.h
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
#ifndef SINK_APPLICATION_H
10
#define SINK_APPLICATION_H
11
12
#include "ns3/address.h"
13
#include "ns3/application.h"
14
15
#include <limits>
16
17
namespace
ns3
18
{
19
20
/**
21
* @ingroup applications
22
* @brief Base class for sink applications.
23
*
24
* This class can be used as a base class for sink applications.
25
* A sink application is an application that is primarily used to only receive or echo packets.
26
*
27
* The main purpose of this base class application public API is to hold attributes for the local
28
* (IPv4 or IPv6) address and port to bind to.
29
*
30
* There are three ways that the port value can be configured. First, and most typically, through
31
* the use of a socket address (InetSocketAddress or Inet6SocketAddress) that is configured as the
32
* Local address to bind to. Second, through direct configuration of the Port attribute. Third,
33
* through the use of an optional constructor argument. If multiple of these port configuration
34
* methods are used, it is up to subclass definition which one takes precedence; in the existing
35
* subclasses in this directory, the port value configured in the Local socket address (if a socket
36
* address is configured there) will take precedence.
37
*/
38
class
SinkApplication
:
public
Application
39
{
40
public
:
41
/**
42
* @brief Get the type ID.
43
* @return the object TypeId
44
*/
45
static
TypeId
GetTypeId
();
46
47
/**
48
* Constructor
49
*
50
* @param defaultPort the default port number
51
*/
52
SinkApplication
(uint16_t defaultPort = 0);
53
~SinkApplication
()
override
;
54
55
static
constexpr
uint32_t
INVALID_PORT
{std::numeric_limits<uint32_t>::max()};
//!< invalid port
56
57
protected
:
58
Address
m_local
;
//!< Local address to bind to (address and port)
59
uint32_t
m_port
;
//!< Local port to bind to
60
61
private
:
62
/**
63
* @brief set the local address
64
* @param addr local address
65
*/
66
virtual
void
SetLocal
(
const
Address
& addr);
67
68
/**
69
* @brief get the local address
70
* @return the local address
71
*/
72
Address
GetLocal
()
const
;
73
74
/**
75
* @brief set the server port
76
* @param port server port
77
*/
78
virtual
void
SetPort
(
uint32_t
port
);
79
80
/**
81
* @brief get the server port
82
* @return the server port
83
*/
84
uint32_t
GetPort
()
const
;
85
};
86
87
}
// namespace ns3
88
89
#endif
/* SINK_APPLICATION_H */
ns3::Address
a polymophic address class
Definition
address.h:90
ns3::Application
The base class for all ns3 applications.
Definition
application.h:51
ns3::SinkApplication
Base class for sink applications.
Definition
sink-application.h:39
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
uint32_t
port
uint16_t port
Definition
dsdv-manet.cc:33
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
applications
model
sink-application.h
Generated on Thu Dec 12 2024 18:40:35 for ns-3 by
1.11.0