18 #include "ns3/wifi-mac.h"
19 #include "ns3/wifi-phy.h"
21 #include "ns3/pointer.h"
22 #include "ns3/string.h"
23 #include "ns3/wifi-mode.h"
24 #include "ns3/config.h"
25 #include "ns3/names.h"
26 #include "ns3/abort.h"
27 #include "ns3/ampdu-subframe-header.h"
28 #include "ns3/wave-net-device.h"
29 #include "ns3/minstrel-wifi-manager.h"
30 #include "ns3/radiotap-header.h"
31 #include "ns3/unused.h"
48 NS_LOG_FUNCTION (stream << context << p << mode << preamble << txLevel);
93 uint16_t channelFreqMhz,
94 uint16_t channelNumber,
109 NS_FATAL_ERROR (
"PcapSniffTxEvent(): DLT_PRISM_HEADER not implemented");
135 uint16_t channelFlags = 0;
150 if (channelFreqMhz < 2500)
168 mcsRate = rate - 128;
189 if (txVector.
GetNess () & 0x01)
193 if (txVector.
GetNess () & 0x02)
215 uint32_t extractedLength;
218 p = p->
CreateFragment (0, static_cast<uint32_t> (extractedLength));
230 uint8_t vhtBandwidth = 0;
231 uint8_t vhtMcsNss[4] = {0,0,0,0};
232 uint8_t vhtCoding = 0;
233 uint8_t vhtGroupId = 0;
234 uint16_t vhtPartialAid = 0;
266 vhtMcsNss[0] |= (txVector.
GetNss () & 0x0f);
267 vhtMcsNss[0] |= (((rate - 128) << 4) & 0xf0);
269 header.
SetVhtFields (vhtKnown, vhtFlags, vhtBandwidth, vhtMcsNss, vhtCoding, vhtGroupId, vhtPartialAid);
277 NS_ABORT_MSG (
"PcapSniffTxEvent(): Unexpected data link type " << dlt);
285 uint16_t channelFreqMhz,
286 uint16_t channelNumber,
302 NS_FATAL_ERROR (
"PcapSniffRxEvent(): DLT_PRISM_HEADER not implemented");
328 uint16_t channelFlags = 0;
343 if (channelFreqMhz < 2500)
364 mcsRate = rate - 128;
385 if (txVector.
GetNess () & 0x01)
389 if (txVector.
GetNess () & 0x02)
412 uint32_t extractedLength;
415 p = p->
CreateFragment (0, static_cast<uint32_t> (extractedLength));
427 uint8_t vhtBandwidth = 0;
428 uint8_t vhtMcsNss[4] = {0,0,0,0};
429 uint8_t vhtCoding = 0;
430 uint8_t vhtGroupId = 0;
431 uint16_t vhtPartialAid = 0;
463 vhtMcsNss[0] |= (txVector.
GetNss () & 0x0f);
464 vhtMcsNss[0] |= (((rate - 128) << 4) & 0xf0);
466 header.
SetVhtFields (vhtKnown, vhtFlags, vhtBandwidth, vhtMcsNss, vhtCoding, vhtGroupId, vhtPartialAid);
474 NS_ABORT_MSG (
"PcapSniffRxEvent(): Unexpected data link type " << dlt);
498 NS_LOG_INFO (
"YansWavePhyHelper::EnablePcapInternal(): Device " << &device <<
" not of type ns3::WaveNetDevice");
502 std::vector<Ptr<WifiPhy> > phys = device->
GetPhys ();
503 NS_ABORT_MSG_IF (phys.size () == 0,
"EnablePcapInternal(): Phy layer in WaveNetDevice must be set");
507 std::string filename;
508 if (explicitFilename)
519 std::vector<Ptr<WifiPhy> >::iterator i;
520 for (i = phys.begin (); i != phys.end (); ++i)
533 bool explicitFilename)
543 NS_LOG_INFO (
"EnableAsciiInternal(): Device " << device <<
" not of type ns3::WaveNetDevice");
553 uint32_t nodeid = nd->GetNode ()->GetId ();
554 uint32_t deviceid = nd->GetIfIndex ();
555 std::ostringstream oss;
572 std::string filename;
573 if (explicitFilename)
590 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/State/RxOk";
594 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/State/Tx";
608 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/RxOk";
612 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid <<
"/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/State/Tx";
635 "ControlMode",
StringValue (
"OfdmRate6MbpsBW10MHz"),
636 "NonUnicastMode",
StringValue (
"OfdmRate6MbpsBW10MHz"));
643 if (channelNumbers.size () == 0)
647 for (std::vector<uint32_t>::iterator i = channelNumbers.begin (); i != channelNumbers.end (); ++i)
651 NS_FATAL_ERROR (
"the channel number " << (*i) <<
" is not a valid WAVE channel number");
666 NS_FATAL_ERROR (
"the number of assigned WAVE PHY entities is more than the number of valid WAVE channels");
725 catch (
const std::bad_cast &)
727 NS_FATAL_ERROR (
"WifiMacHelper should be the class or subclass of QosWaveMacHelper");
758 device->
AddMac (*k, ocbMac);
764 devices.
Add (device);
778 Ptr<Node> node = Names::Find<Node> (nodeName);
802 int64_t currentStream = stream;
811 std::vector<Ptr<WifiPhy> > phys = wave->
GetPhys ();
812 for (std::vector<
Ptr<WifiPhy> >::iterator j = phys.begin (); j != phys.end (); ++i)
814 currentStream += (*j)->AssignStreams (currentStream);
818 std::map<uint32_t, Ptr<OcbWifiMac> > macs = wave->
GetMacs ();
819 for ( std::map<uint32_t,
Ptr<OcbWifiMac> >::iterator k = macs.begin (); k != macs.end (); ++k)
828 currentStream += minstrel->AssignStreams (currentStream);
832 rmac->GetAttribute (
"DcaTxop", ptr);
834 currentStream += dcaTxop->AssignStreams (currentStream);
836 rmac->GetAttribute (
"VO_EdcaTxopN", ptr);
838 currentStream += vo_edcaTxopN->
AssignStreams (currentStream);
840 rmac->GetAttribute (
"VI_EdcaTxopN", ptr);
842 currentStream += vi_edcaTxopN->
AssignStreams (currentStream);
844 rmac->GetAttribute (
"BE_EdcaTxopN", ptr);
846 currentStream += be_edcaTxopN->
AssignStreams (currentStream);
848 rmac->GetAttribute (
"BK_EdcaTxopN", ptr);
850 currentStream += bk_edcaTxopN->
AssignStreams (currentStream);
854 return (currentStream - stream);
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
uint32_t GetPcapDataLinkType(void) const
Get the data link type of PCAP traces to be used.
static void EnableLogComponents(void)
Helper to enable all WaveNetDevice log components with one statement.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
void CreateMacForChannel(std::vector< uint32_t > channelNumbers)
ObjectFactory m_channelScheduler
Manage ASCII trace files for device models.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static std::vector< uint32_t > GetWaveChannels(void)
void SetErrorRateModel(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
virtual void ConfigureStandard(enum WifiPhyStandard standard)=0
Configure the PHY-level parameters for different Wi-Fi standard.
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 ...
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
bool IsAggregation(void) const
Checks whether the PSDU contains A-MPDU.
static void AsciiPhyReceiveSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, double snr, WifiMode mode, enum WifiPreamble preamble)
virtual void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > stationManager)
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Hold variables of type string.
Hold a value for an Attribute.
Manage pcap files for device models.
void Write(Time t, Ptr< const Packet > p)
Write the next packet to file.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
virtual Ptr< WifiMac > Create(void) const =0
void ConfigureStandard(enum WifiPhyStandard standard)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
static bool IsWaveChannel(uint32_t channelNumber)
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
bool IsShortGuardInterval(void) const
#define NS_UNUSED(x)
Mark a local variable as unused.
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
This class holds together multiple, ns3::WifiPhy, and ns3::OcbWifiMac (including ns3::WifiRemoteStati...
Iterator End(void) const
Get an iterator which indicates past-the-last Node in the container.
static void AsciiPhyReceiveSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, double snr, WifiMode mode, enum WifiPreamble preamble)
static WaveHelper Default(void)
void EnableForWave(Ptr< WaveNetDevice > device)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
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. ...
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...
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
virtual void SetAddress(Address address)
Set the address of this interface.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void SetRemoteStationManager(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
This queue contains packets for a particular access class.
static uint32_t GetNumberOfWaveChannels(void)
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...
uint32_t GetDataLinkType(void)
Returns the data link type field of the pcap file as defined by the network field in the pcap global ...
std::vector< uint32_t > m_macsForChannelNumber
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
static void EnablePrinting(void)
Enable printing packets metadata.
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output the indicated net device.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
void SetChannelScheduler(Ptr< ChannelScheduler > channelScheduler)
helps to create WaveNetDevice objects
void SetChannelManager(Ptr< ChannelManager > channelManager)
holds a vector of ns3::NetDevice pointers
uint8_t GetNess(void) const
uint32_t GetChannelWidth(void) const
void SetChannelScheduler(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
bool IsStbc(void) const
Check if STBC is used or not.
hold a list of per-remote-station state.
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
void Connect(std::string path, const CallbackBase &cb)
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
static void PcapSniffRxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu, struct signalNoiseDbm signalNoise)
static uint32_t GetCch(void)
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
std::map< uint32_t, Ptr< OcbWifiMac > > GetMacs(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr.
void CreatePhys(uint32_t phys)
Iterator Begin(void) const
Get an iterator which refers to the first Node in the container.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
To trace WaveNetDevice, we have to overwrite the trace functions of class YansWifiPhyHelper.
static Time Now(void)
Return the current simulation virtual time.
virtual void SetChannelNumber(uint16_t id)=0
Set channel number.
std::vector< Ptr< WifiPhy > > GetPhys(void) const
void AddPhy(Ptr< WifiPhy > phy)
ObjectFactory m_stationManager
Instantiate subclasses of ns3::Object.
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
uint8_t GetNss(void) const
virtual Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< NetDevice > device) const =0
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
static YansWavePhyHelper Default(void)
Create a phy helper in a default working state.
void SetVsaManager(Ptr< VsaManager > vsaManager)
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
void AddMac(uint32_t channelNumber, Ptr< OcbWifiMac > mac)
static void PcapSniffTxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, WifiPreamble preamble, WifiTxVector txVector, struct mpduInfo aMpdu)
void SetChannelCoordinator(Ptr< ChannelCoordinator > channelCoordinator)
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
handle packet fragmentation and retransmissions.
static void AsciiPhyTransmitSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
void AddHeader(const Header &header)
Add header to this packet.
This class will assign channel access for requests from higher layers.
The MPDU is the last aggregate in an A-MPDU.
static void AsciiPhyTransmitSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)