A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
udp-echo-server.h
Go to the documentation of this file.
1/*
2 * Copyright 2007 University of Washington
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
7#ifndef UDP_ECHO_SERVER_H
8#define UDP_ECHO_SERVER_H
9
10#include "sink-application.h"
11
12#include "ns3/event-id.h"
13#include "ns3/ptr.h"
14#include "ns3/traced-callback.h"
15
16namespace ns3
17{
18
19class Socket;
20class Packet;
21
22/**
23 * @ingroup applications
24 * @defgroup udpecho UdpEcho
25 */
26
27/**
28 * @ingroup udpecho
29 * @brief A Udp Echo server
30 *
31 * Every packet received is sent back.
32 */
34{
35 public:
36 static constexpr uint16_t DEFAULT_PORT{9}; //!< default port
37
38 /**
39 * @brief Get the type ID.
40 * @return the object TypeId
41 */
42 static TypeId GetTypeId();
43
45 ~UdpEchoServer() override;
46
47 private:
48 void StartApplication() override;
49 void StopApplication() override;
50
51 /**
52 * @brief Handle a packet reception.
53 *
54 * This function is called by lower layers.
55 *
56 * @param socket the socket the packet was received to.
57 */
58 void HandleRead(Ptr<Socket> socket);
59
60 uint8_t m_tos; //!< The packets Type of Service
61 Ptr<Socket> m_socket; //!< Socket
62 Ptr<Socket> m_socket6; //!< IPv6 Socket (used if only port is specified)
63
64 /// Callbacks for tracing the packet Rx events
66
67 /// Callbacks for tracing the packet Rx events, includes source and destination addresses
69};
70
71} // namespace ns3
72
73#endif /* UDP_ECHO_SERVER_H */
a polymophic address class
Definition address.h:90
Smart pointer class similar to boost::intrusive_ptr.
Base class for sink applications.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
A Udp Echo server.
void StartApplication() override
Application specific startup code.
TracedCallback< Ptr< const Packet >, const Address &, const Address & > m_rxTraceWithAddresses
Callbacks for tracing the packet Rx events, includes source and destination addresses.
static constexpr uint16_t DEFAULT_PORT
default port
Ptr< Socket > m_socket6
IPv6 Socket (used if only port is specified)
uint8_t m_tos
The packets Type of Service.
static TypeId GetTypeId()
Get the type ID.
void StopApplication() override
Application specific shutdown code.
TracedCallback< Ptr< const Packet > > m_rxTrace
Callbacks for tracing the packet Rx events.
Ptr< Socket > m_socket
Socket.
void HandleRead(Ptr< Socket > socket)
Handle a packet reception.
Every class exported by the ns3 library is enclosed in the ns3 namespace.