A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
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::m_socket
Ptr< Socket > m_socket
Receiving socket.
Definition:
wifi-example-apps.h:123
Receiver::m_calc
Ptr< CounterCalculator<> > m_calc
Counter of the number of received packets.
Definition:
wifi-example-apps.h:126
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::m_interval
Ptr< ConstantRandomVariable > m_interval
Rng for sending packets.
Definition:
wifi-example-apps.h:68
Sender::m_destAddr
Ipv4Address m_destAddr
Destination address.
Definition:
wifi-example-apps.h:65
Sender::m_sendEvent
EventId m_sendEvent
Send packet event.
Definition:
wifi-example-apps.h:73
Sender::m_txTrace
TracedCallback< Ptr< const Packet > > m_txTrace
Tx TracedCallback.
Definition:
wifi-example-apps.h:76
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< ConstantRandomVariable >
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
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
SendPacket
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...
Definition:
wifi-trans-example.cc:47
examples
stats
wifi-example-apps.h
Generated on Sun Mar 3 2024 17:10:52 for ns-3 by
1.9.1