A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
packet-socket-server.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Universita' di Firenze
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 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
18 */
19
20#ifndef PACKET_SOCKET_SERVER_H
21#define PACKET_SOCKET_SERVER_H
22
24
25#include "ns3/application.h"
26#include "ns3/event-id.h"
27#include "ns3/ptr.h"
28#include "ns3/traced-callback.h"
29
30namespace ns3
31{
32
33class Socket;
34class Packet;
35
36/**
37 * \ingroup socket
38 *
39 * \brief A server using PacketSocket.
40 *
41 * Receives packets using PacketSocket. It does not require (or use) IP.
42 * The application has the same requirements as the PacketSocket for
43 * what concerns the underlying NetDevice and the Address scheme.
44 * It is meant to be used in ns-3 tests.
45 *
46 * Provides a "Rx" Traced Callback (received packets, source address)
47 */
49{
50 public:
51 /**
52 * \brief Get the type ID.
53 * \return the object TypeId
54 */
55 static TypeId GetTypeId();
56
58
59 ~PacketSocketServer() override;
60
61 /**
62 * \brief set the local address and protocol to be used
63 * \param addr local address
64 */
66
67 protected:
68 void DoDispose() override;
69
70 private:
71 void StartApplication() override;
72 void StopApplication() override;
73
74 /**
75 * \brief Handle a packet received by the application
76 * \param socket the receiving socket
77 */
78 void HandleRead(Ptr<Socket> socket);
79
80 uint32_t m_pktRx; //!< The number of received packets
81 uint32_t m_bytesRx; //!< Total bytes received
82
83 Ptr<Socket> m_socket; //!< Socket
85 bool m_localAddressSet; //!< Sanity check
86
87 /// Traced Callback: received packets, source address.
89};
90
91} // namespace ns3
92
93#endif /* PACKET_SOCKET_SERVER_H */
a polymophic address class
Definition: address.h:101
The base class for all ns3 applications.
Definition: application.h:62
an address for a packet socket
A server using PacketSocket.
uint32_t m_bytesRx
Total bytes received.
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced Callback: received packets, source address.
void HandleRead(Ptr< Socket > socket)
Handle a packet received by the application.
Ptr< Socket > m_socket
Socket.
void StopApplication() override
Application specific shutdown code.
bool m_localAddressSet
Sanity check.
uint32_t m_pktRx
The number of received packets.
static TypeId GetTypeId()
Get the type ID.
void StartApplication() override
Application specific startup code.
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
void DoDispose() override
Destructor implementation.
PacketSocketAddress m_localAddress
Local address.
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.