A Discrete-Event Network Simulator
lorawan @ (+)
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Typedefs
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
j
l
m
n
o
p
q
r
s
t
w
Enumerator
a
b
c
d
e
f
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Properties
Related Symbols
:
a
b
c
d
e
g
h
i
j
l
m
n
o
p
q
r
s
t
u
w
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
w
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
Enumerations
Enumerator
e
l
v
Macros
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
packet-socket-client.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_CLIENT_H
10
#define PACKET_SOCKET_CLIENT_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 simple client.
29
*
30
* Sends packets using PacketSocket. It does not require (or use) IP.
31
*
32
* Packets are sent as soon as PacketSocketClient::Start is called.
33
* The application has the same requirements as the PacketSocket for
34
* what concerns the underlying NetDevice and the Address scheme.
35
* It is meant to be used in ns-3 tests.
36
*
37
* The application will send `MaxPackets' packets, one every `Interval'
38
* time. Packet size (`PacketSize') can be configured.
39
* Provides a "Tx" Traced Callback (transmitted packets, source address).
40
*
41
* Note: packets larger than the NetDevice MTU will not be sent.
42
*/
43
class
PacketSocketClient
:
public
Application
44
{
45
public
:
46
/**
47
* @brief Get the type ID.
48
* @return the object TypeId
49
*/
50
static
TypeId
GetTypeId
();
51
52
PacketSocketClient
();
53
54
~PacketSocketClient
()
override
;
55
56
/**
57
* @brief set the remote address and protocol to be used
58
* @param addr remote address
59
*/
60
void
SetRemote
(
PacketSocketAddress
addr);
61
62
/**
63
* @brief Query the priority value of this socket
64
* @return The priority value
65
*/
66
uint8_t
GetPriority
()
const
;
67
68
protected
:
69
void
DoDispose
()
override
;
70
71
private
:
72
void
StartApplication
()
override
;
73
void
StopApplication
()
override
;
74
75
/**
76
* @brief Manually set the socket priority
77
* @param priority The socket priority (in the range 0..6)
78
*/
79
void
SetPriority
(uint8_t priority);
80
81
/**
82
* @brief Send a packet
83
*
84
* Either <i>Interval</i> and <i>MaxPackets</i> may be zero, but not both. If <i>Interval</i>
85
* is zero, the PacketSocketClient will send <i>MaxPackets</i> packets without any delay into
86
* the socket. If <i>MaxPackets</i> is zero, then the PacketSocketClient will send every
87
* <i>Interval</i> until the application is stopped.
88
*/
89
void
Send
();
90
91
uint32_t
m_maxPackets
;
//!< Maximum number of packets the application will send
92
Time
m_interval
;
//!< Packet inter-send time
93
uint32_t
m_size
;
//!< Size of the sent packet
94
uint8_t
m_priority
;
//!< Priority of the sent packets
95
96
uint32_t
m_sent
;
//!< Counter for sent packets
97
Ptr<Socket>
m_socket
;
//!< Socket
98
PacketSocketAddress
m_peerAddress
;
//!< Remote peer address
99
bool
m_peerAddressSet
;
//!< Sanity check
100
EventId
m_sendEvent
;
//!< Event to send the next packet
101
102
/// Traced Callback: sent packets, source address.
103
TracedCallback<Ptr<const Packet>
,
const
Address
&>
m_txTrace
;
104
};
43
class
PacketSocketClient
:
public
Application
{
…
};
105
106
}
// namespace ns3
107
108
#endif
/* PACKET_SOCKET_CLIENT_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::EventId
An identifier for simulation events.
Definition
event-id.h:45
ns3::PacketSocketAddress
an address for a packet socket
Definition
packet-socket-address.h:29
ns3::PacketSocketClient
A simple client.
Definition
packet-socket-client.h:44
ns3::PacketSocketClient::m_sent
uint32_t m_sent
Counter for sent packets.
Definition
packet-socket-client.h:96
ns3::PacketSocketClient::StopApplication
void StopApplication() override
Application specific shutdown code.
Definition
packet-socket-client.cc:141
ns3::PacketSocketClient::m_txTrace
TracedCallback< Ptr< const Packet >, const Address & > m_txTrace
Traced Callback: sent packets, source address.
Definition
packet-socket-client.h:103
ns3::PacketSocketClient::m_socket
Ptr< Socket > m_socket
Socket.
Definition
packet-socket-client.h:97
ns3::PacketSocketClient::DoDispose
void DoDispose() override
Destructor implementation.
Definition
packet-socket-client.cc:94
ns3::PacketSocketClient::Send
void Send()
Send a packet.
Definition
packet-socket-client.cc:149
ns3::PacketSocketClient::GetPriority
uint8_t GetPriority() const
Query the priority value of this socket.
Definition
packet-socket-client.cc:111
ns3::PacketSocketClient::m_sendEvent
EventId m_sendEvent
Event to send the next packet.
Definition
packet-socket-client.h:100
ns3::PacketSocketClient::m_maxPackets
uint32_t m_maxPackets
Maximum number of packets the application will send.
Definition
packet-socket-client.h:91
ns3::PacketSocketClient::SetPriority
void SetPriority(uint8_t priority)
Manually set the socket priority.
Definition
packet-socket-client.cc:101
ns3::PacketSocketClient::PacketSocketClient
PacketSocketClient()
Definition
packet-socket-client.cc:71
ns3::PacketSocketClient::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
packet-socket-client.cc:35
ns3::PacketSocketClient::~PacketSocketClient
~PacketSocketClient() override
Definition
packet-socket-client.cc:80
ns3::PacketSocketClient::m_peerAddressSet
bool m_peerAddressSet
Sanity check.
Definition
packet-socket-client.h:99
ns3::PacketSocketClient::SetRemote
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
Definition
packet-socket-client.cc:86
ns3::PacketSocketClient::m_size
uint32_t m_size
Size of the sent packet.
Definition
packet-socket-client.h:93
ns3::PacketSocketClient::m_priority
uint8_t m_priority
Priority of the sent packets.
Definition
packet-socket-client.h:94
ns3::PacketSocketClient::StartApplication
void StartApplication() override
Application specific startup code.
Definition
packet-socket-client.cc:117
ns3::PacketSocketClient::m_peerAddress
PacketSocketAddress m_peerAddress
Remote peer address.
Definition
packet-socket-client.h:98
ns3::PacketSocketClient::m_interval
Time m_interval
Packet inter-send time.
Definition
packet-socket-client.h:92
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
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:49
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-client.h
Generated on Tue Apr 8 2025 15:27:17 for ns-3 by
1.11.0