A Discrete-Event Network Simulator
API
ns3::BsmApplication Class Reference

The BsmApplication class sends and receives the IEEE 1609 WAVE (Wireless Access in Vehicular Environments) Basic Safety Messages (BSMs) and uses the WaveBsmStats class to manage statistics about BSMs transmitted and received The BSM is a ~200-byte packet that is generally broadcast from every vehicle at a nominal rate of 10 Hz. More...

#include "bsm-application.h"

+ Inheritance diagram for ns3::BsmApplication:
+ Collaboration diagram for ns3::BsmApplication:

Public Member Functions

 BsmApplication ()
 Constructor. More...
 
virtual ~BsmApplication ()
 
int64_t AssignStreams (int64_t streamIndex)
 Assign a fixed random variable stream number to the random variables used by this model. More...
 
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. More...
 
- Public Member Functions inherited from ns3::Application
 Application ()
 
virtual ~Application ()
 
Ptr< NodeGetNode () const
 
void SetNode (Ptr< Node > node)
 
void SetStartTime (Time start)
 Specify application start time. More...
 
void SetStopTime (Time stop)
 Specify application stop time. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose (void)
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator (void) const
 Get an iterator to the Objects aggregated to this one. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Get the most derived TypeId for this Object. More...
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (void) const
 Get a pointer to the requested aggregated Object. More...
 
void Initialize (void)
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized (void) const
 Check if the object has been initialized. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= ([[maybe_unused]] const SimpleRefCount &o)
 Assignment operator. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising erros. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

Static Public Member Functions

static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Application
static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Static Public Attributes

static int wavePort = 9080
 (Arbitrary) port number that is used to create a socket for transmitting WAVE BSMs. More...
 

Protected Member Functions

virtual void DoDispose (void)
 Destructor implementation. More...
 
- Protected Member Functions inherited from ns3::Application
virtual void DoInitialize (void)
 Initialize() implementation. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void NotifyNewAggregate (void)
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted (void)
 Notifier called once the ObjectBase is fully constructed. More...
 

Private Member Functions

void GenerateWaveTraffic (Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval, uint32_t sendingNodeId)
 Creates and transmits a WAVE BSM packet. More...
 
Ptr< NetDeviceGetNetDevice (int id)
 Get the net device for the desired id. More...
 
Ptr< NodeGetNode (int id)
 Get the node for the desired id. More...
 
void HandleReceivedBsmPacket (Ptr< Node > txNode, Ptr< Node > rxNode)
 Handle the receipt of a WAVE BSM packet from sender to receiver. More...
 
void ReceiveWavePacket (Ptr< Socket > socket)
 Receive a WAVE BSM packet. More...
 
virtual void StartApplication (void)
 Called at time specified by Start. More...
 
virtual void StopApplication (void)
 Called at time specified by Stop. More...
 

Private Attributes

Ipv4InterfaceContainerm_adhocTxInterfaces
 transmit interfaces More...
 
int m_chAccessMode
 WAVE channel access mode. 0=continuous PHY; 1=channel-switching. More...
 
double m_gpsAccuracyNs
 GPS accuracy. More...
 
int m_nodeId
 node ID More...
 
std::vector< int > * m_nodesMoving
 nodes moving More...
 
uint32_t m_numWavePackets
 number of wave packets More...
 
Time m_prevTxDelay
 previous transmit delay More...
 
Time m_TotalSimTime
 total sim time More...
 
Time m_txMaxDelay
 When transmitting at a default rate of 10 Hz, the subsystem shall transmit every 100 ms +/- a random value between 0 and 5 ms. More...
 
std::vector< double > m_txSafetyRangesSq
 tx safety range squared, for optimization More...
 
Ptr< UniformRandomVariablem_unirv
 random variable More...
 
Ptr< WaveBsmStatsm_waveBsmStats
 BSM stats. More...
 
Time m_waveInterval
 wave interval More...
 
uint32_t m_wavePacketSize
 bytes More...
 

Additional Inherited Members

- Public Types inherited from ns3::Application
typedef void(* DelayAddressCallback) (const Time &delay, const Address &from)
 Common callback signature for packet delay and address. More...
 
typedef void(* StateTransitionCallback) (const std::string &oldState, const std::string &newState)
 Common signature used by callbacks to application's state transition trace source. More...
 
- Protected Attributes inherited from ns3::Application
Ptr< Nodem_node
 The node that this application is installed on. More...
 
EventId m_startEvent
 The event that will fire at m_startTime to start the application. More...
 
Time m_startTime
 The simulation time that the application will start. More...
 
EventId m_stopEvent
 The event that will fire at m_stopTime to end the application. More...
 
Time m_stopTime
 The simulation time that the application will end. More...
 

Detailed Description

The BsmApplication class sends and receives the IEEE 1609 WAVE (Wireless Access in Vehicular Environments) Basic Safety Messages (BSMs) and uses the WaveBsmStats class to manage statistics about BSMs transmitted and received The BSM is a ~200-byte packet that is generally broadcast from every vehicle at a nominal rate of 10 Hz.

Config Paths

ns3::BsmApplication is accessible through the following paths with Config::Set and Config::Connect:

  • "/NodeList/[i]/ApplicationList/[i]/$ns3::BsmApplication"

No Attributes are defined for this type.

Attributes defined in parent class ns3::Application

  • StartTime: Time at which the application will start
    • Set with class: ns3::TimeValue
    • Underlying type: Time +9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: construct write read
  • StopTime: Time at which the application will stop
    • Set with class: ns3::TimeValue
    • Underlying type: Time +9.22337e+18ns:+9.22337e+18ns
    • Initial value: +0ns
    • Flags: construct write read

No TraceSources are defined for this type.
Size of this type is 216 bytes (on a 64-bit architecture).

Definition at line 40 of file bsm-application.h.

Constructor & Destructor Documentation

◆ BsmApplication()

ns3::BsmApplication::BsmApplication ( )

Constructor.

Definition at line 50 of file bsm-application.cc.

References NS_LOG_FUNCTION.

◆ ~BsmApplication()

ns3::BsmApplication::~BsmApplication ( )
virtual

Definition at line 69 of file bsm-application.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ AssignStreams()

int64_t ns3::BsmApplication::AssignStreams ( int64_t  streamIndex)

Assign a fixed random variable stream number to the random variables used by this model.

Return the number of streams (possibly zero) that have been assigned. The Install() method should have previously been called by the user.

Parameters
streamIndexfirst stream index to use
Returns
the number of stream indices assigned by this helper

Definition at line 376 of file bsm-application.cc.

References m_unirv, NS_ASSERT, NS_LOG_FUNCTION, and ns3::RandomVariableStream::SetStream().

+ Here is the call graph for this function:

◆ DoDispose()

void ns3::BsmApplication::DoDispose ( void  )
protectedvirtual

Destructor implementation.

This method is called by Dispose() or by the Object's destructor, whichever comes first.

Subclasses are expected to implement their real destruction code in an overridden version of this method and chain up to their parent's implementation once they are done. i.e, for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose() method.

It is safe to call GetObject() from within this method.

Reimplemented from ns3::Application.

Definition at line 75 of file bsm-application.cc.

References ns3::Application::DoDispose(), and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ GenerateWaveTraffic()

void ns3::BsmApplication::GenerateWaveTraffic ( Ptr< Socket socket,
uint32_t  pktSize,
uint32_t  pktCount,
Time  pktInterval,
uint32_t  sendingNodeId 
)
private

Creates and transmits a WAVE BSM packet.

Parameters
socketsocket to use for transmission
pktSizethe size, in bytes, of the WAVE BSM packet
pktCountthe number of remaining WAVE BSM packets to be transmitted
pktIntervalthe interval, in seconds, until the next packet should be transmitted
sendingNodeId

Definition at line 223 of file bsm-application.cc.

References ns3::Socket::Close(), ns3::MobilityHelper::GetDistanceSquaredBetween(), ns3::Node::GetId(), ns3::UniformRandomVariable::GetInteger(), ns3::Time::GetInteger(), ns3::Ipv4InterfaceContainer::GetN(), ns3::Application::GetNode(), ns3::Socket::GetNode(), ns3::Object::GetObject(), m_adhocTxInterfaces, m_nodesMoving, m_prevTxDelay, m_txMaxDelay, m_txSafetyRangesSq, m_unirv, m_waveBsmStats, ns3::NanoSeconds(), NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_UNCOND, pktSize, ns3::Simulator::ScheduleWithContext(), and ns3::Socket::Send().

Referenced by StartApplication().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNetDevice()

Ptr< NetDevice > ns3::BsmApplication::GetNetDevice ( int  id)
private

Get the net device for the desired id.

Parameters
idthe id of the desired net device
Returns
ptr to the desired net device

Definition at line 399 of file bsm-application.cc.

References ns3::Object::GetObject(), m_adhocTxInterfaces, and NS_LOG_FUNCTION.

Referenced by StartApplication().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetNode()

Ptr< Node > ns3::BsmApplication::GetNode ( int  id)
private

Get the node for the desired id.

Parameters
idthe id of the desired node
Returns
ptr to the desired node

Definition at line 387 of file bsm-application.cc.

References ns3::Object::GetObject(), m_adhocTxInterfaces, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ GetTypeId()

TypeId ns3::BsmApplication::GetTypeId ( void  )
static

Get the type ID.

Returns
the object TypeId

Definition at line 40 of file bsm-application.cc.

References ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ HandleReceivedBsmPacket()

void ns3::BsmApplication::HandleReceivedBsmPacket ( Ptr< Node txNode,
Ptr< Node rxNode 
)
private

Handle the receipt of a WAVE BSM packet from sender to receiver.

Parameters
txNodethe sending node
rxNodethe receiving node

Definition at line 343 of file bsm-application.cc.

References ns3::MobilityHelper::GetDistanceSquaredBetween(), ns3::Node::GetId(), ns3::Object::GetObject(), m_nodesMoving, m_txSafetyRangesSq, m_waveBsmStats, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by ReceiveWavePacket().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ReceiveWavePacket()

void ns3::BsmApplication::ReceiveWavePacket ( Ptr< Socket socket)
private

◆ Setup()

void ns3::BsmApplication::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.

Parameters
iIPv4 interface container
nodeIdidentifier of the node (index into container)
totalTimetotal amount of time that BSM packets should be transmitted
wavePacketSizethe size, in bytes, of a WAVE BSM
waveIntervalthe time, in seconds, between each WAVE BSM transmission, typically 10 Hz (0.1 second)
gpsAccuracyNsthe timing synchronization accuracy of GPS time, in nanoseconds. GPS time-sync is ~40-100 ns. Universally synchronized time among all vehicles will result in all vehicles transmitting safety messages simultaneously, leading to excessive wireless collisions.
rangesSqthe expected transmission range, in m ^ 2.
waveBsmStatsclass for WAVE BSM statistics
nodesMovingof whether or not node(s) are moving
mode
txDelay

Definition at line 184 of file bsm-application.cc.

References m_adhocTxInterfaces, m_chAccessMode, m_gpsAccuracyNs, m_nodeId, m_nodesMoving, m_TotalSimTime, m_txMaxDelay, m_txSafetyRangesSq, m_unirv, m_waveBsmStats, m_waveInterval, m_wavePacketSize, and NS_LOG_FUNCTION.

◆ StartApplication()

◆ StopApplication()

void ns3::BsmApplication::StopApplication ( void  )
privatevirtual

Called at time specified by Stop.

Reimplemented from ns3::Application.

Definition at line 178 of file bsm-application.cc.

References NS_LOG_FUNCTION.

Member Data Documentation

◆ m_adhocTxInterfaces

Ipv4InterfaceContainer* ns3::BsmApplication::m_adhocTxInterfaces
private

transmit interfaces

Definition at line 158 of file bsm-application.h.

Referenced by GenerateWaveTraffic(), GetNetDevice(), GetNode(), ReceiveWavePacket(), and Setup().

◆ m_chAccessMode

int ns3::BsmApplication::m_chAccessMode
private

WAVE channel access mode. 0=continuous PHY; 1=channel-switching.

Definition at line 163 of file bsm-application.h.

Referenced by Setup().

◆ m_gpsAccuracyNs

double ns3::BsmApplication::m_gpsAccuracyNs
private

GPS accuracy.

Definition at line 157 of file bsm-application.h.

Referenced by Setup(), and StartApplication().

◆ m_nodeId

int ns3::BsmApplication::m_nodeId
private

node ID

Definition at line 161 of file bsm-application.h.

Referenced by Setup(), and StartApplication().

◆ m_nodesMoving

std::vector<int>* ns3::BsmApplication::m_nodesMoving
private

nodes moving

Definition at line 159 of file bsm-application.h.

Referenced by GenerateWaveTraffic(), HandleReceivedBsmPacket(), and Setup().

◆ m_numWavePackets

uint32_t ns3::BsmApplication::m_numWavePackets
private

number of wave packets

Definition at line 155 of file bsm-application.h.

Referenced by StartApplication().

◆ m_prevTxDelay

Time ns3::BsmApplication::m_prevTxDelay
private

previous transmit delay

Definition at line 173 of file bsm-application.h.

Referenced by GenerateWaveTraffic(), and StartApplication().

◆ m_TotalSimTime

Time ns3::BsmApplication::m_TotalSimTime
private

total sim time

Definition at line 153 of file bsm-application.h.

Referenced by Setup(), and StartApplication().

◆ m_txMaxDelay

Time ns3::BsmApplication::m_txMaxDelay
private

When transmitting at a default rate of 10 Hz, the subsystem shall transmit every 100 ms +/- a random value between 0 and 5 ms.

[MPR-BSMTX-TXTIM-002] Source: CAMP Vehicle Safety Communications 4 Consortium On-board Minimum Performance Requirements for V2V Safety Systems Version 1.0, December 17, 2014 max transmit delay (default 10ms)

Definition at line 172 of file bsm-application.h.

Referenced by GenerateWaveTraffic(), Setup(), and StartApplication().

◆ m_txSafetyRangesSq

std::vector<double> ns3::BsmApplication::m_txSafetyRangesSq
private

tx safety range squared, for optimization

Definition at line 152 of file bsm-application.h.

Referenced by GenerateWaveTraffic(), HandleReceivedBsmPacket(), and Setup().

◆ m_unirv

Ptr<UniformRandomVariable> ns3::BsmApplication::m_unirv
private

random variable

Definition at line 160 of file bsm-application.h.

Referenced by AssignStreams(), GenerateWaveTraffic(), Setup(), and StartApplication().

◆ m_waveBsmStats

Ptr<WaveBsmStats> ns3::BsmApplication::m_waveBsmStats
private

BSM stats.

Definition at line 150 of file bsm-application.h.

Referenced by GenerateWaveTraffic(), HandleReceivedBsmPacket(), and Setup().

◆ m_waveInterval

Time ns3::BsmApplication::m_waveInterval
private

wave interval

Definition at line 156 of file bsm-application.h.

Referenced by Setup(), and StartApplication().

◆ m_wavePacketSize

uint32_t ns3::BsmApplication::m_wavePacketSize
private

bytes

Definition at line 154 of file bsm-application.h.

Referenced by Setup(), and StartApplication().

◆ wavePort

int ns3::BsmApplication::wavePort = 9080
static

(Arbitrary) port number that is used to create a socket for transmitting WAVE BSMs.

Definition at line 99 of file bsm-application.h.

Referenced by StartApplication().


The documentation for this class was generated from the following files: