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-client.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_CLIENT_H
21
#define PACKET_SOCKET_CLIENT_H
22
23
#include "
packet-socket-address.h
"
24
25
#include "ns3/application.h"
26
#include "ns3/event-id.h"
27
#include "ns3/ptr.h"
28
#include "ns3/traced-callback.h"
29
30
namespace
ns3
31
{
32
33
class
Socket;
34
class
Packet;
35
36
/**
37
* \ingroup socket
38
*
39
* \brief A simple client.
40
*
41
* Sends packets using PacketSocket. It does not require (or use) IP.
42
*
43
* Packets are sent as soon as PacketSocketClient::Start is called.
44
* The application has the same requirements as the PacketSocket for
45
* what concerns the underlying NetDevice and the Address scheme.
46
* It is meant to be used in ns-3 tests.
47
*
48
* The application will send `MaxPackets' packets, one every `Interval'
49
* time. Packet size (`PacketSize') can be configured.
50
* Provides a "Tx" Traced Callback (transmitted packets, source address).
51
*
52
* Note: packets larger than the NetDevice MTU will not be sent.
53
*/
54
class
PacketSocketClient
:
public
Application
55
{
56
public
:
57
/**
58
* \brief Get the type ID.
59
* \return the object TypeId
60
*/
61
static
TypeId
GetTypeId
();
62
63
PacketSocketClient
();
64
65
~PacketSocketClient
()
override
;
66
67
/**
68
* \brief set the remote address and protocol to be used
69
* \param addr remote address
70
*/
71
void
SetRemote
(
PacketSocketAddress
addr);
72
73
/**
74
* \brief Query the priority value of this socket
75
* \return The priority value
76
*/
77
uint8_t
GetPriority
()
const
;
78
79
protected
:
80
void
DoDispose
()
override
;
81
82
private
:
83
void
StartApplication
()
override
;
84
void
StopApplication
()
override
;
85
86
/**
87
* \brief Manually set the socket priority
88
* \param priority The socket priority (in the range 0..6)
89
*/
90
void
SetPriority
(uint8_t priority);
91
92
/**
93
* \brief Send a packet
94
*
95
* Either <i>Interval</i> and <i>MaxPackets</i> may be zero, but not both. If <i>Interval</i>
96
* is zero, the PacketSocketClient will send <i>MaxPackets</i> packets without any delay into
97
* the socket. If <i>MaxPackets</i> is zero, then the PacketSocketClient will send every
98
* <i>Interval</i> until the application is stopped.
99
*/
100
void
Send
();
101
102
uint32_t
m_maxPackets
;
//!< Maximum number of packets the application will send
103
Time
m_interval
;
//!< Packet inter-send time
104
uint32_t
m_size
;
//!< Size of the sent packet
105
uint8_t
m_priority
;
//!< Priority of the sent packets
106
107
uint32_t
m_sent
;
//!< Counter for sent packets
108
Ptr<Socket>
m_socket
;
//!< Socket
109
PacketSocketAddress
m_peerAddress
;
//!< Remote peer address
110
bool
m_peerAddressSet
;
//!< Sanity check
111
EventId
m_sendEvent
;
//!< Event to send the next packet
112
113
/// Traced Callback: sent packets, source address.
114
TracedCallback<Ptr<const Packet>
,
const
Address
&>
m_txTrace
;
115
};
116
117
}
// namespace ns3
118
119
#endif
/* PACKET_SOCKET_CLIENT_H */
ns3::Address
a polymophic address class
Definition:
address.h:101
ns3::Application
The base class for all ns3 applications.
Definition:
application.h:62
ns3::EventId
An identifier for simulation events.
Definition:
event-id.h:56
ns3::PacketSocketAddress
an address for a packet socket
Definition:
packet-socket-address.h:40
ns3::PacketSocketClient
A simple client.
Definition:
packet-socket-client.h:55
ns3::PacketSocketClient::m_sent
uint32_t m_sent
Counter for sent packets.
Definition:
packet-socket-client.h:107
ns3::PacketSocketClient::StopApplication
void StopApplication() override
Application specific shutdown code.
Definition:
packet-socket-client.cc:152
ns3::PacketSocketClient::m_txTrace
TracedCallback< Ptr< const Packet >, const Address & > m_txTrace
Traced Callback: sent packets, source address.
Definition:
packet-socket-client.h:114
ns3::PacketSocketClient::m_socket
Ptr< Socket > m_socket
Socket.
Definition:
packet-socket-client.h:108
ns3::PacketSocketClient::DoDispose
void DoDispose() override
Destructor implementation.
Definition:
packet-socket-client.cc:105
ns3::PacketSocketClient::Send
void Send()
Send a packet.
Definition:
packet-socket-client.cc:160
ns3::PacketSocketClient::GetPriority
uint8_t GetPriority() const
Query the priority value of this socket.
Definition:
packet-socket-client.cc:122
ns3::PacketSocketClient::m_sendEvent
EventId m_sendEvent
Event to send the next packet.
Definition:
packet-socket-client.h:111
ns3::PacketSocketClient::m_maxPackets
uint32_t m_maxPackets
Maximum number of packets the application will send.
Definition:
packet-socket-client.h:102
ns3::PacketSocketClient::SetPriority
void SetPriority(uint8_t priority)
Manually set the socket priority.
Definition:
packet-socket-client.cc:112
ns3::PacketSocketClient::PacketSocketClient
PacketSocketClient()
Definition:
packet-socket-client.cc:82
ns3::PacketSocketClient::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
packet-socket-client.cc:46
ns3::PacketSocketClient::~PacketSocketClient
~PacketSocketClient() override
Definition:
packet-socket-client.cc:91
ns3::PacketSocketClient::m_peerAddressSet
bool m_peerAddressSet
Sanity check.
Definition:
packet-socket-client.h:110
ns3::PacketSocketClient::SetRemote
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
Definition:
packet-socket-client.cc:97
ns3::PacketSocketClient::m_size
uint32_t m_size
Size of the sent packet.
Definition:
packet-socket-client.h:104
ns3::PacketSocketClient::m_priority
uint8_t m_priority
Priority of the sent packets.
Definition:
packet-socket-client.h:105
ns3::PacketSocketClient::StartApplication
void StartApplication() override
Application specific startup code.
Definition:
packet-socket-client.cc:128
ns3::PacketSocketClient::m_peerAddress
PacketSocketAddress m_peerAddress
Remote peer address.
Definition:
packet-socket-client.h:109
ns3::PacketSocketClient::m_interval
Time m_interval
Packet inter-send time.
Definition:
packet-socket-client.h:103
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition:
traced-callback.h:54
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
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 May 28 2024 23:38:46 for ns-3 by
1.9.6