22 #include "ns3/abort.h"
23 #include "ns3/config.h"
25 #include "ns3/minstrel-wifi-manager.h"
26 #include "ns3/names.h"
27 #include "ns3/pointer.h"
28 #include "ns3/qos-txop.h"
29 #include "ns3/radiotap-header.h"
30 #include "ns3/string.h"
31 #include "ns3/wave-net-device.h"
53 uint8_t txLevel [[maybe_unused]])
133 bool explicitFilename)
143 NS_LOG_INFO(
"YansWavePhyHelper::EnablePcapInternal(): Device "
144 << &device <<
" not of type ns3::WaveNetDevice");
148 std::vector<Ptr<WifiPhy>> phys = device->
GetPhys();
149 NS_ABORT_MSG_IF(phys.empty(),
"EnablePcapInternal(): Phy layer in WaveNetDevice must be set");
153 std::string filename;
154 if (explicitFilename)
166 std::vector<Ptr<WifiPhy>>::iterator i;
167 for (i = phys.begin(); i != phys.end(); ++i)
170 phy->TraceConnectWithoutContext(
173 phy->TraceConnectWithoutContext(
183 bool explicitFilename)
193 NS_LOG_INFO(
"EnableAsciiInternal(): Device " << device
194 <<
" not of type ns3::WaveNetDevice");
204 uint32_t nodeid = nd->GetNode()->GetId();
205 uint32_t deviceid = nd->GetIfIndex();
206 std::ostringstream oss;
223 std::string filename;
224 if (explicitFilename)
241 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid
242 <<
"/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/State/RxOk";
248 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid
249 <<
"/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/State/Tx";
265 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid
266 <<
"/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/RxOk";
270 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid
271 <<
"/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/State/Tx";
305 if (channelNumbers.empty())
309 for (std::vector<uint32_t>::iterator i = channelNumbers.begin(); i != channelNumbers.end(); ++i)
313 NS_FATAL_ERROR(
"the channel number " << (*i) <<
" is not a valid WAVE channel number");
328 NS_FATAL_ERROR(
"the number of assigned WAVE PHY entities is more than the number of valid "
344 catch (
const std::bad_cast&)
346 NS_FATAL_ERROR(
"WifiMacHelper should be the class or subclass of QosWaveMacHelper");
362 std::vector<Ptr<WifiPhy>> phys = phyHelper.
Create(node, device);
365 phys[0]->SetOperatingChannel(
399 Ptr<Node> node = Names::Find<Node>(nodeName);
423 int64_t currentStream = stream;
432 std::vector<Ptr<WifiPhy>> phys = wave->
GetPhys();
433 for (std::vector<
Ptr<WifiPhy>>::iterator j = phys.begin(); j != phys.end(); ++j)
435 currentStream += (*j)->AssignStreams(currentStream);
439 std::map<uint32_t, Ptr<OcbWifiMac>> macs = wave->
GetMacs();
440 for (std::map<uint32_t,
Ptr<OcbWifiMac>>::iterator
k = macs.begin();
k != macs.end();
448 currentStream += minstrel->AssignStreams(currentStream);
452 k->second->GetAttribute(
"Txop", ptr);
456 k->second->GetAttribute(
"VO_Txop", ptr);
460 k->second->GetAttribute(
"VI_Txop", ptr);
464 k->second->GetAttribute(
"BE_Txop", ptr);
468 k->second->GetAttribute(
"BK_Txop", ptr);
474 return (currentStream - stream);
Manage ASCII trace files for device models.
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the ascii trace helper figure out a reasonable filename to use for an ascii trace file associated...
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
static std::vector< uint32_t > GetWaveChannels()
static uint32_t GetNumberOfWaveChannels()
static bool IsWaveChannel(uint32_t channelNumber)
This class will assign channel access for requests from higher layers.
static Mac48Address Allocate()
Allocate a new Mac48Address.
holds a vector of ns3::NetDevice pointers
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void EnableForWave(Ptr< WaveNetDevice > device)
std::ostream * GetStream()
Return a pointer to an ostream previously set in the wrapper.
static void EnablePrinting()
Enable printing packets metadata.
Manage pcap files for device models.
std::string GetFilenameFromDevice(std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
Let the pcap helper figure out a reasonable filename to use for a pcap file associated with a device.
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, DataLinkType dataLinkType, uint32_t snapLen=std::numeric_limits< uint32_t >::max(), int32_t tzCorrection=0)
Create and initialize a pcap file.
Hold objects of type Ptr<T>.
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Qos Wave Mac Helper class.
static Time Now()
Return the current simulation virtual time.
Hold variables of type string.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Handle packet fragmentation and retransmissions for data and management frames.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
helps to create WaveNetDevice objects
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the Phy and Mac aspects ...
std::vector< uint32_t > m_macsForChannelNumber
MACs for channel number.
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
static void EnableLogComponents()
Helper to enable all WaveNetDevice log components with one statement.
uint32_t m_physNumber
Phy number.
void CreateMacForChannel(std::vector< uint32_t > channelNumbers)
void SetChannelScheduler(std::string type, Ts &&... args)
void SetRemoteStationManager(std::string type, Ts &&... args)
ObjectFactory m_channelScheduler
channel scheduler
ObjectFactory m_stationManager
station manager
void CreatePhys(uint32_t phys)
static WaveHelper Default()
This class holds together multiple, ns3::WifiPhy, and ns3::OcbWifiMac (including ns3::WifiRemoteStati...
void AddPhy(Ptr< WifiPhy > phy)
void SetChannelCoordinator(Ptr< ChannelCoordinator > channelCoordinator)
void AddMac(uint32_t channelNumber, Ptr< OcbWifiMac > mac)
void SetAddress(Address address) override
Set the address of this interface.
void SetChannelScheduler(Ptr< ChannelScheduler > channelScheduler)
void SetVsaManager(Ptr< VsaManager > vsaManager)
const std::vector< Ptr< WifiPhy > > & GetPhys() const override
std::map< uint32_t, Ptr< OcbWifiMac > > GetMacs() const
void SetChannelManager(Ptr< ChannelManager > channelManager)
static void EnableLogComponents()
Helper to enable all WifiNetDevice log components with one statement.
create MAC layers for a ns3::WifiNetDevice.
virtual Ptr< WifiMac > Create(Ptr< WifiNetDevice > device, WifiStandard standard) const
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > stationManager)
represent a single transmission mode
void SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
PcapHelper::DataLinkType GetPcapDataLinkType() const
Get the data link type of PCAP traces to be used.
static void PcapSniffRxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise, uint16_t staId=SU_STA_ID)
virtual std::vector< Ptr< WifiPhy > > Create(Ptr< Node > node, Ptr< WifiNetDevice > device) const =0
static void PcapSniffTxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, uint16_t staId=SU_STA_ID)
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
hold a list of per-remote-station state.
To trace WaveNetDevice, we have to overwrite the trace functions of class YansWifiPhyHelper.
void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
Enable pcap output the indicated net device.
void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename) override
Enable ascii trace output on the indicated net device.
static YansWavePhyHelper Default()
Create a phy helper in a default working state.
void Connect(std::string path, const CallbackBase &cb)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#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_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
auto MakeBoundCallback(R(*fnPtr)(Args...), BArgs &&... bargs)
Make Callbacks with varying number of bound arguments.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
static void AsciiPhyReceiveSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, double snr, WifiMode mode, WifiPreamble preamble)
ASCII Phy receive sink without context.
@ LOG_LEVEL_ALL
Print everything.
static void AsciiPhyReceiveSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, double snr, WifiMode mode, WifiPreamble preamble)
ASCII Phy receive sink with context.
static void AsciiPhyTransmitSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, WifiMode mode[[maybe_unused]], WifiPreamble preamble[[maybe_unused]], uint8_t txLevel[[maybe_unused]])
ASCII Phy transmit sink with context.
static void AsciiPhyTransmitSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
ASCII Phy transmit sink without context.