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 * 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
18#ifndef UDP_ECHO_SERVER_H
19#define UDP_ECHO_SERVER_H
20
21#include "ns3/address.h"
22#include "ns3/application.h"
23#include "ns3/event-id.h"
24#include "ns3/ptr.h"
25#include "ns3/traced-callback.h"
26
27namespace ns3
28{
29
30class Socket;
31class Packet;
32
33/**
34 * \ingroup applications
35 * \defgroup udpecho UdpEcho
36 */
37
38/**
39 * \ingroup udpecho
40 * \brief A Udp Echo server
41 *
42 * Every packet received is sent back.
43 */
45{
46 public:
47 /**
48 * \brief Get the type ID.
49 * \return the object TypeId
50 */
51 static TypeId GetTypeId();
53 ~UdpEchoServer() override;
54
55 private:
56 void StartApplication() override;
57 void StopApplication() override;
58
59 /**
60 * \brief Handle a packet reception.
61 *
62 * This function is called by lower layers.
63 *
64 * \param socket the socket the packet was received to.
65 */
66 void HandleRead(Ptr<Socket> socket);
67
68 uint16_t m_port; //!< Port on which we listen for incoming packets.
69 uint8_t m_tos; //!< The packets Type of Service
70 Ptr<Socket> m_socket; //!< IPv4 Socket
71 Ptr<Socket> m_socket6; //!< IPv6 Socket
72 Address m_local; //!< local multicast address
73
74 /// Callbacks for tracing the packet Rx events
76
77 /// Callbacks for tracing the packet Rx events, includes source and destination addresses
79};
80
81} // namespace ns3
82
83#endif /* UDP_ECHO_SERVER_H */
a polymophic address class
Definition: address.h:101
The base class for all ns3 applications.
Definition: application.h:62
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 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.
~UdpEchoServer() override
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.