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 Packet;
20
21/**
22 * @ingroup applications
23 * @defgroup udpecho UdpEcho
24 */
25
26/**
27 * @ingroup udpecho
28 * @brief A Udp Echo server
29 *
30 * Every packet received is sent back.
31 */
33{
34 public:
35 static constexpr uint16_t DEFAULT_PORT{9}; //!< default port
36
37 /**
38 * @brief Get the type ID.
39 * @return the object TypeId
40 */
41 static TypeId GetTypeId();
42
44 ~UdpEchoServer() override;
45
46 private:
47 void DoStartApplication() override;
48
49 /**
50 * @brief Handle a packet reception.
51 *
52 * This function is called by lower layers.
53 *
54 * @param socket the socket the packet was received to.
55 */
56 void HandleRead(Ptr<Socket> socket);
57
58 uint8_t m_tos; //!< The packets Type of Service
59
60 /// Callbacks for tracing the packet Rx events, includes source and destination addresses
62};
63
64} // namespace ns3
65
66#endif /* UDP_ECHO_SERVER_H */
a polymophic address class
Definition address.h:111
network packets
Definition packet.h:228
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:67
SinkApplication(uint16_t defaultPort=0)
Constructor.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:49
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
uint8_t m_tos
The packets Type of Service.
static TypeId GetTypeId()
Get the type ID.
void DoStartApplication() override
Application specific startup code for child subclasses.
void HandleRead(Ptr< Socket > socket)
Handle a packet reception.
Every class exported by the ns3 library is enclosed in the ns3 namespace.