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
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License version 2 as
4
* published by the Free Software Foundation;
5
*
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
*
11
* You should have received a copy of the GNU General Public License
12
* along with this program; if not, write to the Free Software
13
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14
*
15
* Authors: Joe Kopena <tjkopena@cs.drexel.edu>
16
*
17
* These applications are used in the WiFi Distance Test experiment,
18
* described and implemented in test02.cc. That file should be in the
19
* same place as this file. The applications have two very simple
20
* jobs, they just generate and receive packets. We could use the
21
* standard Application classes included in the NS-3 distribution.
22
* These have been written just to change the behavior a little, and
23
* provide more examples.
24
*
25
*/
26
27
#include "ns3/application.h"
28
#include "ns3/core-module.h"
29
#include "ns3/network-module.h"
30
#include "ns3/stats-module.h"
31
32
using namespace
ns3
;
33
34
// ==============================================
35
// SENDER
36
// ==============================================
37
41
class
Sender
:
public
Application
42
{
43
public
:
48
static
TypeId
GetTypeId
();
49
50
Sender
();
51
~Sender
()
override
;
52
53
protected
:
54
void
DoDispose
()
override
;
55
56
private
:
57
void
StartApplication
()
override
;
58
void
StopApplication
()
override
;
59
63
void
SendPacket
();
64
65
Ipv4Address
m_destAddr
;
66
uint32_t
m_destPort
{0};
67
uint32_t
m_packetSize
{0};
68
Ptr<ConstantRandomVariable>
m_interval
;
69
uint32_t
m_nPackets
{0};
70
uint32_t
m_count
{0};
71
72
Ptr<Socket>
m_socket
;
73
EventId
m_sendEvent
;
74
76
TracedCallback<Ptr<const Packet>
>
m_txTrace
;
77
};
78
79
// ==============================================
80
// RECEIVER
81
// ==============================================
82
86
class
Receiver
:
public
Application
87
{
88
public
:
93
static
TypeId
GetTypeId
();
94
95
Receiver
();
96
~Receiver
()
override
;
97
102
void
SetCounter
(
Ptr
<
CounterCalculator<>
> calc);
103
108
void
SetDelayTracker
(
Ptr<TimeMinMaxAvgTotalCalculator>
delay);
109
110
protected
:
111
void
DoDispose
()
override
;
112
113
private
:
114
void
StartApplication
()
override
;
115
void
StopApplication
()
override
;
116
121
void
Receive
(
Ptr<Socket>
socket);
122
123
Ptr<Socket>
m_socket
;
124
uint32_t
m_port
{0};
125
126
Ptr<CounterCalculator<>
>
m_calc
;
127
Ptr<TimeMinMaxAvgTotalCalculator>
m_delay
;
128
};
Receiver
Receiver application.
Definition:
wifi-example-apps.h:87
Receiver::~Receiver
~Receiver() override
Definition:
wifi-example-apps.cc:178
Receiver::StopApplication
void StopApplication() override
Application specific shutdown code.
Definition:
wifi-example-apps.cc:211
Receiver::m_port
uint32_t m_port
Listening port.
Definition:
wifi-example-apps.h:124
Receiver::m_socket
Ptr< Socket > m_socket
Receiving socket.
Definition:
wifi-example-apps.h:123
Receiver::DoDispose
void DoDispose() override
Destructor implementation.
Definition:
wifi-example-apps.cc:184
Receiver::SetDelayTracker
void SetDelayTracker(Ptr< TimeMinMaxAvgTotalCalculator > delay)
Set the delay tracker for received packets.
Definition:
wifi-example-apps.cc:228
Receiver::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
wifi-example-apps.cc:160
Receiver::Receive
void Receive(Ptr< Socket > socket)
Receive a packet.
Definition:
wifi-example-apps.cc:234
Receiver::m_calc
Ptr< CounterCalculator<> > m_calc
Counter of the number of received packets.
Definition:
wifi-example-apps.h:126
Receiver::StartApplication
void StartApplication() override
Application specific startup code.
Definition:
wifi-example-apps.cc:194
Receiver::Receiver
Receiver()
Definition:
wifi-example-apps.cc:173
Receiver::SetCounter
void SetCounter(Ptr< CounterCalculator<> > calc)
Set the counter calculator for received packets.
Definition:
wifi-example-apps.cc:222
Receiver::m_delay
Ptr< TimeMinMaxAvgTotalCalculator > m_delay
Delay calculator.
Definition:
wifi-example-apps.h:127
Sender
Sender application.
Definition:
wifi-example-apps.h:42
Sender::m_socket
Ptr< Socket > m_socket
Sending socket.
Definition:
wifi-example-apps.h:72
Sender::SendPacket
void SendPacket()
Send a packet.
Definition:
wifi-example-apps.cc:130
Sender::m_count
uint32_t m_count
Number of packets sent.
Definition:
wifi-example-apps.h:70
Sender::m_destPort
uint32_t m_destPort
Destination port.
Definition:
wifi-example-apps.h:66
Sender::m_interval
Ptr< ConstantRandomVariable > m_interval
Rng for sending packets.
Definition:
wifi-example-apps.h:68
Sender::StopApplication
void StopApplication() override
Application specific shutdown code.
Definition:
wifi-example-apps.cc:123
Sender::m_destAddr
Ipv4Address m_destAddr
Destination address.
Definition:
wifi-example-apps.h:65
Sender::DoDispose
void DoDispose() override
Destructor implementation.
Definition:
wifi-example-apps.cc:94
Sender::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition:
wifi-example-apps.cc:45
Sender::m_sendEvent
EventId m_sendEvent
Send packet event.
Definition:
wifi-example-apps.h:73
Sender::~Sender
~Sender() override
Definition:
wifi-example-apps.cc:88
Sender::m_packetSize
uint32_t m_packetSize
The packet size.
Definition:
wifi-example-apps.h:67
Sender::Sender
Sender()
Definition:
wifi-example-apps.cc:82
Sender::m_txTrace
TracedCallback< Ptr< const Packet > > m_txTrace
Tx TracedCallback.
Definition:
wifi-example-apps.h:76
Sender::m_nPackets
uint32_t m_nPackets
Number of packets to send.
Definition:
wifi-example-apps.h:69
Sender::StartApplication
void StartApplication() override
Application specific startup code.
Definition:
wifi-example-apps.cc:104
ns3::Application
The base class for all ns3 applications.
Definition:
application.h:62
ns3::CounterCalculator
Template class CounterCalculator.
Definition:
basic-data-calculators.h:301
ns3::EventId
An identifier for simulation events.
Definition:
event-id.h:55
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:42
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:77
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.
examples
stats
wifi-example-apps.h
Generated on Thu Feb 8 2024 09:23:52 for ns-3 by
1.9.6