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 
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;
55  uint32_t m_destPort;
57  uint32_t m_numPkts;
58 
61 
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 
92 
93  uint32_t m_port;
94 
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:
122 
123  // end class TimestampTag
124 };
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
EventId m_sendEvent
Ipv4Address m_destAddr
Forward calls to a chain of Callback.
uint32_t m_numPkts
The base class for all ns3 applications.
Definition: application.h:60
Ptr< ConstantRandomVariable > m_interval
uint32_t m_destPort
uint32_t m_pktSize
uint32_t m_count
tag a set of bytes in a packet
Definition: tag.h:36
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< Socket > m_socket
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...
uint32_t m_port
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
read and write tag data
Definition: tag-buffer.h:51
An identifier for simulation events.
Definition: event-id.h:53
void Print(ComponentCarrier cc)
TracedCallback< Ptr< const Packet > > m_txTrace
Ptr< TimeMinMaxAvgTotalCalculator > m_delay
a unique identifier for an interface.
Definition: type-id.h:58
Ptr< Socket > m_socket
Ptr< CounterCalculator<> > m_calc