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
wifi-example-apps.h
Go to the documentation of this file.
1
/*
2
* SPDX-License-Identifier: GPL-2.0-only
3
*
4
* Authors: Joe Kopena <tjkopena@cs.drexel.edu>
5
*
6
* These applications are used in the WiFi Distance Test experiment,
7
* described and implemented in test02.cc. That file should be in the
8
* same place as this file. The applications have two very simple
9
* jobs, they just generate and receive packets. We could use the
10
* standard Application classes included in the NS-3 distribution.
11
* These have been written just to change the behavior a little, and
12
* provide more examples.
13
*
14
*/
15
16
#include "ns3/application.h"
17
#include "ns3/core-module.h"
18
#include "ns3/network-module.h"
19
#include "ns3/stats-module.h"
20
21
using namespace
ns3
;
22
23
// ==============================================
24
// SENDER
25
// ==============================================
26
27
/**
28
* Sender application.
29
*/
30
class
Sender
:
public
Application
31
{
32
public
:
33
/**
34
* \brief Get the type ID.
35
* \return The object TypeId.
36
*/
37
static
TypeId
GetTypeId
();
38
39
Sender
();
40
~Sender
()
override
;
41
42
protected
:
43
void
DoDispose
()
override
;
44
45
private
:
46
void
StartApplication
()
override
;
47
void
StopApplication
()
override
;
48
49
/**
50
* Send a packet.
51
*/
52
void
SendPacket
();
53
54
Ipv4Address
m_destAddr
;
//!< Destination address
55
uint32_t
m_destPort
{0};
//!< Destination port
56
uint32_t
m_packetSize
{0};
//!< The packet size
57
Ptr<ConstantRandomVariable>
m_interval
;
//!< Rng for sending packets
58
uint32_t
m_nPackets
{0};
//!< Number of packets to send
59
uint32_t
m_count
{0};
//!< Number of packets sent
60
61
Ptr<Socket>
m_socket
;
//!< Sending socket
62
EventId
m_sendEvent
;
//!< Send packet event
63
64
/// Tx TracedCallback
65
TracedCallback<Ptr<const Packet>
>
m_txTrace
;
66
};
67
68
// ==============================================
69
// RECEIVER
70
// ==============================================
71
72
/**
73
* Receiver application.
74
*/
75
class
Receiver
:
public
Application
76
{
77
public
:
78
/**
79
* \brief Get the type ID.
80
* \return The object TypeId.
81
*/
82
static
TypeId
GetTypeId
();
83
84
Receiver
();
85
~Receiver
()
override
;
86
87
/**
88
* Set the counter calculator for received packets.
89
* \param calc The CounterCalculator.
90
*/
91
void
SetCounter
(
Ptr
<
CounterCalculator<>
> calc);
92
93
/**
94
* Set the delay tracker for received packets.
95
* \param delay The Delay calculator.
96
*/
97
void
SetDelayTracker
(
Ptr<TimeMinMaxAvgTotalCalculator>
delay);
98
99
protected
:
100
void
DoDispose
()
override
;
101
102
private
:
103
void
StartApplication
()
override
;
104
void
StopApplication
()
override
;
105
106
/**
107
* Receive a packet.
108
* \param socket The receiving socket.
109
*/
110
void
Receive
(
Ptr<Socket>
socket);
111
112
Ptr<Socket>
m_socket
;
//!< Receiving socket
113
uint32_t
m_port
{0};
//!< Listening port
114
115
Ptr<CounterCalculator<>
>
m_calc
;
//!< Counter of the number of received packets
116
Ptr<TimeMinMaxAvgTotalCalculator>
m_delay
;
//!< Delay calculator
117
};
Receiver
Receiver application.
Definition
wifi-example-apps.h:76
Receiver::~Receiver
~Receiver() override
Definition
wifi-example-apps.cc:167
Receiver::StopApplication
void StopApplication() override
Application specific shutdown code.
Definition
wifi-example-apps.cc:200
Receiver::m_port
uint32_t m_port
Listening port.
Definition
wifi-example-apps.h:113
Receiver::m_socket
Ptr< Socket > m_socket
Receiving socket.
Definition
wifi-example-apps.h:112
Receiver::DoDispose
void DoDispose() override
Destructor implementation.
Definition
wifi-example-apps.cc:173
Receiver::SetDelayTracker
void SetDelayTracker(Ptr< TimeMinMaxAvgTotalCalculator > delay)
Set the delay tracker for received packets.
Definition
wifi-example-apps.cc:217
Receiver::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
wifi-example-apps.cc:149
Receiver::Receive
void Receive(Ptr< Socket > socket)
Receive a packet.
Definition
wifi-example-apps.cc:223
Receiver::m_calc
Ptr< CounterCalculator<> > m_calc
Counter of the number of received packets.
Definition
wifi-example-apps.h:115
Receiver::StartApplication
void StartApplication() override
Application specific startup code.
Definition
wifi-example-apps.cc:183
Receiver::Receiver
Receiver()
Definition
wifi-example-apps.cc:162
Receiver::SetCounter
void SetCounter(Ptr< CounterCalculator<> > calc)
Set the counter calculator for received packets.
Definition
wifi-example-apps.cc:211
Receiver::m_delay
Ptr< TimeMinMaxAvgTotalCalculator > m_delay
Delay calculator.
Definition
wifi-example-apps.h:116
Sender
Sender application.
Definition
wifi-example-apps.h:31
Sender::m_socket
Ptr< Socket > m_socket
Sending socket.
Definition
wifi-example-apps.h:61
Sender::SendPacket
void SendPacket()
Send a packet.
Definition
wifi-example-apps.cc:119
Sender::m_count
uint32_t m_count
Number of packets sent.
Definition
wifi-example-apps.h:59
Sender::m_destPort
uint32_t m_destPort
Destination port.
Definition
wifi-example-apps.h:55
Sender::m_interval
Ptr< ConstantRandomVariable > m_interval
Rng for sending packets.
Definition
wifi-example-apps.h:57
Sender::StopApplication
void StopApplication() override
Application specific shutdown code.
Definition
wifi-example-apps.cc:112
Sender::m_destAddr
Ipv4Address m_destAddr
Destination address.
Definition
wifi-example-apps.h:54
Sender::DoDispose
void DoDispose() override
Destructor implementation.
Definition
wifi-example-apps.cc:83
Sender::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
wifi-example-apps.cc:34
Sender::m_sendEvent
EventId m_sendEvent
Send packet event.
Definition
wifi-example-apps.h:62
Sender::~Sender
~Sender() override
Definition
wifi-example-apps.cc:77
Sender::m_packetSize
uint32_t m_packetSize
The packet size.
Definition
wifi-example-apps.h:56
Sender::Sender
Sender()
Definition
wifi-example-apps.cc:71
Sender::m_txTrace
TracedCallback< Ptr< const Packet > > m_txTrace
Tx TracedCallback.
Definition
wifi-example-apps.h:65
Sender::m_nPackets
uint32_t m_nPackets
Number of packets to send.
Definition
wifi-example-apps.h:58
Sender::StartApplication
void StartApplication() override
Application specific startup code.
Definition
wifi-example-apps.cc:93
ns3::Application
The base class for all ns3 applications.
Definition
application.h:51
ns3::CounterCalculator
Template class CounterCalculator.
Definition
basic-data-calculators.h:290
ns3::EventId
An identifier for simulation events.
Definition
event-id.h:45
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
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.
examples
stats
wifi-example-apps.h
Generated on Fri Nov 8 2024 13:58:58 for ns-3 by
1.11.0