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)
245 socket->
Send (Create<Packet> (pktSize));
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++)
309 socket, pktSize, pktCount - 1, pktInterval, socket->GetNode ()->GetId ());
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++)
Simulation virtual time values and global simulation resolution.
static Ipv4Address GetAny(void)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Ipv4InterfaceContainer * m_adhocTxInterfaces
transmit interfaces
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
uint32_t GetId(void) const
holds a vector of std::pair of Ptr<Ipv4> and interface index.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
int64_t GetInteger(void) const
Get the raw time value, in the current resolution unit.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
static double GetDistanceSquaredBetween(Ptr< Node > n1, Ptr< Node > n2)
Ptr< UniformRandomVariable > m_unirv
random variable
uint32_t m_wavePacketSize
bytes
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.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
std::vector< double > m_txSafetyRangesSq
tx safety range squared, for optimization
Time m_waveInterval
wave interval
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
virtual void StartApplication(void)
Called at time specified by Start.
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
Time m_prevTxDelay
previous transmit delay
a polymophic address class
Keep track of the current position and velocity of an object.
virtual void DoDispose(void)
Destructor implementation.
virtual uint32_t GetInteger(void)=0
Get the next random value as an integer drawn from the distribution.
virtual ~BsmApplication()
double m_gpsAccuracyNs
GPS accuracy.
The base class for all ns3 applications.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
virtual void StopApplication(void)
Called at time specified by Stop.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
The BsmApplication class sends and receives the IEEE 1609 WAVE (Wireless Access in Vehicular Environm...
double GetDouble(void) const
Get the raw time value, in the current resolution unit.
void SetRecvCallback(Callback< void, Ptr< Socket > >)
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...
uint32_t GetN(void) const
void GenerateWaveTraffic(Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval, uint32_t sendingNodeId)
Creates and transmits a WAVE BSM packet.
Ptr< Node > GetNode() const
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
virtual void DoDispose(void)
Destructor implementation.
Ptr< WaveBsmStats > m_waveBsmStats
BSM stats.
void HandleReceivedBsmPacket(Ptr< Node > txNode, Ptr< Node > rxNode)
Handle the receipt of a WAVE BSM packet from sender to receiver.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Ptr< NetDevice > GetNetDevice(int id)
Get the net device for the desired id.
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
static int wavePort
(Arbitrary) port number that is used to create a socket for transmitting WAVE BSMs.
static void ScheduleWithContext(uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
Ipv4 addresses are stored in host order in this class.
Time m_TotalSimTime
total sim time
Network layer to device interface.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
std::vector< int > * m_nodesMoving
nodes moving
Time Seconds(double value)
Construct a Time in the indicated unit.
void ReceiveWavePacket(Ptr< Socket > socket)
Receive a WAVE BSM packet.
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.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
static TypeId GetTypeId(void)
Get the type ID.
virtual int Close(void)=0
Close a socket.
int m_chAccessMode
WAVE channel access mode. 0=continuous PHY; 1=channel-switching.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static bool IsMatchingType(const Address &address)
Ipv4Address GetIpv4(void) const
static TypeId LookupByName(std::string name)
Get a TypeId by name.