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 * 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
22namespace 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 */
38class 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
96
97 /// Callbacks for tracing the packet Rx events, includes source and destination addresses
99};
100
101} // namespace ns3
102
103#endif /* UDP_SERVER_H */
a polymophic address class
Definition address.h:90
The base class for all ns3 applications.
Definition application.h:51
A class to count the number of lost packets.
Smart pointer class similar to boost::intrusive_ptr.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
A UDP server, receives UDP packets from a remote host.
Definition udp-server.h:39
Ptr< Socket > m_socket6
IPv6 Socket.
Definition udp-server.h:90
TracedCallback< Ptr< const Packet > > m_rxTrace
Callbacks for tracing the packet Rx events.
Definition udp-server.h:95
~UdpServer() override
Definition udp-server.cc:77
uint16_t m_port
Port on which we listen for incoming packets.
Definition udp-server.h:87
uint64_t GetReceived() const
Returns the number of received packets.
void StartApplication() override
Application specific startup code.
Ptr< Socket > m_socket
IPv4 Socket.
Definition udp-server.h:89
void HandleRead(Ptr< Socket > socket)
Handle a packet reception.
static TypeId GetTypeId()
Get the type ID.
Definition udp-server.cc:34
PacketLossCounter m_lossCounter
Lost packet counter.
Definition udp-server.h:92
void SetPacketWindowSize(uint16_t size)
Set the size of the window used for checking loss.
Definition udp-server.cc:90
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
uint32_t GetLost() const
Returns the number of lost packets.
Definition udp-server.cc:97
uint8_t m_tos
The packets Type of Service.
Definition udp-server.h:88
uint64_t m_received
Number of received packets.
Definition udp-server.h:91
uint16_t GetPacketWindowSize() const
Returns the size of the window used for checking loss.
Definition udp-server.cc:83
void StopApplication() override
Application specific shutdown code.
Every class exported by the ns3 library is enclosed in the ns3 namespace.