A Discrete-Event Network Simulator
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
32using namespace ns3;
33
34// ==============================================
35// SENDER
36// ==============================================
37
41class 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
71
74
77};
78
79// ==============================================
80// RECEIVER
81// ==============================================
82
86class Receiver : public Application
87{
88 public:
93 static TypeId GetTypeId();
94
95 Receiver();
96 ~Receiver() override;
97
103
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
125
128};
Receiver application.
~Receiver() override
void StopApplication() override
Application specific shutdown code.
uint32_t m_port
Listening port.
Ptr< Socket > m_socket
Receiving socket.
void DoDispose() override
Destructor implementation.
void SetDelayTracker(Ptr< TimeMinMaxAvgTotalCalculator > delay)
Set the delay tracker for received packets.
static TypeId GetTypeId()
Get the type ID.
void Receive(Ptr< Socket > socket)
Receive a packet.
Ptr< CounterCalculator<> > m_calc
Counter of the number of received packets.
void StartApplication() override
Application specific startup code.
void SetCounter(Ptr< CounterCalculator<> > calc)
Set the counter calculator for received packets.
Ptr< TimeMinMaxAvgTotalCalculator > m_delay
Delay calculator.
Sender application.
Ptr< Socket > m_socket
Sending socket.
void SendPacket()
Send a packet.
uint32_t m_count
Number of packets sent.
uint32_t m_destPort
Destination port.
Ptr< ConstantRandomVariable > m_interval
Rng for sending packets.
void StopApplication() override
Application specific shutdown code.
Ipv4Address m_destAddr
Destination address.
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
EventId m_sendEvent
Send packet event.
~Sender() override
uint32_t m_packetSize
The packet size.
TracedCallback< Ptr< const Packet > > m_txTrace
Tx TracedCallback.
uint32_t m_nPackets
Number of packets to send.
void StartApplication() override
Application specific startup code.
The base class for all ns3 applications.
Definition: application.h:62
Template class CounterCalculator.
An identifier for simulation events.
Definition: event-id.h:55
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.