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
#ifndef WIFI_EXAMPLE_APPS_H
17
#define WIFI_EXAMPLE_APPS_H
18
19
#include "ns3/application.h"
20
#include "ns3/core-module.h"
21
#include "ns3/network-module.h"
22
#include "ns3/stats-module.h"
23
24
using namespace
ns3
;
25
26
// ==============================================
27
// SENDER
28
// ==============================================
29
30
/**
31
* Sender application.
32
*/
33
class
Sender
:
public
Application
34
{
35
public
:
36
/**
37
* @brief Get the type ID.
38
* @return The object TypeId.
39
*/
40
static
TypeId
GetTypeId
();
41
42
Sender
();
43
~Sender
()
override
;
44
45
protected
:
46
void
DoDispose
()
override
;
47
48
private
:
49
void
StartApplication
()
override
;
50
void
StopApplication
()
override
;
51
52
/**
53
* Send a packet.
54
*/
55
void
SendPacket
();
56
57
Ipv4Address
m_destAddr
;
//!< Destination address
58
uint32_t
m_destPort
{0};
//!< Destination port
59
uint32_t
m_packetSize
{0};
//!< The packet size
60
Ptr<ConstantRandomVariable>
m_interval
;
//!< Rng for sending packets
61
uint32_t
m_nPackets
{0};
//!< Number of packets to send
62
uint32_t
m_count
{0};
//!< Number of packets sent
63
64
Ptr<Socket>
m_socket
;
//!< Sending socket
65
EventId
m_sendEvent
;
//!< Send packet event
66
67
/// Tx TracedCallback
68
TracedCallback<Ptr<const Packet>
>
m_txTrace
;
69
};
70
71
// ==============================================
72
// RECEIVER
73
// ==============================================
74
75
/**
76
* Receiver application.
77
*/
78
class
Receiver
:
public
Application
79
{
80
public
:
81
/**
82
* @brief Get the type ID.
83
* @return The object TypeId.
84
*/
85
static
TypeId
GetTypeId
();
86
87
Receiver
();
88
~Receiver
()
override
;
89
90
/**
91
* Set the counter calculator for received packets.
92
* @param calc The CounterCalculator.
93
*/
94
void
SetCounter
(
Ptr
<
CounterCalculator<>
> calc);
95
96
/**
97
* Set the delay tracker for received packets.
98
* @param delay The Delay calculator.
99
*/
100
void
SetDelayTracker
(
Ptr<TimeMinMaxAvgTotalCalculator>
delay);
101
102
protected
:
103
void
DoDispose
()
override
;
104
105
private
:
106
void
StartApplication
()
override
;
107
void
StopApplication
()
override
;
108
109
/**
110
* Receive a packet.
111
* @param socket The receiving socket.
112
*/
113
void
Receive
(
Ptr<Socket>
socket);
114
115
Ptr<Socket>
m_socket
;
//!< Receiving socket
116
uint32_t
m_port
{0};
//!< Listening port
117
118
Ptr<CounterCalculator<>
>
m_calc
;
//!< Counter of the number of received packets
119
Ptr<TimeMinMaxAvgTotalCalculator>
m_delay
;
//!< Delay calculator
120
};
121
122
#endif
// WIFI_EXAMPLE_APPS_H
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:116
Receiver::m_socket
Ptr< Socket > m_socket
Receiving socket.
Definition
wifi-example-apps.h:115
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:118
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:119
Sender::m_socket
Ptr< Socket > m_socket
Sending socket.
Definition
wifi-example-apps.h:64
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:62
Sender::m_destPort
uint32_t m_destPort
Destination port.
Definition
wifi-example-apps.h:58
Sender::m_interval
Ptr< ConstantRandomVariable > m_interval
Rng for sending packets.
Definition
wifi-example-apps.h:60
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:57
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:65
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:59
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:68
Sender::m_nPackets
uint32_t m_nPackets
Number of packets to send.
Definition
wifi-example-apps.h:61
Sender::StartApplication
void StartApplication() override
Application specific startup code.
Definition
wifi-example-apps.cc:93
ns3::Application::Application
Application()
Definition
application.cc:49
ns3::CounterCalculator
Template class CounterCalculator.
Definition
basic-data-calculators.h:290
ns3::EventId
An identifier for simulation events.
Definition
event-id.h:44
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:33
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition
traced-callback.h:46
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.
examples
stats
wifi-example-apps.h
Generated on
for ns-3 by
1.15.0