A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
12
#include "
packet-socket-address.h
"
13
14
#include "ns3/application.h"
15
#include "ns3/event-id.h"
16
#include "ns3/ptr.h"
17
#include "ns3/traced-callback.h"
18
19
namespace
ns3
20
{
21
22
class
Socket;
23
class
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
*/
37
class
PacketSocketServer
:
public
Application
38
{
39
public
:
40
/**
41
* \brief Get the type ID.
42
* \return the object TypeId
43
*/
44
static
TypeId
GetTypeId
();
45
46
PacketSocketServer
();
47
48
~PacketSocketServer
()
override
;
49
50
/**
51
* \brief set the local address and protocol to be used
52
* \param addr local address
53
*/
54
void
SetLocal
(
PacketSocketAddress
addr);
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
73
PacketSocketAddress
m_localAddress
;
//!< Local address
74
bool
m_localAddressSet
;
//!< Sanity check
75
76
/// Traced Callback: received packets, source address.
77
TracedCallback<Ptr<const Packet>
,
const
Address
&>
m_rxTrace
;
78
};
79
80
}
// namespace ns3
81
82
#endif
/* PACKET_SOCKET_SERVER_H */
ns3::Address
a polymophic address class
Definition
address.h:90
ns3::Application
The base class for all ns3 applications.
Definition
application.h:51
ns3::PacketSocketAddress
an address for a packet socket
Definition
packet-socket-address.h:29
ns3::PacketSocketServer
A server using PacketSocket.
Definition
packet-socket-server.h:38
ns3::PacketSocketServer::m_bytesRx
uint32_t m_bytesRx
Total bytes received.
Definition
packet-socket-server.h:70
ns3::PacketSocketServer::m_rxTrace
TracedCallback< Ptr< const Packet >, const Address & > m_rxTrace
Traced Callback: received packets, source address.
Definition
packet-socket-server.h:77
ns3::PacketSocketServer::HandleRead
void HandleRead(Ptr< Socket > socket)
Handle a packet received by the application.
Definition
packet-socket-server.cc:102
ns3::PacketSocketServer::m_socket
Ptr< Socket > m_socket
Socket.
Definition
packet-socket-server.h:72
ns3::PacketSocketServer::StopApplication
void StopApplication() override
Application specific shutdown code.
Definition
packet-socket-server.cc:86
ns3::PacketSocketServer::m_localAddressSet
bool m_localAddressSet
Sanity check.
Definition
packet-socket-server.h:74
ns3::PacketSocketServer::m_pktRx
uint32_t m_pktRx
The number of received packets.
Definition
packet-socket-server.h:69
ns3::PacketSocketServer::~PacketSocketServer
~PacketSocketServer() override
Definition
packet-socket-server.cc:57
ns3::PacketSocketServer::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
packet-socket-server.cc:35
ns3::PacketSocketServer::StartApplication
void StartApplication() override
Application specific startup code.
Definition
packet-socket-server.cc:70
ns3::PacketSocketServer::SetLocal
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
Definition
packet-socket-server.cc:94
ns3::PacketSocketServer::DoDispose
void DoDispose() override
Destructor implementation.
Definition
packet-socket-server.cc:63
ns3::PacketSocketServer::PacketSocketServer
PacketSocketServer()
Definition
packet-socket-server.cc:48
ns3::PacketSocketServer::m_localAddress
PacketSocketAddress m_localAddress
Local address.
Definition
packet-socket-server.h:73
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition
traced-callback.h:43
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
uint32_t
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
packet-socket-address.h
src
network
utils
packet-socket-server.h
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0