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
16
#include "ns3/address.h"
17
#include "ns3/application.h"
18
#include "ns3/event-id.h"
19
#include "ns3/ptr.h"
20
#include "ns3/traced-callback.h"
21
22
namespace
ns3
23
{
24
/**
25
* \ingroup applications
26
* \defgroup udpclientserver UdpClientServer
27
*/
28
29
/**
30
* \ingroup udpclientserver
31
*
32
* \brief A UDP server, receives UDP packets from a remote host.
33
*
34
* UDP packets carry a 32bits sequence number followed by a 64bits time
35
* stamp in their payloads. The application uses the sequence number
36
* to determine if a packet is lost, and the time stamp to compute the delay.
37
*/
38
class
UdpServer
:
public
Application
39
{
40
public
:
41
/**
42
* \brief Get the type ID.
43
* \return the object TypeId
44
*/
45
static
TypeId
GetTypeId
();
46
UdpServer
();
47
~UdpServer
()
override
;
48
/**
49
* \brief Returns the number of lost packets
50
* \return the number of lost packets
51
*/
52
uint32_t
GetLost
()
const
;
53
54
/**
55
* \brief Returns the number of received packets
56
* \return the number of received packets
57
*/
58
uint64_t
GetReceived
()
const
;
59
60
/**
61
* \brief Returns the size of the window used for checking loss.
62
* \return the size of the window used for checking loss.
63
*/
64
uint16_t
GetPacketWindowSize
()
const
;
65
66
/**
67
* \brief Set the size of the window used for checking loss. This value should
68
* be a multiple of 8
69
* \param size the size of the window used for checking loss. This value should
70
* be a multiple of 8
71
*/
72
void
SetPacketWindowSize
(uint16_t size);
73
74
private
:
75
void
StartApplication
()
override
;
76
void
StopApplication
()
override
;
77
78
/**
79
* \brief Handle a packet reception.
80
*
81
* This function is called by lower layers.
82
*
83
* \param socket the socket the packet was received to.
84
*/
85
void
HandleRead
(
Ptr<Socket>
socket);
86
87
uint16_t
m_port
;
//!< Port on which we listen for incoming packets.
88
uint8_t
m_tos
;
//!< The packets Type of Service
89
Ptr<Socket>
m_socket
;
//!< IPv4 Socket
90
Ptr<Socket>
m_socket6
;
//!< IPv6 Socket
91
uint64_t
m_received
;
//!< Number of received packets
92
PacketLossCounter
m_lossCounter
;
//!< Lost packet counter
93
94
/// Callbacks for tracing the packet Rx events
95
TracedCallback<Ptr<const Packet>
>
m_rxTrace
;
96
97
/// Callbacks for tracing the packet Rx events, includes source and destination addresses
98
TracedCallback<Ptr<const Packet>
,
const
Address
&,
const
Address
&>
m_rxTraceWithAddresses
;
99
};
100
101
}
// namespace ns3
102
103
#endif
/* UDP_SERVER_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::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::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:39
ns3::UdpServer::m_socket6
Ptr< Socket > m_socket6
IPv6 Socket.
Definition
udp-server.h:90
ns3::UdpServer::m_rxTrace
TracedCallback< Ptr< const Packet > > m_rxTrace
Callbacks for tracing the packet Rx events.
Definition
udp-server.h:95
ns3::UdpServer::~UdpServer
~UdpServer() override
Definition
udp-server.cc:77
ns3::UdpServer::m_port
uint16_t m_port
Port on which we listen for incoming packets.
Definition
udp-server.h:87
ns3::UdpServer::GetReceived
uint64_t GetReceived() const
Returns the number of received packets.
Definition
udp-server.cc:104
ns3::UdpServer::StartApplication
void StartApplication() override
Application specific startup code.
Definition
udp-server.cc:111
ns3::UdpServer::m_socket
Ptr< Socket > m_socket
IPv4 Socket.
Definition
udp-server.h:89
ns3::UdpServer::HandleRead
void HandleRead(Ptr< Socket > socket)
Handle a packet reception.
Definition
udp-server.cc:155
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:92
ns3::UdpServer::SetPacketWindowSize
void SetPacketWindowSize(uint16_t size)
Set the size of the window used for checking loss.
Definition
udp-server.cc:90
ns3::UdpServer::UdpServer
UdpServer()
Definition
udp-server.cc:70
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:98
ns3::UdpServer::GetLost
uint32_t GetLost() const
Returns the number of lost packets.
Definition
udp-server.cc:97
ns3::UdpServer::m_tos
uint8_t m_tos
The packets Type of Service.
Definition
udp-server.h:88
ns3::UdpServer::m_received
uint64_t m_received
Number of received packets.
Definition
udp-server.h:91
ns3::UdpServer::GetPacketWindowSize
uint16_t GetPacketWindowSize() const
Returns the size of the window used for checking loss.
Definition
udp-server.cc:83
ns3::UdpServer::StopApplication
void StopApplication() override
Application specific shutdown code.
Definition
udp-server.cc:144
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
packet-loss-counter.h
src
applications
model
udp-server.h
Generated on Fri Nov 8 2024 13:58:59 for ns-3 by
1.11.0