A Discrete-Event Network Simulator
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
33namespace 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 */
49class 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
107
108 /// Callbacks for tracing the packet Rx events, includes source and destination addresses
110};
111
112} // namespace ns3
113
114#endif /* UDP_SERVER_H */
a polymophic address class
Definition: address.h:101
The base class for all ns3 applications.
Definition: application.h:62
A class to count the number of lost packets.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
A UDP server, receives UDP packets from a remote host.
Definition: udp-server.h:50
Ptr< Socket > m_socket6
IPv6 Socket.
Definition: udp-server.h:101
TracedCallback< Ptr< const Packet > > m_rxTrace
Callbacks for tracing the packet Rx events.
Definition: udp-server.h:106
~UdpServer() override
Definition: udp-server.cc:88
uint16_t m_port
Port on which we listen for incoming packets.
Definition: udp-server.h:98
uint64_t GetReceived() const
Returns the number of received packets.
Definition: udp-server.cc:115
void StartApplication() override
Application specific startup code.
Definition: udp-server.cc:122
Ptr< Socket > m_socket
IPv4 Socket.
Definition: udp-server.h:100
void HandleRead(Ptr< Socket > socket)
Handle a packet reception.
Definition: udp-server.cc:166
static TypeId GetTypeId()
Get the type ID.
Definition: udp-server.cc:45
PacketLossCounter m_lossCounter
Lost packet counter.
Definition: udp-server.h:103
void SetPacketWindowSize(uint16_t size)
Set the size of the window used for checking loss.
Definition: udp-server.cc:101
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
uint32_t GetLost() const
Returns the number of lost packets.
Definition: udp-server.cc:108
uint8_t m_tos
The packets Type of Service.
Definition: udp-server.h:99
uint64_t m_received
Number of received packets.
Definition: udp-server.h:102
uint16_t GetPacketWindowSize() const
Returns the size of the window used for checking loss.
Definition: udp-server.cc:94
void StopApplication() override
Application specific shutdown code.
Definition: udp-server.cc:155
Every class exported by the ns3 library is enclosed in the ns3 namespace.