22 #include "ns3/bsm-application.h"
24 #include "ns3/seq-ts-header.h"
25 #include "ns3/wave-net-device.h"
26 #include "ns3/wave-mac-helper.h"
27 #include "ns3/wave-helper.h"
28 #include "ns3/mobility-model.h"
29 #include "ns3/mobility-helper.h"
45 .SetGroupName (
"Wave")
53 m_txSafetyRangesSq (),
55 m_wavePacketSize (200),
58 m_gpsAccuracyNs (10000),
59 m_adhocTxInterfaces (0),
105 recvSink->
Bind (local);
172 Time txTime = startTime + tDrift + txDelay;
188 uint32_t wavePacketSize,
190 double gpsAccuracyNs,
191 std::vector <double> rangesSq,
193 std::vector<int> * nodesMoving,
199 m_unirv = CreateObject<UniformRandomVariable> ();
205 int size = rangesSq.size ();
212 for (
int index = 0; index < size; index++)
225 uint32_t pktCount,
Time pktInterval,
226 uint32_t sendingNodeId)
237 int txNodeId = sendingNodeId;
243 if (senderMoving != 0)
246 socket->
Send (Create<Packet> (pktSize));
251 if ((
m_waveBsmStats->GetLogging () != 0) && ((wavePktsSent % 1000) == 0))
259 for (
int i = 0; i < nRxNodes; i++)
262 int rxNodeId = rxNode->
GetId ();
264 if (rxNodeId != txNodeId)
273 if (receiverMoving == 1)
280 for (
int index = 1; index <= rangeCount; index++)
310 socket, pktSize, pktCount - 1, pktInterval, socket->GetNode ()->GetId ());
323 while ((packet = socket->
Recv ()))
335 for (
int i = 0; i <
nodes; i++)
360 int rxNodeId = rxNode->
GetId ();
362 if (receiverMoving == 1)
368 for (
int index = 1; index <= rangeCount; index++)
Simulation virtual time values and global simulation resolution.
Ipv4Address GetIpv4(void) const
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
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
holds a vector of std::pair of Ptr and interface index.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
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
uint32_t m_wavePacketSize
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
#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)
Application specific startup code.
uint32_t m_numWavePackets
uint32_t GetN(void) const
Keep track of the current position and velocity of an object.
virtual void DoDispose(void)
Destructor implementation.
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
virtual ~BsmApplication()
The base class for all ns3 applications.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
virtual void StopApplication(void)
Application specific shutdown code.
Ptr< Node > GetNode() const
This class implements a tag that carries an address of a packet across the socket interface...
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
The BsmApplication class sends and receives the IEEE 1609 WAVE (Wireless Access in Vehicular Environm...
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...
void GenerateWaveTraffic(Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval, uint32_t sendingNodeId)
Creates and transmits a WAVE BSM packet.
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual void DoDispose(void)
Destructor implementation.
Ptr< WaveBsmStats > m_waveBsmStats
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.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionaly.
int64_t GetInteger(void) const
double GetDouble(void) const
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.
Ipv4 addresses are stored in host order in this class.
uint32_t GetId(void) const
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
Address GetAddress(void) const
Get the tag's address.
Time Seconds(double value)
Construct a Time in the indicated unit.
void ReceiveWavePacket(Ptr< Socket > socket)
Receive a WAVE BSM packet.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
static TypeId GetTypeId(void)
virtual int Close(void)=0
Close a socket.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
static TypeId LookupByName(std::string name)
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const