A Discrete-Event Network Simulator
API
yans-wifi-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  * Sébastien Deronne <sebastien.deronne@gmail.com>
20  */
21 
22 #include "ns3/trace-helper.h"
23 #include "yans-wifi-helper.h"
24 #include "ns3/error-rate-model.h"
25 #include "ns3/propagation-loss-model.h"
26 #include "ns3/propagation-delay-model.h"
27 #include "ns3/yans-wifi-channel.h"
28 #include "ns3/yans-wifi-phy.h"
29 #include "ns3/ampdu-subframe-header.h"
30 #include "ns3/wifi-net-device.h"
31 #include "ns3/radiotap-header.h"
32 #include "ns3/pcap-file-wrapper.h"
33 #include "ns3/simulator.h"
34 #include "ns3/config.h"
35 #include "ns3/names.h"
36 #include "ns3/abort.h"
37 #include "ns3/log.h"
38 
39 namespace ns3 {
40 
41 NS_LOG_COMPONENT_DEFINE ("YansWifiHelper");
42 
43 static void
46  std::string context,
48  WifiMode mode,
49  WifiPreamble preamble,
50  uint8_t txLevel)
51 {
52  NS_LOG_FUNCTION (stream << context << p << mode << preamble << txLevel);
53  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
54 }
55 
56 static void
60  WifiMode mode,
61  WifiPreamble preamble,
62  uint8_t txLevel)
63 {
64  NS_LOG_FUNCTION (stream << p << mode << preamble << txLevel);
65  *stream->GetStream () << "t " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
66 }
67 
68 static void
71  std::string context,
73  double snr,
74  WifiMode mode,
75  enum WifiPreamble preamble)
76 {
77  NS_LOG_FUNCTION (stream << context << p << snr << mode << preamble);
78  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << context << " " << *p << std::endl;
79 }
80 
81 static void
85  double snr,
86  WifiMode mode,
87  enum WifiPreamble preamble)
88 {
89  NS_LOG_FUNCTION (stream << p << snr << mode << preamble);
90  *stream->GetStream () << "r " << Simulator::Now ().GetSeconds () << " " << *p << std::endl;
91 }
92 
94 {
95 }
96 
99 {
100  YansWifiChannelHelper helper;
101  helper.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
102  helper.AddPropagationLoss ("ns3::LogDistancePropagationLossModel");
103  return helper;
104 }
105 
106 void
108  std::string n0, const AttributeValue &v0,
109  std::string n1, const AttributeValue &v1,
110  std::string n2, const AttributeValue &v2,
111  std::string n3, const AttributeValue &v3,
112  std::string n4, const AttributeValue &v4,
113  std::string n5, const AttributeValue &v5,
114  std::string n6, const AttributeValue &v6,
115  std::string n7, const AttributeValue &v7)
116 {
117  ObjectFactory factory;
118  factory.SetTypeId (type);
119  factory.Set (n0, v0);
120  factory.Set (n1, v1);
121  factory.Set (n2, v2);
122  factory.Set (n3, v3);
123  factory.Set (n4, v4);
124  factory.Set (n5, v5);
125  factory.Set (n6, v6);
126  factory.Set (n7, v7);
127  m_propagationLoss.push_back (factory);
128 }
129 
130 void
132  std::string n0, const AttributeValue &v0,
133  std::string n1, const AttributeValue &v1,
134  std::string n2, const AttributeValue &v2,
135  std::string n3, const AttributeValue &v3,
136  std::string n4, const AttributeValue &v4,
137  std::string n5, const AttributeValue &v5,
138  std::string n6, const AttributeValue &v6,
139  std::string n7, const AttributeValue &v7)
140 {
141  ObjectFactory factory;
142  factory.SetTypeId (type);
143  factory.Set (n0, v0);
144  factory.Set (n1, v1);
145  factory.Set (n2, v2);
146  factory.Set (n3, v3);
147  factory.Set (n4, v4);
148  factory.Set (n5, v5);
149  factory.Set (n6, v6);
150  factory.Set (n7, v7);
151  m_propagationDelay = factory;
152 }
153 
156 {
157  Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> ();
158  Ptr<PropagationLossModel> prev = 0;
159  for (std::vector<ObjectFactory>::const_iterator i = m_propagationLoss.begin (); i != m_propagationLoss.end (); ++i)
160  {
161  Ptr<PropagationLossModel> cur = (*i).Create<PropagationLossModel> ();
162  if (prev != 0)
163  {
164  prev->SetNext (cur);
165  }
166  if (m_propagationLoss.begin () == i)
167  {
168  channel->SetPropagationLossModel (cur);
169  }
170  prev = cur;
171  }
173  channel->SetPropagationDelayModel (delay);
174  return channel;
175 }
176 
177 int64_t
179 {
180  return c->AssignStreams (stream);
181 }
182 
184  : m_channel (0),
185  m_pcapDlt (PcapHelper::DLT_IEEE802_11)
186 {
187  m_phy.SetTypeId ("ns3::YansWifiPhy");
188 }
189 
192 {
193  YansWifiPhyHelper helper;
194  helper.SetErrorRateModel ("ns3::NistErrorRateModel");
195  return helper;
196 }
197 
198 void
200 {
201  m_channel = channel;
202 }
203 
204 void
205 YansWifiPhyHelper::SetChannel (std::string channelName)
206 {
207  Ptr<YansWifiChannel> channel = Names::Find<YansWifiChannel> (channelName);
208  m_channel = channel;
209 }
210 
211 void
212 YansWifiPhyHelper::Set (std::string name, const AttributeValue &v)
213 {
214  m_phy.Set (name, v);
215 }
216 
217 void
219  std::string n0, const AttributeValue &v0,
220  std::string n1, const AttributeValue &v1,
221  std::string n2, const AttributeValue &v2,
222  std::string n3, const AttributeValue &v3,
223  std::string n4, const AttributeValue &v4,
224  std::string n5, const AttributeValue &v5,
225  std::string n6, const AttributeValue &v6,
226  std::string n7, const AttributeValue &v7)
227 {
230  m_errorRateModel.Set (n0, v0);
231  m_errorRateModel.Set (n1, v1);
232  m_errorRateModel.Set (n2, v2);
233  m_errorRateModel.Set (n3, v3);
234  m_errorRateModel.Set (n4, v4);
235  m_errorRateModel.Set (n5, v5);
236  m_errorRateModel.Set (n6, v6);
237  m_errorRateModel.Set (n7, v7);
238 }
239 
242 {
245  phy->SetErrorRateModel (error);
246  phy->SetChannel (m_channel);
247  phy->SetDevice (device);
248  return phy;
249 }
250 
251 static void
254  Ptr<const Packet> packet,
255  uint16_t channelFreqMhz,
256  uint16_t channelNumber,
257  uint32_t rate,
258  WifiPreamble preamble,
259  WifiTxVector txVector,
260  struct mpduInfo aMpdu)
261 {
262  uint32_t dlt = file->GetDataLinkType ();
263 
264  switch (dlt)
265  {
267  file->Write (Simulator::Now (), packet);
268  return;
270  {
271  NS_FATAL_ERROR ("PcapSniffTxEvent(): DLT_PRISM_HEADER not implemented");
272  return;
273  }
275  {
276  Ptr<Packet> p = packet->Copy ();
277  RadiotapHeader header;
278  uint8_t frameFlags = RadiotapHeader::FRAME_FLAG_NONE;
279  header.SetTsft (Simulator::Now ().GetMicroSeconds ());
280 
281  //Our capture includes the FCS, so we set the flag to say so.
283 
284  if (preamble == WIFI_PREAMBLE_SHORT)
285  {
287  }
288 
289  if (txVector.IsShortGuardInterval ())
290  {
292  }
293 
294  header.SetFrameFlags (frameFlags);
295  header.SetRate (rate);
296 
297  uint16_t channelFlags = 0;
298  switch (rate)
299  {
300  case 2: //1Mbps
301  case 4: //2Mbps
302  case 10: //5Mbps
303  case 22: //11Mbps
304  channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK;
305  break;
306 
307  default:
308  channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM;
309  break;
310  }
311 
312  if (channelFreqMhz < 2500)
313  {
315  }
316  else
317  {
319  }
320 
321  header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags);
322 
323  if (preamble == WIFI_PREAMBLE_HT_MF || preamble == WIFI_PREAMBLE_HT_GF || preamble == WIFI_PREAMBLE_NONE)
324  {
325  uint8_t mcsRate = 0;
326  uint8_t mcsKnown = RadiotapHeader::MCS_KNOWN_NONE;
327  uint8_t mcsFlags = RadiotapHeader::MCS_FLAGS_NONE;
328 
330  mcsRate = rate - 128;
331 
333  if (txVector.GetChannelWidth () == 40)
334  {
336  }
337 
339  if (txVector.IsShortGuardInterval ())
340  {
342  }
343 
345  if (preamble == WIFI_PREAMBLE_HT_GF)
346  {
348  }
349 
350  mcsKnown |= RadiotapHeader::MCS_KNOWN_NESS;
351  if (txVector.GetNess () & 0x01) //bit 1
352  {
354  }
355  if (txVector.GetNess () & 0x02) //bit 2
356  {
358  }
359 
360  mcsKnown |= RadiotapHeader::MCS_KNOWN_FEC_TYPE; //only BCC is currently supported
361 
362  mcsKnown |= RadiotapHeader::MCS_KNOWN_STBC;
363  if (txVector.IsStbc ())
364  {
366  }
367 
368  header.SetMcsFields (mcsKnown, mcsFlags, mcsRate);
369  }
370 
371  if (txVector.IsAggregation ())
372  {
373  uint16_t ampduStatusFlags = RadiotapHeader::A_MPDU_STATUS_NONE;
374  ampduStatusFlags |= RadiotapHeader::A_MPDU_STATUS_LAST_KNOWN;
375  /* For PCAP file, MPDU Delimiter and Padding should be removed by the MAC Driver */
377  uint32_t extractedLength;
378  p->RemoveHeader (hdr);
379  extractedLength = hdr.GetLength ();
380  p = p->CreateFragment (0, static_cast<uint32_t> (extractedLength));
381  if (aMpdu.type == LAST_MPDU_IN_AGGREGATE || (hdr.GetEof () == true && hdr.GetLength () > 0))
382  {
383  ampduStatusFlags |= RadiotapHeader::A_MPDU_STATUS_LAST;
384  }
385  header.SetAmpduStatus (aMpdu.mpduRefNumber, ampduStatusFlags, hdr.GetCrc ());
386  }
387 
388  if (preamble == WIFI_PREAMBLE_VHT)
389  {
390  uint16_t vhtKnown = RadiotapHeader::VHT_KNOWN_NONE;
391  uint8_t vhtFlags = RadiotapHeader::VHT_FLAGS_NONE;
392  uint8_t vhtBandwidth = 0;
393  uint8_t vhtMcsNss[4] = {0,0,0,0};
394  uint8_t vhtCoding = 0;
395  uint8_t vhtGroupId = 0;
396  uint16_t vhtPartialAid = 0;
397 
398  vhtKnown |= RadiotapHeader::VHT_KNOWN_STBC;
399  if (txVector.IsStbc ())
400  {
401  vhtFlags |= RadiotapHeader::VHT_FLAGS_STBC;
402  }
403 
405  if (txVector.IsShortGuardInterval ())
406  {
408  }
409 
410  vhtKnown |= RadiotapHeader::VHT_KNOWN_BEAMFORMED; //Beamforming is currently not supported
411 
413  //not all bandwidth values are currently supported
414  if (txVector.GetChannelWidth () == 40)
415  {
416  vhtBandwidth = 1;
417  }
418  else if (txVector.GetChannelWidth () == 80)
419  {
420  vhtBandwidth = 4;
421  }
422  else if (txVector.GetChannelWidth () == 160)
423  {
424  vhtBandwidth = 11;
425  }
426 
427  //only SU PPDUs are currently supported
428  vhtMcsNss[0] |= (txVector.GetNss () & 0x0f);
429  vhtMcsNss[0] |= (((rate - 128) << 4) & 0xf0);
430 
431  header.SetVhtFields (vhtKnown, vhtFlags, vhtBandwidth, vhtMcsNss, vhtCoding, vhtGroupId, vhtPartialAid);
432  }
433 
434  p->AddHeader (header);
435  file->Write (Simulator::Now (), p);
436  return;
437  }
438  default:
439  NS_ABORT_MSG ("PcapSniffTxEvent(): Unexpected data link type " << dlt);
440  }
441 }
442 
443 static void
446  Ptr<const Packet> packet,
447  uint16_t channelFreqMhz,
448  uint16_t channelNumber,
449  uint32_t rate,
450  WifiPreamble preamble,
451  WifiTxVector txVector,
452  struct mpduInfo aMpdu,
453  struct signalNoiseDbm signalNoise)
454 {
455  uint32_t dlt = file->GetDataLinkType ();
456 
457  switch (dlt)
458  {
460  file->Write (Simulator::Now (), packet);
461  return;
463  {
464  NS_FATAL_ERROR ("PcapSniffRxEvent(): DLT_PRISM_HEADER not implemented");
465  return;
466  }
468  {
469  Ptr<Packet> p = packet->Copy ();
470  RadiotapHeader header;
471  uint8_t frameFlags = RadiotapHeader::FRAME_FLAG_NONE;
472  header.SetTsft (Simulator::Now ().GetMicroSeconds ());
473 
474  //Our capture includes the FCS, so we set the flag to say so.
476 
477  if (preamble == WIFI_PREAMBLE_SHORT)
478  {
480  }
481 
482  if (txVector.IsShortGuardInterval ())
483  {
485  }
486 
487  header.SetFrameFlags (frameFlags);
488  header.SetRate (rate);
489 
490  uint16_t channelFlags = 0;
491  switch (rate)
492  {
493  case 2: //1Mbps
494  case 4: //2Mbps
495  case 10: //5Mbps
496  case 22: //11Mbps
497  channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK;
498  break;
499 
500  default:
501  channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM;
502  break;
503  }
504 
505  if (channelFreqMhz < 2500)
506  {
508  }
509  else
510  {
512  }
513 
514  header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags);
515 
516  header.SetAntennaSignalPower (signalNoise.signal);
517  header.SetAntennaNoisePower (signalNoise.noise);
518 
519  if (preamble == WIFI_PREAMBLE_HT_MF || preamble == WIFI_PREAMBLE_HT_GF || preamble == WIFI_PREAMBLE_NONE)
520  {
521  uint8_t mcsRate = 0;
522  uint8_t mcsKnown = RadiotapHeader::MCS_KNOWN_NONE;
523  uint8_t mcsFlags = RadiotapHeader::MCS_FLAGS_NONE;
524 
526  mcsRate = rate - 128;
527 
529  if (txVector.GetChannelWidth () == 40)
530  {
532  }
533 
535  if (txVector.IsShortGuardInterval ())
536  {
538  }
539 
541  if (preamble == WIFI_PREAMBLE_HT_GF)
542  {
544  }
545 
546  mcsKnown |= RadiotapHeader::MCS_KNOWN_NESS;
547  if (txVector.GetNess () & 0x01) //bit 1
548  {
550  }
551  if (txVector.GetNess () & 0x02) //bit 2
552  {
554  }
555 
556  mcsKnown |= RadiotapHeader::MCS_KNOWN_FEC_TYPE; //only BCC is currently supported
557 
558  mcsKnown |= RadiotapHeader::MCS_KNOWN_STBC;
559  if (txVector.IsStbc ())
560  {
562  }
563 
564  header.SetMcsFields (mcsKnown, mcsFlags, mcsRate);
565  }
566 
567  if (txVector.IsAggregation ())
568  {
569  uint16_t ampduStatusFlags = RadiotapHeader::A_MPDU_STATUS_NONE;
571  ampduStatusFlags |= RadiotapHeader::A_MPDU_STATUS_LAST_KNOWN;
572  /* For PCAP file, MPDU Delimiter and Padding should be removed by the MAC Driver */
574  uint32_t extractedLength;
575  p->RemoveHeader (hdr);
576  extractedLength = hdr.GetLength ();
577  p = p->CreateFragment (0, static_cast<uint32_t> (extractedLength));
578  if (aMpdu.type == LAST_MPDU_IN_AGGREGATE || (hdr.GetEof () == true && hdr.GetLength () > 0))
579  {
580  ampduStatusFlags |= RadiotapHeader::A_MPDU_STATUS_LAST;
581  }
582  header.SetAmpduStatus (aMpdu.mpduRefNumber, ampduStatusFlags, hdr.GetCrc ());
583  }
584 
585  if (preamble == WIFI_PREAMBLE_VHT)
586  {
587  uint16_t vhtKnown = RadiotapHeader::VHT_KNOWN_NONE;
588  uint8_t vhtFlags = RadiotapHeader::VHT_FLAGS_NONE;
589  uint8_t vhtBandwidth = 0;
590  uint8_t vhtMcsNss[4] = {0,0,0,0};
591  uint8_t vhtCoding = 0;
592  uint8_t vhtGroupId = 0;
593  uint16_t vhtPartialAid = 0;
594 
595  vhtKnown |= RadiotapHeader::VHT_KNOWN_STBC;
596  if (txVector.IsStbc ())
597  {
598  vhtFlags |= RadiotapHeader::VHT_FLAGS_STBC;
599  }
600 
602  if (txVector.IsShortGuardInterval ())
603  {
605  }
606 
607  vhtKnown |= RadiotapHeader::VHT_KNOWN_BEAMFORMED; //Beamforming is currently not supported
608 
610  //not all bandwidth values are currently supported
611  if (txVector.GetChannelWidth () == 40)
612  {
613  vhtBandwidth = 1;
614  }
615  else if (txVector.GetChannelWidth () == 80)
616  {
617  vhtBandwidth = 4;
618  }
619  else if (txVector.GetChannelWidth () == 160)
620  {
621  vhtBandwidth = 11;
622  }
623 
624  //only SU PPDUs are currently supported
625  vhtMcsNss[0] |= (txVector.GetNss () & 0x0f);
626  vhtMcsNss[0] |= (((rate - 128) << 4) & 0xf0);
627 
628  header.SetVhtFields (vhtKnown, vhtFlags, vhtBandwidth, vhtMcsNss, vhtCoding, vhtGroupId, vhtPartialAid);
629  }
630 
631  p->AddHeader (header);
632  file->Write (Simulator::Now (), p);
633  return;
634  }
635  default:
636  NS_ABORT_MSG ("PcapSniffRxEvent(): Unexpected data link type " << dlt);
637  }
638 }
639 
640 void
642 {
643  switch (dlt)
644  {
645  case DLT_IEEE802_11:
647  return;
648  case DLT_PRISM_HEADER:
650  return;
653  return;
654  default:
655  NS_ABORT_MSG ("YansWifiPhyHelper::SetPcapFormat(): Unexpected format");
656  }
657 }
658 
659 uint32_t
661 {
662  return m_pcapDlt;
663 }
664 
665 void
666 YansWifiPhyHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous, bool explicitFilename)
667 {
668  //All of the Pcap enable functions vector through here including the ones
669  //that are wandering through all of devices on perhaps all of the nodes in
670  //the system. We can only deal with devices of type WifiNetDevice.
671  Ptr<WifiNetDevice> device = nd->GetObject<WifiNetDevice> ();
672  if (device == 0)
673  {
674  NS_LOG_INFO ("YansWifiHelper::EnablePcapInternal(): Device " << &device << " not of type ns3::WifiNetDevice");
675  return;
676  }
677 
678  Ptr<WifiPhy> phy = device->GetPhy ();
679  NS_ABORT_MSG_IF (phy == 0, "YansWifiPhyHelper::EnablePcapInternal(): Phy layer in WifiNetDevice must be set");
680 
681  PcapHelper pcapHelper;
682 
683  std::string filename;
684  if (explicitFilename)
685  {
686  filename = prefix;
687  }
688  else
689  {
690  filename = pcapHelper.GetFilenameFromDevice (prefix, device);
691  }
692 
693  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, m_pcapDlt);
694 
695  phy->TraceConnectWithoutContext ("MonitorSnifferTx", MakeBoundCallback (&PcapSniffTxEvent, file));
696  phy->TraceConnectWithoutContext ("MonitorSnifferRx", MakeBoundCallback (&PcapSniffRxEvent, file));
697 }
698 
699 void
702  std::string prefix,
703  Ptr<NetDevice> nd,
704  bool explicitFilename)
705 {
706  //All of the ascii enable functions vector through here including the ones
707  //that are wandering through all of devices on perhaps all of the nodes in
708  //the system. We can only deal with devices of type WifiNetDevice.
709  Ptr<WifiNetDevice> device = nd->GetObject<WifiNetDevice> ();
710  if (device == 0)
711  {
712  NS_LOG_INFO ("YansWifiHelper::EnableAsciiInternal(): Device " << device << " not of type ns3::WifiNetDevice");
713  return;
714  }
715 
716  //Our trace sinks are going to use packet printing, so we have to make sure
717  //that is turned on.
719 
720  uint32_t nodeid = nd->GetNode ()->GetId ();
721  uint32_t deviceid = nd->GetIfIndex ();
722  std::ostringstream oss;
723 
724  //If we are not provided an OutputStreamWrapper, we are expected to create
725  //one using the usual trace filename conventions and write our traces
726  //without a context since there will be one file per context and therefore
727  //the context would be redundant.
728  if (stream == 0)
729  {
730  //Set up an output stream object to deal with private ofstream copy
731  //constructor and lifetime issues. Let the helper decide the actual
732  //name of the file given the prefix.
733  AsciiTraceHelper asciiTraceHelper;
734 
735  std::string filename;
736  if (explicitFilename)
737  {
738  filename = prefix;
739  }
740  else
741  {
742  filename = asciiTraceHelper.GetFilenameFromDevice (prefix, device);
743  }
744 
745  Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
746  //We could go poking through the phy and the state looking for the
747  //correct trace source, but we can let Config deal with that with
748  //some search cost. Since this is presumably happening at topology
749  //creation time, it doesn't seem much of a price to pay.
750  oss.str ("");
751  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk";
753 
754  oss.str ("");
755  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx";
757 
758  return;
759  }
760 
761  //If we are provided an OutputStreamWrapper, we are expected to use it, and
762  //to provide a context. We are free to come up with our own context if we
763  //want, and use the AsciiTraceHelper Hook*WithContext functions, but for
764  //compatibility and simplicity, we just use Config::Connect and let it deal
765  //with coming up with a context.
766  oss.str ("");
767  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk";
769 
770  oss.str ("");
771  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx";
773 }
774 
775 } //namespace ns3
void AddPropagationLoss(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())
uint16_t GetLength(void) const
Return the length field.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
tuple channel
Definition: third.py:85
uint32_t GetPcapDataLinkType(void) const
Get the data link type of PCAP traces to be used.
Manage ASCII trace files for device models.
Definition: trace-helper.h:155
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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())
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetErrorRateModel(Ptr< ErrorRateModel > rate)
Sets the error rate model.
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)
Definition: wave-helper.cc:78
void SetNext(Ptr< PropagationLossModel > next)
Enables a chain of loss models to act on the signal.
Ptr< YansWifiChannel > Create(void) const
Radiotap header implementation.
Make it easy to create and manage PHY objects for the yans model.
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
Hold a value for an Attribute.
Definition: attribute.h:68
enum mpduType type
Definition: wifi-phy.h:63
Manage pcap files for device models.
Definition: trace-helper.h:38
void Write(Time t, Ptr< const Packet > p)
Write the next packet to file.
Include Prism monitor mode information.
Callback< R > MakeBoundCallback(R(*fnPtr)(TX), ARG a1)
Make Callbacks with one bound argument.
Definition: callback.h:1677
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
void SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
This frame is the last subframe.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
bool IsShortGuardInterval(void) const
virtual void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
Enable ascii trace output on the indicated net device.
static void AsciiPhyReceiveSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, double snr, WifiMode mode, enum WifiPreamble preamble)
Definition: wave-helper.cc:65
#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)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:145
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 Set(std::string name, const AttributeValue &v)
void SetAntennaNoisePower(double noise)
Set the RF noise power at the antenna as a decibel difference from an arbitrary, fixed reference...
static YansWifiPhyHelper Default(void)
Create a phy helper in a default working state.
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...
void SetTsft(uint64_t tsft)
Set the Time Synchronization Function Timer (TSFT) value.
YansWifiChannelHelper()
Create a channel helper without any parameter set.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:99
Include Radiotap link layer information.
the interface for Wifi's error models
Set if all spatial streams of all users have space-time block coding.
IEEE 802.11 Wireless LAN headers on packets.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Definition: wifi-preamble.h:30
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
Definition: packet.cc:228
Frame sent/received with short preamble.
void SetChannel(Ptr< YansWifiChannel > channel)
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
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 ...
tuple phy
Definition: third.py:86
static void EnablePrinting(void)
Enable printing packets metadata.
Definition: packet.cc:535
uint32_t mpduRefNumber
Definition: wifi-phy.h:64
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetChannelFrequencyAndFlags(uint16_t frequency, uint16_t flags)
Set the transmit/receive channel frequency and flags.
uint8_t GetNess(void) const
uint32_t GetChannelWidth(void) const
uint8_t GetCrc(void) const
Return the CRC field.
Introspection did not find any typical Config paths.
calculate a propagation delay.
Hold together all Wifi-related objects.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
Definition: config.cc:824
YansWifiPhyHelper()
Create a phy helper without any parameter set.
Ness known (Number of extension spatial streams)
Beamformed known/applicable (this flag should be set to zero for MU PPDUs).
bool IsStbc(void) const
Check if STBC is used or not.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:835
void SetChannel(Ptr< YansWifiChannel > channel)
Set the YansWifiChannel this YansWifiPhy is to be connected to.
void SetFrameFlags(uint8_t flags)
Set the frame flags of the transmitted or received frame.
Ness data - bit 1 (MSB) of Number of extension spatial streams.
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.
Space-time block coding (1 if all spatial streams of all users have STBC, 0 otherwise).
ObjectFactory m_errorRateModel
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)
Definition: wave-helper.cc:282
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:299
Every class exported by the ns3 library is enclosed in the ns3 namespace.
802.11 PHY layer modelThis PHY implements a model of 802.11a.
Definition: yans-wifi-phy.h:66
Delimiter CRC value known: the delimiter CRC value field is valid.
Frame used short guard interval (HT)
virtual void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
Enable pcap output the indicated net device.
Ptr< YansWifiChannel > m_channel
Last subframe is known (should be set for all subframes in an A-MPDU)
void SetMcsFields(uint8_t known, uint8_t flags, uint8_t mcs)
Set the MCS fields.
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
manage and create wifi channel objects for the yans model.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
void SetVhtFields(uint16_t known, uint8_t flags, uint8_t bandwidth, uint8_t mcs_nss[4], uint8_t coding, uint8_t group_id, uint16_t partial_aid)
Set the VHT fields.
Instantiate subclasses of ns3::Object.
uint8_t GetNss(void) const
Models the propagation loss through a transmission medium.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
virtual Ptr< WifiPhy > Create(Ptr< Node > node, Ptr< NetDevice > device) const
Default: 20 MHz, long guard interval, mixed HT format and BCC FEC type.
Ptr< PcapFileWrapper > CreateFile(std::string filename, std::ios::openmode filemode, uint32_t dataLinkType, uint32_t snapLen=std::numeric_limits< uint32_t >::max(), int32_t tzCorrection=0)
Create and initialize a pcap file.
Definition: trace-helper.cc:49
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)
Definition: wave-helper.cc:90
void SetDevice(Ptr< NetDevice > device)
Sets the device this PHY is associated with.
Ness - bit 0 (LSB) of Number of extension spatial streams.
void SetPropagationDelay(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())
std::vector< ObjectFactory > m_propagationLoss
void SetAmpduStatus(uint32_t referenceNumber, uint16_t flags, uint8_t crc)
Set the A-MPDU status fields.
bool GetEof(void) const
Return the EOF field.
static void AsciiPhyTransmitSinkWithContext(Ptr< OutputStreamWrapper > stream, std::string context, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
Definition: wave-helper.cc:40
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
SupportedPcapDataLinkTypes
An enumeration of the pcap data link types (DLTs) which this helper supports.
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:257
int64_t AssignStreams(Ptr< YansWifiChannel > c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the channel.
void SetAntennaSignalPower(double signal)
Set the RF signal power at the antenna as a decibel difference from an arbitrary, fixed reference...
The MPDU is the last aggregate in an A-MPDU.
Definition: wifi-phy.h:52
static void AsciiPhyTransmitSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
Definition: wave-helper.cc:53