17#include "ns3/command-line.h"
18#include "ns3/mobility-helper.h"
19#include "ns3/net-device-container.h"
20#include "ns3/node-container.h"
22#include "ns3/packet.h"
23#include "ns3/seq-ts-header.h"
24#include "ns3/simulator.h"
25#include "ns3/wave-helper.h"
26#include "ns3/wave-mac-helper.h"
27#include "ns3/wave-net-device.h"
28#include "ns3/yans-wifi-helper.h"
96 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
97 positionAlloc->Add(Vector(5.0, 0.0, 0.0));
98 mobility.SetPositionAllocator(positionAlloc);
99 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
107 WaveHelper waveHelper = WaveHelper::Default();
129 std::cout <<
"receive a packet: " << std::endl
130 <<
" sequence = " << seqTs.
GetSeq() <<
"," << std::endl
131 <<
" sendTime = " << seqTs.
GetTs().
As(Time::S) <<
"," << std::endl
132 <<
" recvTime = " <<
Now().
As(Time::S) <<
"," << std::endl
133 <<
" protocol = 0x" << std::hex << mode << std::dec << std::endl;
142 const static uint16_t WSMP_PROT_NUMBER = 0x88DC;
143 Mac48Address bssWildcard = Mac48Address::GetBroadcast();
150 sender->
SendX(p, bssWildcard, WSMP_PROT_NUMBER, txInfo);
162 Simulator::Schedule(
Seconds(0.0), &WaveNetDevice::StartSch, sender, schInfo);
165 Simulator::Schedule(
Seconds(0.0), &WaveNetDevice::StartSch, receiver, schInfo);
177 Simulator::Schedule(
Seconds(2.0), &WaveNetDevice::StopSch, sender,
SCH1);
178 Simulator::Schedule(
Seconds(2.0), &WaveNetDevice::StopSch, receiver,
SCH1);
187 Simulator::Destroy();
197 const static uint16_t IPv4_PROT_NUMBER = 0x0800;
198 const static uint16_t IPv6_PROT_NUMBER = 0x86DD;
199 uint16_t protocol = ipv6 ? IPv6_PROT_NUMBER : IPv4_PROT_NUMBER;
204 sender->
Send(p, dest, protocol);
216 Simulator::Schedule(
Seconds(0.0), &WaveNetDevice::StartSch, sender, schInfo);
219 Simulator::Schedule(
Seconds(0.0), &WaveNetDevice::StartSch, receiver, schInfo);
228 Simulator::Schedule(
Seconds(2.0), &WaveNetDevice::RegisterTxProfile, sender, txProfile);
233 Simulator::Schedule(
Seconds(4.0), &WaveNetDevice::DeleteTxProfile, sender,
SCH1);
234 Simulator::Schedule(
Seconds(4.0), &WaveNetDevice::StopSch, sender,
SCH1);
235 Simulator::Schedule(
Seconds(4.0), &WaveNetDevice::StopSch, receiver,
SCH1);
243 Simulator::Destroy();
249 std::cout <<
"receive a VSA management frame: recvTime = " <<
Now().
As(Time::S) <<
"."
263 Simulator::Schedule(
Seconds(0.0), &WaveNetDevice::StartSch, sender, schInfo);
264 Simulator::Schedule(
Seconds(0.0), &WaveNetDevice::StartSch, receiver, schInfo);
272 Simulator::Schedule(
Seconds(1.0), &WaveNetDevice::StartVsa, sender, vsaInfo);
273 Simulator::Schedule(
Seconds(3.0), &WaveNetDevice::StopVsa, sender,
SCH1);
276 Simulator::Schedule(
Seconds(4.0), &WaveNetDevice::StopSch, sender,
SCH1);
277 Simulator::Schedule(
Seconds(4.0), &WaveNetDevice::StopSch, receiver,
SCH1);
280 Simulator::Schedule(
Seconds(5.0), &WaveNetDevice::StartVsa, sender, vsaInfo);
281 Simulator::Schedule(
Seconds(6.0), &WaveNetDevice::StopVsa, sender,
SCH1);
285 Simulator::Destroy();
289main(
int argc,
char* argv[])
292 cmd.Parse(argc, argv);
295 std::cout <<
"run WAVE WSMP routing service case:" << std::endl;
297 std::cout <<
"run WAVE IP routing service case:" << std::endl;
299 std::cout <<
"run WAVE WSA routing service case:" << std::endl;
#define EXTENDED_ALTERNATING
This simulation is to show the routing service of WaveNetDevice described in IEEE 09....
void CreateWaveNodes()
Create WAVE nodes function.
void SendWsmpExample()
Send WSMP example function.
void SendWsaExample()
Send WSA example.
bool Receive(Ptr< NetDevice > dev, Ptr< const Packet > pkt, uint16_t mode, const Address &sender)
Receive function.
void SendOneWsmpPacket(uint32_t channel, uint32_t seq)
Send one WSMP packet function.
NetDeviceContainer devices
the devices
void SendIpPacket(uint32_t seq, bool ipv6)
Send IP packet function.
NodeContainer nodes
the nodes
void SendIpExample()
Send IP example function.
bool ReceiveVsa(Ptr< const Packet > pkt, const Address &address, uint32_t, uint32_t)
Receive VSA function.
a polymophic address class
Parse command-line arguments.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
the organization identifier is a public organizationally unique identifier assigned by the IEEE.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
Smart pointer class similar to boost::intrusive_ptr.
Qos Wave Mac Helper class.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
helps to create WaveNetDevice objects
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
Address GetAddress() const override
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
bool SendX(Ptr< Packet > packet, const Address &dest, uint32_t protocol, const TxInfo &txInfo)
void SetWaveVsaCallback(WaveVsaCallback vsaCallback)
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
To trace WaveNetDevice, we have to overwrite the trace functions of class YansWifiPhyHelper.
manage and create wifi channel objects for the YANS model.
Ptr< YansWifiChannel > Create() const
void SetChannel(Ptr< YansWifiChannel > channel)
Time Now()
create an ns3::Time instance which contains the current simulation time.
Time Seconds(double 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...