A Discrete-Event Network Simulator
API
bsm-application.h
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 North Carolina State University
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Scott E. Carpenter <scarpen@ncsu.edu>
19  *
20  */
21 
22 #ifndef BSM_APPLICATION_H
23 #define BSM_APPLICATION_H
24 
25 #include "ns3/application.h"
26 #include "ns3/wave-bsm-stats.h"
27 #include "ns3/random-variable-stream.h"
28 #include "ns3/internet-stack-helper.h"
29 
30 namespace ns3 {
41 {
42 public:
43  static TypeId GetTypeId (void);
44 
49  BsmApplication ();
50  virtual ~BsmApplication ();
51 
69  void Setup (Ipv4InterfaceContainer & i,
70  int nodeId,
71  Time totalTime,
72  uint32_t wavePacketSize, // bytes
73  Time waveInterval,
74  double gpsAccuracyNs,
75  std::vector <double> rangesSq, // m ^ 2
76  Ptr<WaveBsmStats> waveBsmStats,
77  std::vector<int> * nodesMoving,
78  int mode,
79  Time txDelay);
80 
90  int64_t AssignStreams (int64_t streamIndex);
91 
95  static int wavePort;
96 
97 protected:
98  virtual void DoDispose (void);
99 
100 private:
101  // inherited from Application base class.
102  virtual void StartApplication (void); // Called at time specified by Start
103  virtual void StopApplication (void); // Called at time specified by Stop
104 
114  void GenerateWaveTraffic (Ptr<Socket> socket, uint32_t pktSize,
115  uint32_t pktCount, Time pktInterval,
116  uint32_t sendingNodeId);
117 
123  void ReceiveWavePacket (Ptr<Socket> socket);
124 
131  void HandleReceivedBsmPacket (Ptr<Node> txNode,
132  Ptr<Node> rxNode);
133 
139  Ptr<Node> GetNode (int id);
140 
146  Ptr<NetDevice> GetNetDevice (int id);
147 
149  // tx safety range squared, for optimization
150  std::vector <double> m_txSafetyRangesSq;
152  uint32_t m_wavePacketSize; // bytes
157  std::vector<int> * m_nodesMoving;
159  int m_nodeId;
160  // WAVE channel access mode. 0=continuous PHY; 1=channel-switching
162  // When transmitting at a default rate of 10 Hz,
163  // the subsystem shall transmit every 100 ms +/-
164  // a random value between 0 and 5 ms. [MPR-BSMTX-TXTIM-002]
165  // Source: CAMP Vehicle Safety Communications 4 Consortium
166  // On-board Minimum Performance Requirements
167  // for V2V Safety Systems Version 1.0, December 17, 2014
168  // max transmit delay (default 10ms)
171 };
172 
173 } // namespace ns3
174 
175 #endif /* BSM_APPLICATION_H*/
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
Ipv4InterfaceContainer * m_adhocTxInterfaces
holds a vector of std::pair of Ptr and interface index.
Ptr< UniformRandomVariable > m_unirv
int64_t AssignStreams(int64_t streamIndex)
Assign a fixed random variable stream number to the random variables used by this model...
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.
BsmApplication()
Constructor.
std::vector< double > m_txSafetyRangesSq
virtual void StartApplication(void)
Application specific startup code.
virtual void DoDispose(void)
Destructor implementation.
The base class for all ns3 applications.
Definition: application.h:60
virtual void StopApplication(void)
Application specific shutdown code.
Ptr< Node > GetNode() const
Definition: application.cc:104
The BsmApplication class sends and receives the IEEE 1609 WAVE (Wireless Access in Vehicular Environm...
void GenerateWaveTraffic(Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval, uint32_t sendingNodeId)
Creates and transmits a WAVE BSM packet.
Ptr< WaveBsmStats > m_waveBsmStats
void HandleReceivedBsmPacket(Ptr< Node > txNode, Ptr< Node > rxNode)
Handle the receipt of a WAVE BSM packet from sender to receiver.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< NetDevice > GetNetDevice(int id)
Get the net device for the desired id.
static int wavePort
(Arbitrary) port number that is used to create a socket for transmitting WAVE BSMs.
std::vector< int > * m_nodesMoving
void ReceiveWavePacket(Ptr< Socket > socket)
Receive a WAVE BSM packet.
static TypeId GetTypeId(void)
a unique identifier for an interface.
Definition: type-id.h:58