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"
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< Node > | GetNode () 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< Object > | GetObject () 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< Object > | GetObject (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... | |
SimpleRefCount & | operator= ([[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< NetDevice > | GetNetDevice (int id) |
Get the net device for the desired id. More... | |
Ptr< Node > | GetNode (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 | |
Ipv4InterfaceContainer * | m_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< UniformRandomVariable > | m_unirv |
random variable More... | |
Ptr< WaveBsmStats > | m_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< Node > | m_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... | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid (void) |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. More... | |
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.
ns3::BsmApplication is accessible through the following paths with Config::Set and Config::Connect:
No Attributes are defined for this type.
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.
ns3::BsmApplication::BsmApplication | ( | ) |
|
virtual |
Definition at line 69 of file bsm-application.cc.
References NS_LOG_FUNCTION.
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.
streamIndex | first stream index to use |
Definition at line 376 of file bsm-application.cc.
References m_unirv, NS_ASSERT, NS_LOG_FUNCTION, and ns3::RandomVariableStream::SetStream().
|
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.
|
private |
Creates and transmits a WAVE BSM packet.
socket | socket to use for transmission |
pktSize | the size, in bytes, of the WAVE BSM packet |
pktCount | the number of remaining WAVE BSM packets to be transmitted |
pktInterval | the 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().
Get the net device for the desired id.
id | the id of 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().
Get the node for the desired id.
id | the id of the desired node |
Definition at line 387 of file bsm-application.cc.
References ns3::Object::GetObject(), m_adhocTxInterfaces, and NS_LOG_FUNCTION.
|
static |
Get the type ID.
Definition at line 40 of file bsm-application.cc.
References ns3::TypeId::SetParent().
|
private |
Handle the receipt of a WAVE BSM packet from sender to receiver.
txNode | the sending node |
rxNode | the 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().
Receive a WAVE BSM packet.
socket | the receiving socket |
Definition at line 317 of file bsm-application.cc.
References ns3::InetSocketAddress::ConvertFrom(), ns3::Ipv4InterfaceContainer::GetAddress(), ns3::InetSocketAddress::GetIpv4(), ns3::Ipv4InterfaceContainer::GetN(), ns3::Application::GetNode(), ns3::Socket::GetNode(), HandleReceivedBsmPacket(), ns3::InetSocketAddress::IsMatchingType(), m_adhocTxInterfaces, first::nodes, NS_LOG_FUNCTION, and ns3::Socket::RecvFrom().
Referenced by StartApplication().
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.
i | IPv4 interface container |
nodeId | identifier of the node (index into container) |
totalTime | total amount of time that BSM packets should be transmitted |
wavePacketSize | the size, in bytes, of a WAVE BSM |
waveInterval | the time, in seconds, between each WAVE BSM transmission, typically 10 Hz (0.1 second) |
gpsAccuracyNs | the 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. |
rangesSq | the expected transmission range, in m ^ 2. |
waveBsmStats | class for WAVE BSM statistics |
nodesMoving | of 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.
|
privatevirtual |
Called at time specified by Start.
Reimplemented from ns3::Application.
Definition at line 84 of file bsm-application.cc.
References ns3::Socket::Bind(), ns3::Socket::BindToNetDevice(), ns3::Socket::Connect(), ns3::Socket::CreateSocket(), GenerateWaveTraffic(), ns3::Ipv4Address::GetAny(), ns3::Time::GetDouble(), ns3::Node::GetId(), ns3::UniformRandomVariable::GetInteger(), ns3::Time::GetInteger(), GetNetDevice(), ns3::Application::GetNode(), ns3::Socket::GetNode(), ns3::TypeId::LookupByName(), m_gpsAccuracyNs, m_nodeId, m_numWavePackets, m_prevTxDelay, m_TotalSimTime, m_txMaxDelay, m_unirv, m_waveInterval, m_wavePacketSize, ns3::MakeCallback(), ns3::NanoSeconds(), NS_LOG_FUNCTION, ReceiveWavePacket(), ns3::Simulator::ScheduleWithContext(), ns3::Seconds(), ns3::Socket::SetAllowBroadcast(), ns3::Socket::SetRecvCallback(), startTime, and wavePort.
|
privatevirtual |
Called at time specified by Stop.
Reimplemented from ns3::Application.
Definition at line 178 of file bsm-application.cc.
References NS_LOG_FUNCTION.
|
private |
transmit interfaces
Definition at line 158 of file bsm-application.h.
Referenced by GenerateWaveTraffic(), GetNetDevice(), GetNode(), ReceiveWavePacket(), and Setup().
|
private |
WAVE channel access mode. 0=continuous PHY; 1=channel-switching.
Definition at line 163 of file bsm-application.h.
Referenced by Setup().
|
private |
GPS accuracy.
Definition at line 157 of file bsm-application.h.
Referenced by Setup(), and StartApplication().
|
private |
node ID
Definition at line 161 of file bsm-application.h.
Referenced by Setup(), and StartApplication().
|
private |
nodes moving
Definition at line 159 of file bsm-application.h.
Referenced by GenerateWaveTraffic(), HandleReceivedBsmPacket(), and Setup().
|
private |
number of wave packets
Definition at line 155 of file bsm-application.h.
Referenced by StartApplication().
|
private |
previous transmit delay
Definition at line 173 of file bsm-application.h.
Referenced by GenerateWaveTraffic(), and StartApplication().
|
private |
total sim time
Definition at line 153 of file bsm-application.h.
Referenced by Setup(), and StartApplication().
|
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().
|
private |
tx safety range squared, for optimization
Definition at line 152 of file bsm-application.h.
Referenced by GenerateWaveTraffic(), HandleReceivedBsmPacket(), and Setup().
|
private |
random variable
Definition at line 160 of file bsm-application.h.
Referenced by AssignStreams(), GenerateWaveTraffic(), Setup(), and StartApplication().
|
private |
BSM stats.
Definition at line 150 of file bsm-application.h.
Referenced by GenerateWaveTraffic(), HandleReceivedBsmPacket(), and Setup().
|
private |
wave interval
Definition at line 156 of file bsm-application.h.
Referenced by Setup(), and StartApplication().
|
private |
bytes
Definition at line 154 of file bsm-application.h.
Referenced by Setup(), and StartApplication().
|
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().