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