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
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Amine Ismail <amine.ismail@sophia.inria.fr>
18
* <amine.ismail@udcast.com>
19
*
20
*/
21
22
#ifndef UDP_SERVER_H
23
#define UDP_SERVER_H
24
25
#include "
packet-loss-counter.h
"
26
27
#include "ns3/address.h"
28
#include "ns3/application.h"
29
#include "ns3/event-id.h"
30
#include "ns3/ptr.h"
31
#include "ns3/traced-callback.h"
32
33
namespace
ns3
34
{
35
/**
36
* \ingroup applications
37
* \defgroup udpclientserver UdpClientServer
38
*/
39
40
/**
41
* \ingroup udpclientserver
42
*
43
* \brief A UDP server, receives UDP packets from a remote host.
44
*
45
* UDP packets carry a 32bits sequence number followed by a 64bits time
46
* stamp in their payloads. The application uses the sequence number
47
* to determine if a packet is lost, and the time stamp to compute the delay.
48
*/
49
class
UdpServer
:
public
Application
50
{
51
public
:
52
/**
53
* \brief Get the type ID.
54
* \return the object TypeId
55
*/
56
static
TypeId
GetTypeId
();
57
UdpServer
();
58
~UdpServer
()
override
;
59
/**
60
* \brief Returns the number of lost packets
61
* \return the number of lost packets
62
*/
63
uint32_t
GetLost
()
const
;
64
65
/**
66
* \brief Returns the number of received packets
67
* \return the number of received packets
68
*/
69
uint64_t
GetReceived
()
const
;
70
71
/**
72
* \brief Returns the size of the window used for checking loss.
73
* \return the size of the window used for checking loss.
74
*/
75
uint16_t
GetPacketWindowSize
()
const
;
76
77
/**
78
* \brief Set the size of the window used for checking loss. This value should
79
* be a multiple of 8
80
* \param size the size of the window used for checking loss. This value should
81
* be a multiple of 8
82
*/
83
void
SetPacketWindowSize
(uint16_t size);
84
85
private
:
86
void
StartApplication
()
override
;
87
void
StopApplication
()
override
;
88
89
/**
90
* \brief Handle a packet reception.
91
*
92
* This function is called by lower layers.
93
*
94
* \param socket the socket the packet was received to.
95
*/
96
void
HandleRead
(
Ptr<Socket>
socket);
97
98
uint16_t
m_port
;
//!< Port on which we listen for incoming packets.
99
uint8_t
m_tos
;
//!< The packets Type of Service
100
Ptr<Socket>
m_socket
;
//!< IPv4 Socket
101
Ptr<Socket>
m_socket6
;
//!< IPv6 Socket
102
uint64_t
m_received
;
//!< Number of received packets
103
PacketLossCounter
m_lossCounter
;
//!< Lost packet counter
104
105
/// Callbacks for tracing the packet Rx events
106
TracedCallback<Ptr<const Packet>
>
m_rxTrace
;
107
108
/// Callbacks for tracing the packet Rx events, includes source and destination addresses
109
TracedCallback<Ptr<const Packet>
,
const
Address
&,
const
Address
&>
m_rxTraceWithAddresses
;
110
};
111
112
}
// namespace ns3
113
114
#endif
/* UDP_SERVER_H */
ns3::Address
a polymophic address class
Definition:
address.h:101
ns3::Application
The base class for all ns3 applications.
Definition:
application.h:62
ns3::PacketLossCounter
A class to count the number of lost packets.
Definition:
packet-loss-counter.h:46
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition:
traced-callback.h:54
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::UdpServer
A UDP server, receives UDP packets from a remote host.
Definition:
udp-server.h:50
ns3::UdpServer::m_socket6
Ptr< Socket > m_socket6
IPv6 Socket.
Definition:
udp-server.h:101
ns3::UdpServer::m_rxTrace
TracedCallback< Ptr< const Packet > > m_rxTrace
Callbacks for tracing the packet Rx events.
Definition:
udp-server.h:106
ns3::UdpServer::~UdpServer
~UdpServer() override
Definition:
udp-server.cc:88
ns3::UdpServer::m_port
uint16_t m_port
Port on which we listen for incoming packets.
Definition:
udp-server.h:98
ns3::UdpServer::GetReceived
uint64_t GetReceived() const
Returns the number of received packets.
Definition:
udp-server.cc:115
ns3::UdpServer::StartApplication
void StartApplication() override
Application specific startup code.
Definition:
udp-server.cc:122
ns3::UdpServer::m_socket
Ptr< Socket > m_socket
IPv4 Socket.
Definition:
udp-server.h:100
ns3::UdpServer::HandleRead
void HandleRead(Ptr< Socket > socket)
Handle a packet reception.
Definition:
udp-server.cc:166
ns3::UdpServer::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
udp-server.cc:45
ns3::UdpServer::m_lossCounter
PacketLossCounter m_lossCounter
Lost packet counter.
Definition:
udp-server.h:103
ns3::UdpServer::SetPacketWindowSize
void SetPacketWindowSize(uint16_t size)
Set the size of the window used for checking loss.
Definition:
udp-server.cc:101
ns3::UdpServer::UdpServer
UdpServer()
Definition:
udp-server.cc:81
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:109
ns3::UdpServer::GetLost
uint32_t GetLost() const
Returns the number of lost packets.
Definition:
udp-server.cc:108
ns3::UdpServer::m_tos
uint8_t m_tos
The packets Type of Service.
Definition:
udp-server.h:99
ns3::UdpServer::m_received
uint64_t m_received
Number of received packets.
Definition:
udp-server.h:102
ns3::UdpServer::GetPacketWindowSize
uint16_t GetPacketWindowSize() const
Returns the size of the window used for checking loss.
Definition:
udp-server.cc:94
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
src
applications
model
udp-server.h
Generated on Tue May 28 2024 23:34:12 for ns-3 by
1.9.6