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 () == 40000000)
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;
375  ampduStatusFlags |= RadiotapHeader::A_MPDU_STATUS_LAST_KNOWN;
376  /* For PCAP file, MPDU Delimiter and Padding should be removed by the MAC Driver */
378  uint32_t extractedLength;
379  p->RemoveHeader (hdr);
380  extractedLength = hdr.GetLength ();
381  p = p->CreateFragment (0, static_cast<uint32_t> (extractedLength));
382  if (aMpdu.packetType == 2 || (hdr.GetEof () == true && hdr.GetLength () > 0))
383  {
384  ampduStatusFlags |= RadiotapHeader::A_MPDU_STATUS_LAST;
385  }
386  header.SetAmpduStatus (aMpdu.referenceNumber, ampduStatusFlags, hdr.GetCrc ());
387  }
388 
389  if (preamble == WIFI_PREAMBLE_VHT)
390  {
391  uint16_t vhtKnown = RadiotapHeader::VHT_KNOWN_NONE;
392  uint8_t vhtFlags = RadiotapHeader::VHT_FLAGS_NONE;
393  uint8_t vhtBandwidth = 0;
394  uint8_t vhtMcsNss[4] = {0,0,0,0};
395  uint8_t vhtCoding = 0;
396  uint8_t vhtGroupId = 0;
397  uint16_t vhtPartialAid = 0;
398 
399  vhtKnown |= RadiotapHeader::VHT_KNOWN_STBC;
400  if (txVector.IsStbc ())
401  {
402  vhtFlags |= RadiotapHeader::VHT_FLAGS_STBC;
403  }
404 
406  if (txVector.IsShortGuardInterval ())
407  {
409  }
410 
411  vhtKnown |= RadiotapHeader::VHT_KNOWN_BEAMFORMED; //Beamforming is currently not supported
412 
414  //not all bandwidth values are currently supported
415  if (txVector.GetChannelWidth () == 40000000)
416  {
417  vhtBandwidth = 1;
418  }
419  else if (txVector.GetChannelWidth () == 80000000)
420  {
421  vhtBandwidth = 4;
422  }
423  else if (txVector.GetChannelWidth () == 160000000)
424  {
425  vhtBandwidth = 11;
426  }
427 
428  //only SU PPDUs are currently supported
429  vhtMcsNss[0] |= (txVector.GetNss () & 0x0f);
430  vhtMcsNss[0] |= (((rate - 128) << 4) & 0xf0);
431 
432  header.SetVhtFields (vhtKnown, vhtFlags, vhtBandwidth, vhtMcsNss, vhtCoding, vhtGroupId, vhtPartialAid);
433  }
434 
435  p->AddHeader (header);
436  file->Write (Simulator::Now (), p);
437  return;
438  }
439  default:
440  NS_ABORT_MSG ("PcapSniffTxEvent(): Unexpected data link type " << dlt);
441  }
442 }
443 
444 static void
447  Ptr<const Packet> packet,
448  uint16_t channelFreqMhz,
449  uint16_t channelNumber,
450  uint32_t rate,
451  WifiPreamble preamble,
452  WifiTxVector txVector,
453  struct mpduInfo aMpdu,
454  struct signalNoiseDbm signalNoise)
455 {
456  uint32_t dlt = file->GetDataLinkType ();
457 
458  switch (dlt)
459  {
461  file->Write (Simulator::Now (), packet);
462  return;
464  {
465  NS_FATAL_ERROR ("PcapSniffRxEvent(): DLT_PRISM_HEADER not implemented");
466  return;
467  }
469  {
470  Ptr<Packet> p = packet->Copy ();
471  RadiotapHeader header;
472  uint8_t frameFlags = RadiotapHeader::FRAME_FLAG_NONE;
473  header.SetTsft (Simulator::Now ().GetMicroSeconds ());
474 
475  //Our capture includes the FCS, so we set the flag to say so.
477 
478  if (preamble == WIFI_PREAMBLE_SHORT)
479  {
481  }
482 
483  if (txVector.IsShortGuardInterval ())
484  {
486  }
487 
488  header.SetFrameFlags (frameFlags);
489  header.SetRate (rate);
490 
491  uint16_t channelFlags = 0;
492  switch (rate)
493  {
494  case 2: //1Mbps
495  case 4: //2Mbps
496  case 10: //5Mbps
497  case 22: //11Mbps
498  channelFlags |= RadiotapHeader::CHANNEL_FLAG_CCK;
499  break;
500 
501  default:
502  channelFlags |= RadiotapHeader::CHANNEL_FLAG_OFDM;
503  break;
504  }
505 
506  if (channelFreqMhz < 2500)
507  {
509  }
510  else
511  {
513  }
514 
515  header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags);
516 
517  header.SetAntennaSignalPower (signalNoise.signal);
518  header.SetAntennaNoisePower (signalNoise.noise);
519 
520  if (preamble == WIFI_PREAMBLE_HT_MF || preamble == WIFI_PREAMBLE_HT_GF || preamble == WIFI_PREAMBLE_NONE)
521  {
522  uint8_t mcsRate = 0;
523  uint8_t mcsKnown = RadiotapHeader::MCS_KNOWN_NONE;
524  uint8_t mcsFlags = RadiotapHeader::MCS_FLAGS_NONE;
525 
527  mcsRate = rate - 128;
528 
530  if (txVector.GetChannelWidth () == 40000000)
531  {
533  }
534 
536  if (txVector.IsShortGuardInterval ())
537  {
539  }
540 
542  if (preamble == WIFI_PREAMBLE_HT_GF)
543  {
545  }
546 
547  mcsKnown |= RadiotapHeader::MCS_KNOWN_NESS;
548  if (txVector.GetNess () & 0x01) //bit 1
549  {
551  }
552  if (txVector.GetNess () & 0x02) //bit 2
553  {
555  }
556 
557  mcsKnown |= RadiotapHeader::MCS_KNOWN_FEC_TYPE; //only BCC is currently supported
558 
559  mcsKnown |= RadiotapHeader::MCS_KNOWN_STBC;
560  if (txVector.IsStbc ())
561  {
563  }
564 
565  header.SetMcsFields (mcsKnown, mcsFlags, mcsRate);
566  }
567 
568  if (txVector.IsAggregation ())
569  {
570  uint16_t ampduStatusFlags = 0;
572  ampduStatusFlags |= RadiotapHeader::A_MPDU_STATUS_LAST_KNOWN;
573  /* For PCAP file, MPDU Delimiter and Padding should be removed by the MAC Driver */
575  uint32_t extractedLength;
576  p->RemoveHeader (hdr);
577  extractedLength = hdr.GetLength ();
578  p = p->CreateFragment (0, static_cast<uint32_t> (extractedLength));
579  if (aMpdu.packetType == 2 || (hdr.GetEof () == true && hdr.GetLength () > 0))
580  {
581  ampduStatusFlags |= RadiotapHeader::A_MPDU_STATUS_LAST;
582  }
583  header.SetAmpduStatus (aMpdu.referenceNumber, ampduStatusFlags, hdr.GetCrc ());
584  }
585 
586  if (preamble == WIFI_PREAMBLE_VHT)
587  {
588  uint16_t vhtKnown = RadiotapHeader::VHT_KNOWN_NONE;
589  uint8_t vhtFlags = RadiotapHeader::VHT_FLAGS_NONE;
590  uint8_t vhtBandwidth = 0;
591  uint8_t vhtMcsNss[4] = {0,0,0,0};
592  uint8_t vhtCoding = 0;
593  uint8_t vhtGroupId = 0;
594  uint16_t vhtPartialAid = 0;
595 
596  vhtKnown |= RadiotapHeader::VHT_KNOWN_STBC;
597  if (txVector.IsStbc ())
598  {
599  vhtFlags |= RadiotapHeader::VHT_FLAGS_STBC;
600  }
601 
603  if (txVector.IsShortGuardInterval ())
604  {
606  }
607 
608  vhtKnown |= RadiotapHeader::VHT_KNOWN_BEAMFORMED; //Beamforming is currently not supported
609 
611  //not all bandwidth values are currently supported
612  if (txVector.GetChannelWidth () == 40000000)
613  {
614  vhtBandwidth = 1;
615  }
616  else if (txVector.GetChannelWidth () == 80000000)
617  {
618  vhtBandwidth = 4;
619  }
620  else if (txVector.GetChannelWidth () == 160000000)
621  {
622  vhtBandwidth = 11;
623  }
624 
625  //only SU PPDUs are currently supported
626  vhtMcsNss[0] |= (txVector.GetNss () & 0x0f);
627  vhtMcsNss[0] |= (((rate - 128) << 4) & 0xf0);
628 
629  header.SetVhtFields (vhtKnown, vhtFlags, vhtBandwidth, vhtMcsNss, vhtCoding, vhtGroupId, vhtPartialAid);
630  }
631 
632  p->AddHeader (header);
633  file->Write (Simulator::Now (), p);
634  return;
635  }
636  default:
637  NS_ABORT_MSG ("PcapSniffRxEvent(): Unexpected data link type " << dlt);
638  }
639 }
640 
641 void
643 {
644  switch (dlt)
645  {
646  case DLT_IEEE802_11:
648  return;
649  case DLT_PRISM_HEADER:
651  return;
654  return;
655  default:
656  NS_ABORT_MSG ("YansWifiPhyHelper::SetPcapFormat(): Unexpected format");
657  }
658 }
659 
660 uint32_t
662 {
663  return m_pcapDlt;
664 }
665 
666 void
667 YansWifiPhyHelper::EnablePcapInternal (std::string prefix, Ptr<NetDevice> nd, bool promiscuous, bool explicitFilename)
668 {
669  //All of the Pcap enable functions vector through here including the ones
670  //that are wandering through all of devices on perhaps all of the nodes in
671  //the system. We can only deal with devices of type WifiNetDevice.
672  Ptr<WifiNetDevice> device = nd->GetObject<WifiNetDevice> ();
673  if (device == 0)
674  {
675  NS_LOG_INFO ("YansWifiHelper::EnablePcapInternal(): Device " << &device << " not of type ns3::WifiNetDevice");
676  return;
677  }
678 
679  Ptr<WifiPhy> phy = device->GetPhy ();
680  NS_ABORT_MSG_IF (phy == 0, "YansWifiPhyHelper::EnablePcapInternal(): Phy layer in WifiNetDevice must be set");
681 
682  PcapHelper pcapHelper;
683 
684  std::string filename;
685  if (explicitFilename)
686  {
687  filename = prefix;
688  }
689  else
690  {
691  filename = pcapHelper.GetFilenameFromDevice (prefix, device);
692  }
693 
694  Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out, m_pcapDlt);
695 
696  phy->TraceConnectWithoutContext ("MonitorSnifferTx", MakeBoundCallback (&PcapSniffTxEvent, file));
697  phy->TraceConnectWithoutContext ("MonitorSnifferRx", MakeBoundCallback (&PcapSniffRxEvent, file));
698 }
699 
700 void
703  std::string prefix,
704  Ptr<NetDevice> nd,
705  bool explicitFilename)
706 {
707  //All of the ascii enable functions vector through here including the ones
708  //that are wandering through all of devices on perhaps all of the nodes in
709  //the system. We can only deal with devices of type WifiNetDevice.
710  Ptr<WifiNetDevice> device = nd->GetObject<WifiNetDevice> ();
711  if (device == 0)
712  {
713  NS_LOG_INFO ("YansWifiHelper::EnableAsciiInternal(): Device " << device << " not of type ns3::WifiNetDevice");
714  return;
715  }
716 
717  //Our trace sinks are going to use packet printing, so we have to make sure
718  //that is turned on.
720 
721  uint32_t nodeid = nd->GetNode ()->GetId ();
722  uint32_t deviceid = nd->GetIfIndex ();
723  std::ostringstream oss;
724 
725  //If we are not provided an OutputStreamWrapper, we are expected to create
726  //one using the usual trace filename conventions and write our traces
727  //without a context since there will be one file per context and therefore
728  //the context would be redundant.
729  if (stream == 0)
730  {
731  //Set up an output stream object to deal with private ofstream copy
732  //constructor and lifetime issues. Let the helper decide the actual
733  //name of the file given the prefix.
734  AsciiTraceHelper asciiTraceHelper;
735 
736  std::string filename;
737  if (explicitFilename)
738  {
739  filename = prefix;
740  }
741  else
742  {
743  filename = asciiTraceHelper.GetFilenameFromDevice (prefix, device);
744  }
745 
746  Ptr<OutputStreamWrapper> theStream = asciiTraceHelper.CreateFileStream (filename);
747  //We could go poking through the phy and the state looking for the
748  //correct trace source, but we can let Config deal with that with
749  //some search cost. Since this is presumably happening at topology
750  //creation time, it doesn't seem much of a price to pay.
751  oss.str ("");
752  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk";
754 
755  oss.str ("");
756  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx";
758 
759  return;
760  }
761 
762  //If we are provided an OutputStreamWrapper, we are expected to use it, and
763  //to provide a context. We are free to come up with our own context if we
764  //want, and use the AsciiTraceHelper Hook*WithContext functions, but for
765  //compatibility and simplicity, we just use Config::Connect and let it deal
766  //with coming up with a context.
767  oss.str ("");
768  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/RxOk";
770 
771  oss.str ("");
772  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid << "/$ns3::WifiNetDevice/Phy/State/Tx";
774 }
775 
776 } //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:266
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
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:97
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:533
uint8_t packetType
Definition: wifi-phy.h:50
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:283
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:255
uint32_t referenceNumber
Definition: wifi-phy.h:51
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...
static void AsciiPhyTransmitSinkWithoutContext(Ptr< OutputStreamWrapper > stream, Ptr< const Packet > p, WifiMode mode, WifiPreamble preamble, uint8_t txLevel)
Definition: wave-helper.cc:53