A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
wifi-example-apps.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License version 2 as
5
* published by the Free Software Foundation;
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
*
16
* Authors: Joe Kopena <tjkopena@cs.drexel.edu>
17
*
18
* These applications are used in the WiFi Distance Test experiment,
19
* described and implemented in test02.cc. That file should be in the
20
* same place as this file. The applications have two very simple
21
* jobs, they just generate and receive packets. We could use the
22
* standard Application classes included in the NS-3 distribution.
23
* These have been written just to change the behavior a little, and
24
* provide more examples.
25
*
26
*/
27
28
#include "ns3/core-module.h"
29
#include "ns3/network-module.h"
30
#include "ns3/application.h"
31
32
#include "ns3/stats-module.h"
33
34
using namespace
ns3
;
35
36
//----------------------------------------------------------------------
37
//------------------------------------------------------
38
class
Sender
:
public
Application
{
39
public
:
40
static
TypeId
GetTypeId (
void
);
41
Sender
();
42
virtual
~
Sender
();
43
44
protected
:
45
virtual
void
DoDispose (
void
);
46
47
private
:
48
virtual
void
StartApplication (
void
);
49
virtual
void
StopApplication (
void
);
50
51
void
SendPacket
();
52
53
uint32_t
m_pktSize
;
54
Ipv4Address
m_destAddr
;
55
uint32_t
m_destPort
;
56
Ptr<ConstantRandomVariable>
m_interval
;
57
uint32_t
m_numPkts
;
58
59
Ptr<Socket>
m_socket
;
60
EventId
m_sendEvent
;
61
62
TracedCallback<Ptr<const Packet>
>
m_txTrace
;
63
64
uint32_t
m_count
;
65
66
// end class Sender
67
};
68
69
70
71
72
//------------------------------------------------------
73
class
Receiver
:
public
Application
{
74
public
:
75
static
TypeId
GetTypeId (
void
);
76
Receiver
();
77
virtual
~
Receiver
();
78
79
void
SetCounter (
Ptr
<
CounterCalculator<>
> calc);
80
void
SetDelayTracker (
Ptr<TimeMinMaxAvgTotalCalculator>
delay);
81
82
protected
:
83
virtual
void
DoDispose (
void
);
84
85
private
:
86
virtual
void
StartApplication (
void
);
87
virtual
void
StopApplication (
void
);
88
89
void
Receive (
Ptr<Socket>
socket);
90
91
Ptr<Socket>
m_socket
;
92
93
uint32_t
m_port
;
94
95
Ptr<CounterCalculator<>
>
m_calc
;
96
Ptr<TimeMinMaxAvgTotalCalculator>
m_delay
;
97
98
// end class Receiver
99
};
100
101
102
103
104
//------------------------------------------------------
105
class
TimestampTag
:
public
Tag
{
106
public
:
107
static
TypeId
GetTypeId (
void
);
108
virtual
TypeId
GetInstanceTypeId (
void
)
const
;
109
110
virtual
uint32_t GetSerializedSize (
void
)
const
;
111
virtual
void
Serialize (
TagBuffer
i)
const
;
112
virtual
void
Deserialize (
TagBuffer
i);
113
114
// these are our accessors to our tag structure
115
void
SetTimestamp (
Time
time);
116
Time
GetTimestamp (
void
)
const
;
117
118
void
Print
(std::ostream &os)
const
;
119
120
private
:
121
Time
m_timestamp
;
122
123
// end class TimestampTag
124
};
Receiver
Definition:
wifi-example-apps.h:73
Receiver::m_port
uint32_t m_port
Definition:
wifi-example-apps.h:93
Receiver::m_socket
Ptr< Socket > m_socket
Definition:
wifi-example-apps.h:91
Receiver::m_calc
Ptr< CounterCalculator<> > m_calc
Definition:
wifi-example-apps.h:95
Receiver::m_delay
Ptr< TimeMinMaxAvgTotalCalculator > m_delay
Definition:
wifi-example-apps.h:96
Sender
Definition:
wifi-example-apps.h:38
Sender::m_socket
Ptr< Socket > m_socket
Definition:
wifi-example-apps.h:59
Sender::m_count
uint32_t m_count
Definition:
wifi-example-apps.h:64
Sender::m_destPort
uint32_t m_destPort
Definition:
wifi-example-apps.h:55
Sender::m_interval
Ptr< ConstantRandomVariable > m_interval
Definition:
wifi-example-apps.h:56
Sender::m_destAddr
Ipv4Address m_destAddr
Definition:
wifi-example-apps.h:54
Sender::m_sendEvent
EventId m_sendEvent
Definition:
wifi-example-apps.h:60
Sender::m_numPkts
uint32_t m_numPkts
Definition:
wifi-example-apps.h:57
Sender::m_txTrace
TracedCallback< Ptr< const Packet > > m_txTrace
Definition:
wifi-example-apps.h:62
Sender::m_pktSize
uint32_t m_pktSize
Definition:
wifi-example-apps.h:53
TimestampTag
Definition:
wifi-example-apps.h:105
TimestampTag::m_timestamp
Time m_timestamp
Definition:
wifi-example-apps.h:121
ns3::Application
The base class for all ns3 applications.
Definition:
application.h:61
ns3::CounterCalculator
Template class CounterCalculator.
Definition:
basic-data-calculators.h:271
ns3::EventId
An identifier for simulation events.
Definition:
event-id.h:54
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:41
ns3::Ptr< ConstantRandomVariable >
ns3::TagBuffer
read and write tag data
Definition:
tag-buffer.h:52
ns3::Tag
tag a set of bytes in a packet
Definition:
tag.h:37
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:103
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition:
traced-callback.h:53
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
Print
void Print(ComponentCarrier cc)
Definition:
lena-cc-helper.cc:69
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:48
examples
stats
wifi-example-apps.h
Generated on Tue Feb 6 2024 19:21:14 for ns-3 by
1.9.1