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
udp-server.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2007,2008,2009 INRIA, UDCAST
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Amine Ismail <amine.ismail@sophia.inria.fr>
7
* <amine.ismail@udcast.com>
8
*
9
*/
10
11
#ifndef UDP_SERVER_H
12
#define UDP_SERVER_H
13
14
#include "
packet-loss-counter.h
"
15
#include "
sink-application.h
"
16
17
#include "ns3/event-id.h"
18
#include "ns3/ptr.h"
19
#include "ns3/traced-callback.h"
20
21
namespace
ns3
22
{
23
/**
24
* @ingroup applications
25
* @defgroup udpclientserver UdpClientServer
26
*/
27
28
/**
29
* @ingroup udpclientserver
30
*
31
* @brief A UDP server, receives UDP packets from a remote host.
32
*
33
* UDP packets carry a 32bits sequence number followed by a 64bits time
34
* stamp in their payloads. The application uses the sequence number
35
* to determine if a packet is lost, and the time stamp to compute the delay.
36
*/
37
class
UdpServer
:
public
SinkApplication
38
{
39
public
:
40
static
constexpr
uint16_t
DEFAULT_PORT
{100};
//!< default port
41
42
/**
43
* @brief Get the type ID.
44
* @return the object TypeId
45
*/
46
static
TypeId
GetTypeId
();
47
48
UdpServer
();
49
~UdpServer
()
override
;
50
51
/**
52
* @brief Returns the number of lost packets
53
* @return the number of lost packets
54
*/
55
uint32_t
GetLost
()
const
;
56
57
/**
58
* @brief Returns the number of received packets
59
* @return the number of received packets
60
*/
61
uint64_t
GetReceived
()
const
;
62
63
/**
64
* @brief Returns the size of the window used for checking loss.
65
* @return the size of the window used for checking loss.
66
*/
67
uint16_t
GetPacketWindowSize
()
const
;
68
69
/**
70
* @brief Set the size of the window used for checking loss. This value should
71
* be a multiple of 8
72
* @param size the size of the window used for checking loss. This value should
73
* be a multiple of 8
74
*/
75
void
SetPacketWindowSize
(uint16_t size);
76
77
private
:
78
void
StartApplication
()
override
;
79
void
StopApplication
()
override
;
80
81
/**
82
* @brief Handle a packet reception.
83
*
84
* This function is called by lower layers.
85
*
86
* @param socket the socket the packet was received to.
87
*/
88
void
HandleRead
(
Ptr<Socket>
socket);
89
90
Ptr<Socket>
m_socket
;
//!< Socket
91
Ptr<Socket>
m_socket6
;
//!< IPv6 Socket (used if only port is specified)
92
uint64_t
m_received
;
//!< Number of received packets
93
PacketLossCounter
m_lossCounter
;
//!< Lost packet counter
94
95
/// Callbacks for tracing the packet Rx events
96
TracedCallback<Ptr<const Packet>
>
m_rxTrace
;
97
98
/// Callbacks for tracing the packet Rx events, includes source and destination addresses
99
TracedCallback<Ptr<const Packet>
,
const
Address
&,
const
Address
&>
m_rxTraceWithAddresses
;
100
};
101
102
}
// namespace ns3
103
104
#endif
/* UDP_SERVER_H */
ns3::Address
a polymophic address class
Definition
address.h:90
ns3::PacketLossCounter
A class to count the number of lost packets.
Definition
packet-loss-counter.h:35
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::SinkApplication
Base class for sink applications.
Definition
sink-application.h:39
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition
traced-callback.h:43
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::UdpServer
A UDP server, receives UDP packets from a remote host.
Definition
udp-server.h:38
ns3::UdpServer::m_socket6
Ptr< Socket > m_socket6
IPv6 Socket (used if only port is specified)
Definition
udp-server.h:91
ns3::UdpServer::m_rxTrace
TracedCallback< Ptr< const Packet > > m_rxTrace
Callbacks for tracing the packet Rx events.
Definition
udp-server.h:96
ns3::UdpServer::~UdpServer
~UdpServer() override
Definition
udp-server.cc:69
ns3::UdpServer::GetReceived
uint64_t GetReceived() const
Returns the number of received packets.
Definition
udp-server.cc:96
ns3::UdpServer::StartApplication
void StartApplication() override
Application specific startup code.
Definition
udp-server.cc:103
ns3::UdpServer::m_socket
Ptr< Socket > m_socket
Socket.
Definition
udp-server.h:90
ns3::UdpServer::HandleRead
void HandleRead(Ptr< Socket > socket)
Handle a packet reception.
Definition
udp-server.cc:170
ns3::UdpServer::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
udp-server.cc:34
ns3::UdpServer::m_lossCounter
PacketLossCounter m_lossCounter
Lost packet counter.
Definition
udp-server.h:93
ns3::UdpServer::DEFAULT_PORT
static constexpr uint16_t DEFAULT_PORT
default port
Definition
udp-server.h:40
ns3::UdpServer::SetPacketWindowSize
void SetPacketWindowSize(uint16_t size)
Set the size of the window used for checking loss.
Definition
udp-server.cc:82
ns3::UdpServer::UdpServer
UdpServer()
Definition
udp-server.cc:59
ns3::UdpServer::m_rxTraceWithAddresses
TracedCallback< Ptr< const Packet >, const Address &, const Address & > m_rxTraceWithAddresses
Callbacks for tracing the packet Rx events, includes source and destination addresses.
Definition
udp-server.h:99
ns3::UdpServer::GetLost
uint32_t GetLost() const
Returns the number of lost packets.
Definition
udp-server.cc:89
ns3::UdpServer::m_received
uint64_t m_received
Number of received packets.
Definition
udp-server.h:92
ns3::UdpServer::GetPacketWindowSize
uint16_t GetPacketWindowSize() const
Returns the size of the window used for checking loss.
Definition
udp-server.cc:75
ns3::UdpServer::StopApplication
void StopApplication() override
Application specific shutdown code.
Definition
udp-server.cc:155
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
packet-loss-counter.h
sink-application.h
src
applications
model
udp-server.h
Generated on Thu Dec 12 2024 18:40:35 for ns-3 by
1.11.0