A Discrete-Event Network Simulator
API
bsm-application.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 North Carolina State University
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Scott E. Carpenter <scarpen@ncsu.edu>
18  *
19  */
20 
21 #ifndef BSM_APPLICATION_H
22 #define BSM_APPLICATION_H
23 
24 #include "ns3/application.h"
25 #include "ns3/internet-stack-helper.h"
26 #include "ns3/random-variable-stream.h"
27 #include "ns3/wave-bsm-stats.h"
28 
29 namespace ns3
30 {
41 {
42  public:
47  static TypeId GetTypeId();
48 
53  ~BsmApplication() override;
54 
74  int nodeId,
75  Time totalTime,
76  uint32_t wavePacketSize, // bytes
77  Time waveInterval,
78  double gpsAccuracyNs,
79  std::vector<double> rangesSq, // m ^ 2
80  Ptr<WaveBsmStats> waveBsmStats,
81  std::vector<int>* nodesMoving,
82  int mode,
83  Time txDelay);
84 
94  int64_t AssignStreams(int64_t streamIndex);
95 
99  static int wavePort;
100 
101  protected:
102  void DoDispose() override;
103 
104  private:
105  // inherited from Application base class.
106  void StartApplication() override;
107  void StopApplication() override;
108 
118  void GenerateWaveTraffic(Ptr<Socket> socket,
119  uint32_t pktSize,
120  uint32_t pktCount,
121  Time pktInterval,
122  uint32_t sendingNodeId);
123 
128  void ReceiveWavePacket(Ptr<Socket> socket);
129 
135  void HandleReceivedBsmPacket(Ptr<Node> txNode, Ptr<Node> rxNode);
136 
142  Ptr<Node> GetNode(int id);
143 
150 
153  std::vector<double> m_txSafetyRangesSq;
155  uint32_t m_wavePacketSize;
156  uint32_t m_numWavePackets;
160  std::vector<int>* m_nodesMoving;
162  int m_nodeId;
175 };
176 
177 } // namespace ns3
178 
179 #endif /* BSM_APPLICATION_H*/
The base class for all ns3 applications.
Definition: application.h:61
Ptr< Node > GetNode() const
Definition: application.cc:107
The BsmApplication class sends and receives the IEEE 1609 WAVE (Wireless Access in Vehicular Environm...
uint32_t m_wavePacketSize
bytes
Ptr< NetDevice > GetNetDevice(int id)
Get the net device for the desired id.
Ipv4InterfaceContainer * m_adhocTxInterfaces
transmit interfaces
Time m_TotalSimTime
total sim time
int64_t AssignStreams(int64_t streamIndex)
Assign a fixed random variable stream number to the random variables used by this model.
void GenerateWaveTraffic(Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval, uint32_t sendingNodeId)
Creates and transmits a WAVE BSM packet.
std::vector< double > m_txSafetyRangesSq
tx safety range squared, for optimization
Time m_txMaxDelay
When transmitting at a default rate of 10 Hz, the subsystem shall transmit every 100 ms +/- a random ...
uint32_t m_numWavePackets
number of wave packets
double m_gpsAccuracyNs
GPS accuracy.
void ReceiveWavePacket(Ptr< Socket > socket)
Receive a WAVE BSM packet.
std::vector< int > * m_nodesMoving
nodes moving
int m_chAccessMode
WAVE channel access mode. 0=continuous PHY; 1=channel-switching.
~BsmApplication() override
Ptr< UniformRandomVariable > m_unirv
random variable
static int wavePort
(Arbitrary) port number that is used to create a socket for transmitting WAVE BSMs.
Time m_waveInterval
wave interval
void Setup(Ipv4InterfaceContainer &i, int nodeId, Time totalTime, uint32_t wavePacketSize, Time waveInterval, double gpsAccuracyNs, std::vector< double > rangesSq, Ptr< WaveBsmStats > waveBsmStats, std::vector< int > *nodesMoving, int mode, Time txDelay)
Setup BSM generation parameters for a node.
Time m_prevTxDelay
previous transmit delay
static TypeId GetTypeId()
Get the type ID.
BsmApplication()
Constructor.
void HandleReceivedBsmPacket(Ptr< Node > txNode, Ptr< Node > rxNode)
Handle the receipt of a WAVE BSM packet from sender to receiver.
void StartApplication() override
Called at time specified by Start.
void StopApplication() override
Called at time specified by Stop.
void DoDispose() override
Destructor implementation.
Ptr< WaveBsmStats > m_waveBsmStats
BSM stats.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:60
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t pktSize
packet size used for the simulation (in bytes)