22 #include "ns3/bsm-application.h"
24 #include "ns3/wave-net-device.h"
25 #include "ns3/wave-mac-helper.h"
26 #include "ns3/wave-helper.h"
27 #include "ns3/mobility-model.h"
28 #include "ns3/mobility-helper.h"
44 .SetGroupName (
"Wave")
52 m_txSafetyRangesSq (),
54 m_wavePacketSize (200),
57 m_gpsAccuracyNs (10000),
58 m_adhocTxInterfaces (0),
105 recvSink->
Bind (local);
187 uint32_t wavePacketSize,
189 double gpsAccuracyNs,
190 std::vector <double> rangesSq,
192 std::vector<int> * nodesMoving,
198 m_unirv = CreateObject<UniformRandomVariable> ();
204 int size = rangesSq.size ();
211 for (
int index = 0; index < size; index++)
224 uint32_t pktCount,
Time pktInterval,
225 uint32_t sendingNodeId)
236 int txNodeId = sendingNodeId;
242 if (senderMoving != 0)
250 if ((
m_waveBsmStats->GetLogging () != 0) && ((wavePktsSent % 1000) == 0))
258 for (
int i = 0; i < nRxNodes; i++)
261 int rxNodeId = rxNode->
GetId ();
263 if (rxNodeId != txNodeId)
272 if (receiverMoving == 1)
279 for (
int index = 1; index <= rangeCount; index++)
323 while ((packet = socket->
RecvFrom (senderAddr)))
331 for (
int i = 0; i <
nodes; i++)
356 int rxNodeId = rxNode->
GetId ();
358 if (receiverMoving == 1)
364 for (
int index = 1; index <= rangeCount; index++)
a polymophic address class
The base class for all ns3 applications.
virtual void DoDispose(void)
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.
virtual void StartApplication(void)
Called at time specified by Start.
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
static TypeId GetTypeId(void)
Get the type ID.
virtual void StopApplication(void)
Called at time specified by Stop.
int m_chAccessMode
WAVE channel access mode. 0=continuous PHY; 1=channel-switching.
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
BsmApplication()
Constructor.
virtual void DoDispose(void)
Destructor implementation.
void HandleReceivedBsmPacket(Ptr< Node > txNode, Ptr< Node > rxNode)
Handle the receipt of a WAVE BSM packet from sender to receiver.
virtual ~BsmApplication()
Ptr< WaveBsmStats > m_waveBsmStats
BSM stats.
Ipv4Address GetIpv4(void) const
static bool IsMatchingType(const Address &address)
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(void)
holds a vector of std::pair of Ptr<Ipv4> and interface index.
uint32_t GetN(void) const
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.
uint32_t GetId(void) const
Ptr< T > GetObject(void) 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, Time const &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.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
virtual int Close(void)=0
Close a socket.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
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 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.
double GetDouble(void) const
Get the raw time value, in the current resolution unit.
int64_t GetInteger(void) 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, Ts... > MakeCallback(R(T::*memPtr)(Ts...), 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)