A Discrete-Event Network Simulator
API
wave-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License version 2 as
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Author: Junling Bu <linlinjavaer@gmail.com>
17  */
18 #include "ns3/wifi-mac.h"
19 #include "ns3/wifi-phy.h"
20 #include "ns3/log.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/wave-net-device.h"
28 #include "ns3/minstrel-wifi-manager.h"
29 #include "ns3/radiotap-header.h"
30 #include "ns3/unused.h"
31 #include "wave-mac-helper.h"
32 #include "wave-helper.h"
33 
34 NS_LOG_COMPONENT_DEFINE ("WaveHelper");
35 
36 namespace ns3 {
37 
38 static void
41  std::string context,
43  WifiMode mode,
44  WifiPreamble preamble,
45  uint8_t txLevel)
46 {
47  NS_LOG_FUNCTION (stream << context << p << mode << preamble << txLevel);
48  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
49 }
50 
51 static void
55  WifiMode mode,
56  WifiPreamble preamble,
57  uint8_t txLevel)
58 {
59  NS_LOG_FUNCTION (stream << p << mode << preamble << txLevel);
60  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
61 }
62 
63 static void
66  std::string context,
68  double snr,
69  WifiMode mode,
70  enum WifiPreamble preamble)
71 {
72  NS_LOG_FUNCTION (stream << context << p << snr << mode << preamble);
73  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
74 }
75 
76 static void
80  double snr,
81  WifiMode mode,
82  enum WifiPreamble preamble)
83 {
84  NS_LOG_FUNCTION (stream << p << snr << mode << preamble);
85  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
86 }
87 
88 static void
91  Ptr<const Packet> packet,
92  uint16_t channelFreqMhz,
93  uint16_t channelNumber,
94  uint32_t rate,
95  bool isShortPreamble,
96  uint8_t txPower)
97 {
98  uint32_t dlt = file->GetDataLinkType ();
99 
100  switch (dlt)
101  {
103  file->Write (Simulator::Now (), packet);
104  return;
106  {
107  NS_FATAL_ERROR ("PcapSniffTxEvent(): DLT_PRISM_HEADER not implemented");
108  return;
109  }
111  {
112  Ptr<Packet> p = packet->Copy ();
113  RadiotapHeader header;
114  uint8_t frameFlags = RadiotapHeader::FRAME_FLAG_NONE;
115  header.SetTsft (Simulator::Now ().GetMicroSeconds ());
116 
117  // Our capture includes the FCS, so we set the flag to say so.
119 
120  if (isShortPreamble)
121  {
123  }
124 
125  header.SetFrameFlags (frameFlags);
126  header.SetRate (rate);
127 
128  uint16_t channelFlags = 0;
129  switch (rate)
130  {
131  case 2: // 1Mbps
132  case 4: // 2Mbps
133  case 10: // 5Mbps
134  case 22: // 11Mbps
135  channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK;
136  break;
137 
138  default:
139  channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM;
140  break;
141  }
142 
143  if (channelFreqMhz < 2500)
144  {
146  }
147  else
148  {
150  }
151 
152  header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags);
153 
154 
155  p->AddHeader (header);
156  file->Write (Simulator::Now (), p);
157  return;
158  }
159  default:
160  NS_ABORT_MSG ("PcapSniffTxEvent(): Unexpected data link type " << dlt);
161  }
162 }
163 
164 static void
167  Ptr<const Packet> packet,
168  uint16_t channelFreqMhz,
169  uint16_t channelNumber,
170  uint32_t rate,
171  bool isShortPreamble,
172  double signalDbm,
173  double noiseDbm)
174 {
175  uint32_t dlt = file->GetDataLinkType ();
176 
177  switch (dlt)
178  {
180  file->Write (Simulator::Now (), packet);
181  return;
183  {
184  NS_FATAL_ERROR ("PcapSniffRxEvent(): DLT_PRISM_HEADER not implemented");
185  return;
186  }
188  {
189  Ptr<Packet> p = packet->Copy ();
190  RadiotapHeader header;
191  uint8_t frameFlags = RadiotapHeader::FRAME_FLAG_NONE;
192  header.SetTsft (Simulator::Now ().GetMicroSeconds ());
193 
194  // Our capture includes the FCS, so we set the flag to say so.
196 
197  if (isShortPreamble)
198  {
200  }
201 
202  header.SetFrameFlags (frameFlags);
203  header.SetRate (rate);
204 
205  uint16_t channelFlags = 0;
206  switch (rate)
207  {
208  case 2: // 1Mbps
209  case 4: // 2Mbps
210  case 10: // 5Mbps
211  case 22: // 11Mbps
212  channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK;
213  break;
214 
215  default:
216  channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM;
217  break;
218  }
219 
220  if (channelFreqMhz < 2500)
221  {
223  }
224  else
225  {
227  }
228 
229  header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags);
230 
231  header.SetAntennaSignalPower (signalDbm);
232  header.SetAntennaNoisePower (noiseDbm);
233 
234  p->AddHeader (header);
235  file->Write (Simulator::Now (), p);
236  return;
237  }
238  default:
239  NS_ABORT_MSG ("PcapSniffRxEvent(): Unexpected data link type " << dlt);
240  }
241 }
242 
243 /****************************** YansWavePhyHelper ***********************************/
244 YansWavePhyHelper
246 {
247  YansWavePhyHelper helper;
248  helper.SetErrorRateModel ("ns3::NistErrorRateModel");
249  return helper;
250 }
251 
252 void
253 YansWavePhyHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous, bool explicitFilename)
254 {
255  //
256  // All of the Pcap enable functions vector through here including the ones
257  // that are wandering through all of devices on perhaps all of the nodes in
258  // the system. We can only deal with devices of type WaveNetDevice.
259  //
260  Ptr<WaveNetDevice> device = nd->GetObject<WaveNetDevice> ();
261  if (device == 0)
262  {
263  NS_LOG_INFO ("YansWavePhyHelper::EnablePcapInternal(): Device " << &device << " not of type ns3::WaveNetDevice");
264  return;
265  }
266 
267  std::vector<Ptr<WifiPhy> > phys = device->GetPhys ();
268  NS_ABORT_MSG_IF (phys.size () == 0, "EnablePcapInternal(): Phy layer in WaveNetDevice must be set");
269 
270  PcapHelper pcapHelper;
271 
272  std::string filename;
273  if (explicitFilename)
274  {
275  filename = prefix;
276  }
277  else
278  {
279  filename = pcapHelper.GetFilenameFromDevice (prefix, device);
280  }
281 
282  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, GetPcapDataLinkType ());
283 
284  std::vector<Ptr<WifiPhy> >::iterator i;
285  for (i = phys.begin (); i != phys.end (); ++i)
286  {
287  Ptr<WifiPhy> phy = (*i);
288  phy->TraceConnectWithoutContext ("MonitorSnifferTx", MakeBoundCallback (&PcapSniffTxEvent, file));
289  phy->TraceConnectWithoutContext ("MonitorSnifferRx", MakeBoundCallback (&PcapSniffRxEvent, file));
290  }
291 }
292 
293 void
296  std::string prefix,
297  Ptr<NetDevice> nd,
298  bool explicitFilename)
299 {
300  //
301  // All of the ascii enable functions vector through here including the ones
302  // that are wandering through all of devices on perhaps all of the nodes in
303  // the system. We can only deal with devices of type WaveNetDevice.
304  //
305  Ptr<WaveNetDevice> device = nd->GetObject<WaveNetDevice> ();
306  if (device == 0)
307  {
308  NS_LOG_INFO ("EnableAsciiInternal(): Device " << device << " not of type ns3::WaveNetDevice");
309  return;
310  }
311 
312  //
313  // Our trace sinks are going to use packet printing, so we have to make sure
314  // that is turned on.
315  //
317 
318  uint32_t nodeid = nd->GetNode ()->GetId ();
319  uint32_t deviceid = nd->GetIfIndex ();
320  std::ostringstream oss;
321 
322  //
323  // If we are not provided an OutputStreamWrapper, we are expected to create
324  // one using the usual trace filename conventions and write our traces
325  // without a context since there will be one file per context and therefore
326  // the context would be redundant.
327  //
328  if (stream == 0)
329  {
330  //
331  // Set up an output stream object to deal with private ofstream copy
332  // constructor and lifetime issues. Let the helper decide the actual
333  // name of the file given the prefix.
334  //
335  AsciiTraceHelper asciiTraceHelper;
336 
337  std::string filename;
338  if (explicitFilename)
339  {
340  filename = prefix;
341  }
342  else
343  {
344  filename = asciiTraceHelper.GetFilenameFromDevice (prefix, device);
345  }
346 
347  Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
348  //
349  // We could go poking through the phy and the state looking for the
350  // correct trace source, but we can let Config deal with that with
351  // some search cost. Since this is presumably happening at topology
352  // creation time, it doesn't seem much of a price to pay.
353  //
354  oss.str ("");
355  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/State/RxOk";
357 
358  oss.str ("");
359  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/State/Tx";
361 
362  return;
363  }
364 
365  //
366  // If we are provided an OutputStreamWrapper, we are expected to use it, and
367  // to provide a context. We are free to come up with our own context if we
368  // want, and use the AsciiTraceHelper Hook*WithContext functions, but for
369  // compatibility and simplicity, we just use Config::Connect and let it deal
370  // with coming up with a context.
371  //
372  oss.str ("");
373  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/RxOk";
375 
376  oss.str ("");
377  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/State/Tx";
379 }
380 
381 /********************************** WaveHelper ******************************************/
383 {
384 }
385 
387 {
388 }
389 
392 {
393  WaveHelper helper;
394  // default 7 MAC entities and single PHY device.
396  helper.CreatePhys (1);
397  helper.SetChannelScheduler ("ns3::DefaultChannelScheduler");
398  helper.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
399  "DataMode", StringValue ("OfdmRate6MbpsBW10MHz"),
400  "ControlMode",StringValue ("OfdmRate6MbpsBW10MHz"),
401  "NonUnicastMode", StringValue ("OfdmRate6MbpsBW10MHz"));
402  return helper;
403 }
404 
405 void
406 WaveHelper::CreateMacForChannel (std::vector<uint32_t> channelNumbers)
407 {
408  if (channelNumbers.size () == 0)
409  {
410  NS_FATAL_ERROR ("the WAVE MAC entities is at least one");
411  }
412  for (std::vector<uint32_t>::iterator i = channelNumbers.begin (); i != channelNumbers.end (); ++i)
413  {
415  {
416  NS_FATAL_ERROR ("the channel number " << (*i) << " is not a valid WAVE channel number");
417  }
418  }
419  m_macsForChannelNumber = channelNumbers;
420 }
421 
422 void
423 WaveHelper::CreatePhys (uint32_t phys)
424 {
425  if (phys == 0)
426  {
427  NS_FATAL_ERROR ("the WAVE PHY entities is at least one");
428  }
430  {
431  NS_FATAL_ERROR ("the number of assigned WAVE PHY entities is more than the number of valid WAVE channels");
432  }
433  m_physNumber = phys;
434 }
435 
436 void
438  std::string n0, const AttributeValue &v0,
439  std::string n1, const AttributeValue &v1,
440  std::string n2, const AttributeValue &v2,
441  std::string n3, const AttributeValue &v3,
442  std::string n4, const AttributeValue &v4,
443  std::string n5, const AttributeValue &v5,
444  std::string n6, const AttributeValue &v6,
445  std::string n7, const AttributeValue &v7)
446 {
449  m_stationManager.Set (n0, v0);
450  m_stationManager.Set (n1, v1);
451  m_stationManager.Set (n2, v2);
452  m_stationManager.Set (n3, v3);
453  m_stationManager.Set (n4, v4);
454  m_stationManager.Set (n5, v5);
455  m_stationManager.Set (n6, v6);
456  m_stationManager.Set (n7, v7);
457 }
458 
459 void
461  std::string n0, const AttributeValue &v0,
462  std::string n1, const AttributeValue &v1,
463  std::string n2, const AttributeValue &v2,
464  std::string n3, const AttributeValue &v3,
465  std::string n4, const AttributeValue &v4,
466  std::string n5, const AttributeValue &v5,
467  std::string n6, const AttributeValue &v6,
468  std::string n7, const AttributeValue &v7)
469 {
472  m_channelScheduler.Set (n0, v0);
473  m_channelScheduler.Set (n1, v1);
474  m_channelScheduler.Set (n2, v2);
475  m_channelScheduler.Set (n3, v3);
476  m_channelScheduler.Set (n4, v4);
477  m_channelScheduler.Set (n5, v5);
478  m_channelScheduler.Set (n6, v6);
479  m_channelScheduler.Set (n7, v7);
480 }
481 
483 WaveHelper::Install (const WifiPhyHelper &phyHelper, const WifiMacHelper &macHelper, NodeContainer c) const
484 {
485  try
486  {
487  const QosWaveMacHelper& qosMac = dynamic_cast<const QosWaveMacHelper&> (macHelper);
488  NS_UNUSED (qosMac);
489  }
490  catch (const std::bad_cast &)
491  {
492  NS_FATAL_ERROR ("WifiMacHelper should be the class or subclass of QosWaveMacHelper");
493  }
494 
496  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
497  {
498  Ptr<Node> node = *i;
499  Ptr<WaveNetDevice> device = CreateObject<WaveNetDevice> ();
500 
501  device->SetChannelManager (CreateObject<ChannelManager> ());
502  device->SetChannelCoordinator (CreateObject<ChannelCoordinator> ());
503  device->SetVsaManager (CreateObject<VsaManager> ());
505 
506  for (uint32_t j = 0; j != m_physNumber; ++j)
507  {
508  Ptr<WifiPhy> phy = phyHelper.Create (node, device);
511  device->AddPhy (phy);
512  }
513 
514  for (std::vector<uint32_t>::const_iterator k = m_macsForChannelNumber.begin ();
515  k != m_macsForChannelNumber.end (); ++k)
516  {
517  Ptr<WifiMac> wifiMac = macHelper.Create ();
518  Ptr<OcbWifiMac> ocbMac = DynamicCast<OcbWifiMac> (wifiMac);
519  // we use WaveMacLow to replace original MacLow
520  ocbMac->EnableForWave (device);
523  device->AddMac (*k, ocbMac);
524  }
525 
526  device->SetAddress (Mac48Address::Allocate ());
527 
528  node->AddDevice (device);
529  devices.Add (device);
530  }
531  return devices;
532 }
533 
535 WaveHelper::Install (const WifiPhyHelper &phy, const WifiMacHelper &mac, Ptr<Node> node) const
536 {
537  return Install (phy, mac, NodeContainer (node));
538 }
539 
541 WaveHelper::Install (const WifiPhyHelper &phy, const WifiMacHelper &mac, std::string nodeName) const
542 {
543  Ptr<Node> node = Names::Find<Node> (nodeName);
544  return Install (phy, mac, NodeContainer (node));
545 }
546 
547 void
549 {
551 
552  LogComponentEnable ("WaveNetDevice", LOG_LEVEL_ALL);
553  LogComponentEnable ("ChannelCoordinator", LOG_LEVEL_ALL);
554  LogComponentEnable ("ChannelManager", LOG_LEVEL_ALL);
555  LogComponentEnable ("ChannelScheduler", LOG_LEVEL_ALL);
556  LogComponentEnable ("DefaultChannelScheduler", LOG_LEVEL_ALL);
557  LogComponentEnable ("VsaManager", LOG_LEVEL_ALL);
558  LogComponentEnable ("OcbWifiMac", LOG_LEVEL_ALL);
559  LogComponentEnable ("VendorSpecificAction", LOG_LEVEL_ALL);
560  LogComponentEnable ("WaveMacLow", LOG_LEVEL_ALL);
561  LogComponentEnable ("HigherLayerTxVectorTag", LOG_LEVEL_ALL);
562 }
563 
564 int64_t
566 {
567  int64_t currentStream = stream;
568  Ptr<NetDevice> netDevice;
569  for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); ++i)
570  {
571  netDevice = (*i);
572  Ptr<WaveNetDevice> wave = DynamicCast<WaveNetDevice> (netDevice);
573  if (wave)
574  {
575  // Handle any random numbers in the PHY objects.
576  std::vector<Ptr<WifiPhy> > phys = wave->GetPhys ();
577  for (std::vector<Ptr<WifiPhy> >::iterator j = phys.begin (); j != phys.end (); ++i)
578  {
579  currentStream += (*j)->AssignStreams (currentStream);
580  }
581 
582  // Handle any random numbers in the MAC objects.
583  std::map<uint32_t, Ptr<OcbWifiMac> > macs = wave->GetMacs ();
584  for ( std::map<uint32_t, Ptr<OcbWifiMac> >::iterator k = macs.begin (); k != macs.end (); ++k)
585  {
586  Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (k->second);
587 
588  // Handle any random numbers in the station managers.
589  Ptr<WifiRemoteStationManager> manager = rmac->GetWifiRemoteStationManager ();
590  Ptr<MinstrelWifiManager> minstrel = DynamicCast<MinstrelWifiManager> (manager);
591  if (minstrel)
592  {
593  currentStream += minstrel->AssignStreams (currentStream);
594  }
595 
596  PointerValue ptr;
597  rmac->GetAttribute ("DcaTxop", ptr);
598  Ptr<DcaTxop> dcaTxop = ptr.Get<DcaTxop> ();
599  currentStream += dcaTxop->AssignStreams (currentStream);
600 
601  rmac->GetAttribute ("VO_EdcaTxopN", ptr);
602  Ptr<EdcaTxopN> vo_edcaTxopN = ptr.Get<EdcaTxopN> ();
603  currentStream += vo_edcaTxopN->AssignStreams (currentStream);
604 
605  rmac->GetAttribute ("VI_EdcaTxopN", ptr);
606  Ptr<EdcaTxopN> vi_edcaTxopN = ptr.Get<EdcaTxopN> ();
607  currentStream += vi_edcaTxopN->AssignStreams (currentStream);
608 
609  rmac->GetAttribute ("BE_EdcaTxopN", ptr);
610  Ptr<EdcaTxopN> be_edcaTxopN = ptr.Get<EdcaTxopN> ();
611  currentStream += be_edcaTxopN->AssignStreams (currentStream);
612 
613  rmac->GetAttribute ("BK_EdcaTxopN", ptr);
614  Ptr<EdcaTxopN> bk_edcaTxopN = ptr.Get<EdcaTxopN> ();
615  currentStream += bk_edcaTxopN->AssignStreams (currentStream);
616  }
617  }
618  }
619  return (currentStream - stream);
620 }
621 } // namespace ns3
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.
Definition: wave-helper.cc:548
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
void CreateMacForChannel(std::vector< uint32_t > channelNumbers)
Definition: wave-helper.cc:406
ObjectFactory m_channelScheduler
Definition: wave-helper.h:246
Ptr< T > Get(void) const
Definition: pointer.h:184
Manage ASCII trace files for device models.
Definition: trace-helper.h:141
#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())
tuple devices
Definition: first.py:32
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 ...
Definition: wave-helper.cc:565
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
Frame sent/received with short preamble.
static void AsciiPhyReceiveSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, double snr, WifiMode mode, enum WifiPreamble preamble)
Definition: wave-helper.cc:77
virtual void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > stationManager)
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Radiotap header implementation.
Hold variables of type string.
Definition: string.h:41
Hold a value for an Attribute.
Definition: attribute.h:68
Manage pcap files for device models.
Definition: trace-helper.h:38
create PHY objects
Definition: wifi-helper.h:46
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.
Definition: callback.h:1493
virtual Ptr< WifiMac > Create(void) const =0
void ConfigureStandard(enum WifiPhyStandard standard)
Definition: wifi-mac.cc:281
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
static bool IsWaveChannel(uint32_t channelNumber)
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:16
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)
Definition: wave-helper.cc:64
static WaveHelper Default(void)
Definition: wave-helper.cc:391
void EnableForWave(Ptr< WaveNetDevice > device)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
#define NS_FATAL_ERROR(msg)
Fatal error handling.
Definition: fatal-error.h:100
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. ...
void SetAntennaNoisePower(double noise)
Set the RF noise power at the antenna as a decibel difference from an arbitrary, fixed reference...
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
Definition: wave-helper.cc:483
void SetTsft(uint64_t tsft)
Set the Time Synchronization Function Timer (TSFT) value.
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...
Definition: wifi-mode.h:93
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:29
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:334
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())
Definition: wave-helper.cc:437
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:84
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...
Definition: trace-helper.cc:80
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
Definition: wave-helper.h:247
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:351
static Mac48Address Allocate(void)
Allocate a new Mac48Address.
static void EnablePrinting(void)
Enable printing packets metadata.
Definition: packet.cc:547
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output the indicated net device.
Definition: wave-helper.cc:253
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
Definition: wave-helper.h:110
void SetChannelFrequencyAndFlags(uint16_t frequency, uint16_t flags)
Set the transmit/receive channel frequency and flags.
virtual ~WaveHelper()
Definition: wave-helper.cc:386
void SetChannelManager(Ptr< ChannelManager > channelManager)
holds a vector of ns3::NetDevice pointers
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())
Definition: wave-helper.cc:460
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:733
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
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.
Definition: wave-helper.cc:294
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:744
static void PcapSniffRxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
Definition: wave-helper.cc:165
void SetFrameFlags(uint8_t flags)
Set the frame flags of the transmitted or received frame.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:122
void SetRate(uint8_t rate)
Set the transmit/receive channel frequency in units of megahertz.
static uint32_t GetCch(void)
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:298
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.
Definition: pointer.h:36
void CreatePhys(uint32_t phys)
Definition: wave-helper.cc:423
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.
create MAC objects
Definition: wifi-helper.h:72
To trace WaveNetDevice, we have to overwrite the trace functions of class YansWifiPhyHelper.
Definition: wave-helper.h:39
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
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
Definition: wave-helper.h:245
Instantiate subclasses of ns3::Object.
static void EnableLogComponents(void)
Helper to enable all WifiNetDevice log components with one statement.
Definition: wifi-helper.cc:142
virtual Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< NetDevice > device) const =0
static void PcapSniffTxEvent(Ptr< PcapFileWrapper > file, Ptr< const Packet > packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, uint8_t txPower)
Definition: wave-helper.cc:89
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:121
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
static YansWavePhyHelper Default(void)
Create a phy helper in a default working state.
Definition: wave-helper.cc:245
void SetVsaManager(Ptr< VsaManager > vsaManager)
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
void AddMac(uint32_t channelNumber, Ptr< OcbWifiMac > mac)
Print everything.
Definition: log.h:112
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.
Definition: dca-txop.h:67
static void AsciiPhyTransmitSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
Definition: wave-helper.cc:39
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.
Definition: packet.cc:253
This class will assign channel access for requests from higher layers.
uint32_t m_physNumber
Definition: wave-helper.h:248
void SetAntennaSignalPower(double signal)
Set the RF signal power at the antenna as a decibel difference from an arbitrary, fixed reference...
static void AsciiPhyTransmitSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
Definition: wave-helper.cc:52