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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Tommaso Pecorella <tommaso.pecorella@unifi.it>
7 */
8
9#ifndef PACKET_SOCKET_SERVER_H
10#define PACKET_SOCKET_SERVER_H
11
13
14#include "ns3/application.h"
15#include "ns3/event-id.h"
16#include "ns3/ptr.h"
17#include "ns3/traced-callback.h"
18
19namespace ns3
20{
21
22class Socket;
23class Packet;
24
25/**
26 * \ingroup socket
27 *
28 * \brief A server using PacketSocket.
29 *
30 * Receives packets using PacketSocket. It does not require (or use) IP.
31 * The application has the same requirements as the PacketSocket for
32 * what concerns the underlying NetDevice and the Address scheme.
33 * It is meant to be used in ns-3 tests.
34 *
35 * Provides a "Rx" Traced Callback (received packets, source address)
36 */
38{
39 public:
40 /**
41 * \brief Get the type ID.
42 * \return the object TypeId
43 */
44 static TypeId GetTypeId();
45
47
48 ~PacketSocketServer() override;
49
50 /**
51 * \brief set the local address and protocol to be used
52 * \param addr local address
53 */
55
56 protected:
57 void DoDispose() override;
58
59 private:
60 void StartApplication() override;
61 void StopApplication() override;
62
63 /**
64 * \brief Handle a packet received by the application
65 * \param socket the receiving socket
66 */
67 void HandleRead(Ptr<Socket> socket);
68
69 uint32_t m_pktRx; //!< The number of received packets
70 uint32_t m_bytesRx; //!< Total bytes received
71
72 Ptr<Socket> m_socket; //!< Socket
74 bool m_localAddressSet; //!< Sanity check
75
76 /// Traced Callback: received packets, source address.
78};
79
80} // namespace ns3
81
82#endif /* PACKET_SOCKET_SERVER_H */
a polymophic address class
Definition address.h:90
The base class for all ns3 applications.
Definition application.h:51
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.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.