A Discrete-Event Network Simulator
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
34using namespace ns3;
35
39class Sender : public Application {
40public:
45 static TypeId GetTypeId (void);
46 Sender();
47 virtual ~Sender();
48
49protected:
50 virtual void DoDispose (void);
51
52private:
53 virtual void StartApplication (void);
54 virtual void StopApplication (void);
55
59 void SendPacket ();
60
66
69
72
74
75 // end class Sender
76};
77
78
82class Receiver : public Application {
83public:
88 static TypeId GetTypeId (void);
89 Receiver();
90 virtual ~Receiver();
91
97
103
104protected:
105 virtual void DoDispose (void);
106
107private:
108 virtual void StartApplication (void);
109 virtual void StopApplication (void);
110
115 void Receive (Ptr<Socket> socket);
116
119
122
123 // end class Receiver
124};
125
126
134class TimestampTag : public Tag {
135public:
140 static TypeId GetTypeId (void);
141 virtual TypeId GetInstanceTypeId (void) const;
142
143 virtual uint32_t GetSerializedSize (void) const;
144 virtual void Serialize (TagBuffer i) const;
145 virtual void Deserialize (TagBuffer i);
146
151 void SetTimestamp (Time time);
156 Time GetTimestamp (void) const;
157
158 void Print (std::ostream &os) const;
159
160private:
162
163 // end class TimestampTag
164};
Receiver application.
uint32_t m_port
Listening port.
virtual void StopApplication(void)
Application specific shutdown code.
virtual ~Receiver()
Ptr< Socket > m_socket
Receiving socket.
void SetDelayTracker(Ptr< TimeMinMaxAvgTotalCalculator > delay)
Set the delay tracker for received packets.
void Receive(Ptr< Socket > socket)
Receive a packet.
virtual void StartApplication(void)
Application specific startup code.
static TypeId GetTypeId(void)
Get the type ID.
Ptr< CounterCalculator<> > m_calc
Counter of the number of received packets.
void SetCounter(Ptr< CounterCalculator<> > calc)
Set the counter calculator for received packets.
Ptr< TimeMinMaxAvgTotalCalculator > m_delay
Delay calculator.
virtual void DoDispose(void)
Destructor implementation.
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.
static TypeId GetTypeId(void)
Get the type ID.
Ipv4Address m_destAddr
Destination address.
virtual void StartApplication(void)
Application specific startup code.
EventId m_sendEvent
Send packet event.
uint32_t m_numPkts
Number of packets to send.
virtual ~Sender()
virtual void DoDispose(void)
Destructor implementation.
TracedCallback< Ptr< const Packet > > m_txTrace
Tx TracedCallback.
uint32_t m_pktSize
The packet size.
virtual void StopApplication(void)
Application specific shutdown code.
Timestamp tag - it carries when the packet has been sent.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void Print(std::ostream &os) const
static TypeId GetTypeId(void)
Get the type ID.
void SetTimestamp(Time time)
Set the timestamp.
virtual void Serialize(TagBuffer i) const
virtual uint32_t GetSerializedSize(void) const
virtual void Deserialize(TagBuffer i)
Time GetTimestamp(void) const
Get the timestamp.
Time m_timestamp
Timestamp.
The base class for all ns3 applications.
Definition: application.h:61
Template class CounterCalculator.
An identifier for simulation events.
Definition: event-id.h:54
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
read and write tag data
Definition: tag-buffer.h:52
tag a set of bytes in a packet
Definition: tag.h:37
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
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.