21 #include "ns3/bsm-application.h"
24 #include "ns3/mobility-helper.h"
25 #include "ns3/mobility-model.h"
26 #include "ns3/wave-helper.h"
27 #include "ns3/wave-mac-helper.h"
28 #include "ns3/wave-net-device.h"
51 : m_waveBsmStats(nullptr),
54 m_wavePacketSize(200),
57 m_gpsAccuracyNs(10000),
58 m_adhocTxInterfaces(nullptr),
59 m_nodesMoving(nullptr),
106 recvSink->
Bind(local);
172 Time txTime = startTime + tDrift + txDelay;
181 waveInterPacketInterval,
195 uint32_t wavePacketSize,
197 double gpsAccuracyNs,
198 std::vector<double> rangesSq,
200 std::vector<int>* nodesMoving,
206 m_unirv = CreateObject<UniformRandomVariable>();
212 int size = rangesSq.size();
219 for (
int index = 0; index < size; index++)
235 uint32_t sendingNodeId)
246 int txNodeId = sendingNodeId;
252 if (senderMoving != 0)
260 if ((
m_waveBsmStats->GetLogging() != 0) && ((wavePktsSent % 1000) == 0))
268 for (
int i = 0; i < nRxNodes; i++)
271 int rxNodeId = rxNode->
GetId();
273 if (rxNodeId != txNodeId)
282 if (receiverMoving == 1)
289 for (
int index = 1; index <= rangeCount; index++)
340 while ((packet = socket->
RecvFrom(senderAddr)))
348 for (
int i = 0; i <
nodes; i++)
373 int rxNodeId = rxNode->
GetId();
375 if (receiverMoving == 1)
381 for (
int index = 1; index <= rangeCount; index++)
a polymophic address class
The base class for all ns3 applications.
void DoDispose() override
Destructor implementation.
Ptr< Node > GetNode() const
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.
static bool IsMatchingType(const Address &address)
Ipv4Address GetIpv4() const
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny()
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
static double GetDistanceSquaredBetween(Ptr< Node > n1, Ptr< Node > n2)
Keep track of the current position and velocity of an object.
Network layer to device interface.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
void SetRecvCallback(Callback< void, Ptr< Socket >> receivedData)
Notify application when new data is available to be read.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual Ptr< Node > GetNode() const =0
Return the node this socket is associated with.
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
virtual int Close()=0
Close a socket.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
Simulation virtual time values and global simulation resolution.
int64_t GetInteger() const
Get the raw time value, in the current resolution unit.
double GetDouble() const
Get the raw time value, in the current resolution unit.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
uint32_t pktSize
packet size used for the simulation (in bytes)