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 "ns3/address.h"
11#include "ns3/application.h"
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 /**
37 * \brief Get the type ID.
38 * \return the object TypeId
39 */
40 static TypeId GetTypeId();
42 ~UdpEchoServer() override;
43
44 private:
45 void StartApplication() override;
46 void StopApplication() override;
47
48 /**
49 * \brief Handle a packet reception.
50 *
51 * This function is called by lower layers.
52 *
53 * \param socket the socket the packet was received to.
54 */
55 void HandleRead(Ptr<Socket> socket);
56
57 uint16_t m_port; //!< Port on which we listen for incoming packets.
58 uint8_t m_tos; //!< The packets Type of Service
59 Ptr<Socket> m_socket; //!< IPv4 Socket
60 Ptr<Socket> m_socket6; //!< IPv6 Socket
61 Address m_local; //!< local multicast address
62
63 /// Callbacks for tracing the packet Rx events
65
66 /// Callbacks for tracing the packet Rx events, includes source and destination addresses
68};
69
70} // namespace ns3
71
72#endif /* UDP_ECHO_SERVER_H */
a polymophic address class
Definition address.h:90
The base class for all ns3 applications.
Definition application.h:51
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 Echo server.
void StartApplication() override
Application specific startup code.
uint16_t m_port
Port on which we listen for incoming packets.
Address m_local
local multicast address
TracedCallback< Ptr< const Packet >, const Address &, const Address & > m_rxTraceWithAddresses
Callbacks for tracing the packet Rx events, includes source and destination addresses.
Ptr< Socket > m_socket6
IPv6 Socket.
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
IPv4 Socket.
void HandleRead(Ptr< Socket > socket)
Handle a packet reception.
Every class exported by the ns3 library is enclosed in the ns3 namespace.