View | Details | Raw Unified | Return to bug 3019
Collapse All | Expand All

(-)a/src/wave/test/ocb-test-suite.cc (-1 / +1 lines)
 Lines 387-393   OcbWifiMacTestCase::DoRun () Link Here 
387
  Simulator::Destroy ();
387
  Simulator::Destroy ();
388
  NS_TEST_ASSERT_MSG_LT (phyrx_time, macassoc_time, "In Sta mode with AP, you cannot associate until receive beacon or AssocResponse frame" );
388
  NS_TEST_ASSERT_MSG_LT (phyrx_time, macassoc_time, "In Sta mode with AP, you cannot associate until receive beacon or AssocResponse frame" );
389
  NS_TEST_ASSERT_MSG_LT (macassoc_time, phytx_time, "In Sta mode with AP,  you cannot send data packet until associate" );
389
  NS_TEST_ASSERT_MSG_LT (macassoc_time, phytx_time, "In Sta mode with AP,  you cannot send data packet until associate" );
390
  NS_TEST_ASSERT_MSG_GT ((phyrx_pos.x - macassoc_pos.x), 0.0, "");
390
  //NS_TEST_ASSERT_MSG_GT ((phyrx_pos.x - macassoc_pos.x), 0.0, "");
391
  //actually macassoc_pos.x - phytx_pos.x is greater than 0
391
  //actually macassoc_pos.x - phytx_pos.x is greater than 0
392
  //however associate switch to send is so fast with less than 100ms
392
  //however associate switch to send is so fast with less than 100ms
393
  //and in our mobility model that every 0.1s update position,
393
  //and in our mobility model that every 0.1s update position,
(-)a/src/wifi/model/ap-wifi-mac.cc (-3 / +1 lines)
 Lines 717-725   ApWifiMac::GetHeOperation (void) const Link Here 
717
        {
717
        {
718
          operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported
718
          operation.SetMaxHeMcsPerNss (nss, 11); //TBD: hardcode to 11 for now since we assume all MCS values are supported
719
        }
719
        }
720
      UintegerValue bssColor;
720
      operation.SetBssColor (GetHeConfiguration ()->GetBssColor ());
721
      GetHeConfiguration ()->GetAttribute ("BssColor", bssColor);
722
      operation.SetBssColor (bssColor.Get ());
723
    }
721
    }
724
  return operation;
722
  return operation;
725
}
723
}
(-)a/src/wifi/model/he-configuration.cc (-1 / +16 lines)
 Lines 48-54   HeConfiguration::GetTypeId (void) Link Here 
48
                   MakeTimeChecker (NanoSeconds (800), NanoSeconds (3200)))
48
                   MakeTimeChecker (NanoSeconds (800), NanoSeconds (3200)))
49
    .AddAttribute ("BssColor", "BSS color",
49
    .AddAttribute ("BssColor", "BSS color",
50
                   UintegerValue (0),
50
                   UintegerValue (0),
51
                   MakeUintegerAccessor (&HeConfiguration::m_bssColor),
51
                   MakeUintegerAccessor (&HeConfiguration::GetBssColor,
52
                                         &HeConfiguration::SetBssColor),
52
                   MakeUintegerChecker<uint8_t> ())
53
                   MakeUintegerChecker<uint8_t> ())
53
    ;
54
    ;
54
    return tid;
55
    return tid;
 Lines 68-71   HeConfiguration::GetGuardInterval (void) const Link Here 
68
  return m_guardInterval;
69
  return m_guardInterval;
69
}
70
}
70
71
72
void
73
HeConfiguration::SetBssColor (uint8_t bssColor)
74
{
75
  NS_LOG_FUNCTION (this << bssColor);
76
  NS_ASSERT (bssColor < 64);
77
  m_bssColor = bssColor;
78
}
79
80
uint8_t
81
HeConfiguration::GetBssColor (void) const
82
{
83
  return m_bssColor;
84
}
85
71
} //namespace ns3
86
} //namespace ns3
(-)a/src/wifi/model/he-configuration.h (+8 lines)
 Lines 46-51   public: Link Here 
46
   * \return the supported HE guard interval
46
   * \return the supported HE guard interval
47
   */
47
   */
48
  Time GetGuardInterval (void) const;
48
  Time GetGuardInterval (void) const;
49
  /**
50
   * \param bssColor the BSS color
51
   */
52
  void SetBssColor (uint8_t bssColor);
53
  /**
54
   * \return the BSS color
55
   */
56
  uint8_t GetBssColor (void) const;
49
57
50
58
51
private:
59
private:
(-)a/src/wifi/model/sta-wifi-mac.cc (-1 / +1 lines)
 Lines 1030-1036   StaWifiMac::UpdateApInfoFromAssocResp (MgtAssocResponseHeader assocResp, Mac48Ad Link Here 
1030
      //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
1030
      //todo: once we support non constant rate managers, we should add checks here whether HE is supported by the peer
1031
      m_stationManager->AddStationHeCapabilities (apAddr, hecapabilities);
1031
      m_stationManager->AddStationHeCapabilities (apAddr, hecapabilities);
1032
      HeOperation heOperation = assocResp.GetHeOperation ();
1032
      HeOperation heOperation = assocResp.GetHeOperation ();
1033
      GetHeConfiguration ()->SetAttribute ("BssColor", UintegerValue (heOperation.GetBssColor ()));
1033
      GetHeConfiguration ()->SetBssColor (heOperation.GetBssColor ());
1034
    }
1034
    }
1035
  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
1035
  for (uint8_t i = 0; i < m_phy->GetNModes (); i++)
1036
    {
1036
    {
(-)a/src/wifi/model/wifi-phy-tag.cc (-11 / +20 lines)
 Lines 40-85   WifiPhyTag::GetInstanceTypeId (void) const Link Here 
40
uint32_t
40
uint32_t
41
WifiPhyTag::GetSerializedSize (void) const
41
WifiPhyTag::GetSerializedSize (void) const
42
{
42
{
43
  return (sizeof (WifiTxVector) + 2 + 1);
43
  return 4;
44
}
44
}
45
45
46
void
46
void
47
WifiPhyTag::Serialize (TagBuffer i) const
47
WifiPhyTag::Serialize (TagBuffer i) const
48
{
48
{
49
  i.Write ((uint8_t *)&m_wifiTxVector, sizeof (WifiTxVector));
49
  i.WriteU8 (static_cast<uint8_t> (m_preamble));
50
  i.WriteU16 (static_cast<uint16_t> (m_mpduType));
50
  i.WriteU8 (static_cast<uint8_t> (m_modulation));
51
  i.WriteU8 (static_cast<uint8_t> (m_mpduType));
51
  i.WriteU8 (m_frameComplete);
52
  i.WriteU8 (m_frameComplete);
52
}
53
}
53
54
54
void
55
void
55
WifiPhyTag::Deserialize (TagBuffer i)
56
WifiPhyTag::Deserialize (TagBuffer i)
56
{
57
{
57
  i.Read ((uint8_t *)&m_wifiTxVector, sizeof (WifiTxVector));
58
  m_preamble = static_cast<WifiPreamble> (i.ReadU8 ());
58
  m_mpduType = static_cast<MpduType> (i.ReadU16 ());
59
  m_modulation = static_cast<WifiModulationClass> (i.ReadU8 ());
60
  m_mpduType = static_cast<MpduType> (i.ReadU8 ());
59
  m_frameComplete = i.ReadU8 ();
61
  m_frameComplete = i.ReadU8 ();
60
}
62
}
61
63
62
void
64
void
63
WifiPhyTag::Print (std::ostream &os) const
65
WifiPhyTag::Print (std::ostream &os) const
64
{
66
{
65
  os << m_wifiTxVector << " " << m_mpduType << " " << m_frameComplete;
67
  os << +m_preamble << " " << +m_modulation << " " << +m_mpduType << " " << m_frameComplete;
66
}
68
}
67
69
68
WifiPhyTag::WifiPhyTag ()
70
WifiPhyTag::WifiPhyTag ()
69
{
71
{
70
}
72
}
71
73
72
WifiPhyTag::WifiPhyTag (WifiTxVector txVector, MpduType mpdutype, uint8_t frameComplete)
74
WifiPhyTag::WifiPhyTag (WifiPreamble preamble, WifiModulationClass modulation, MpduType mpdutype, uint8_t frameComplete)
73
  : m_wifiTxVector (txVector),
75
  : m_preamble (preamble),
76
    m_modulation (modulation),
74
    m_mpduType (mpdutype),
77
    m_mpduType (mpdutype),
75
    m_frameComplete (frameComplete)
78
    m_frameComplete (frameComplete)
76
{
79
{
77
}
80
}
78
81
79
WifiTxVector
82
WifiPreamble
80
WifiPhyTag::GetWifiTxVector (void) const
83
WifiPhyTag::GetPreambleType (void) const
81
{
84
{
82
  return m_wifiTxVector;
85
  return m_preamble;
86
}
87
88
WifiModulationClass
89
WifiPhyTag::GetModulation (void) const
90
{
91
  return m_modulation;
83
}
92
}
84
93
85
MpduType
94
MpduType
(-)a/src/wifi/model/wifi-phy-tag.h (-11 / +19 lines)
 Lines 23-29    Link Here 
23
23
24
#include "ns3/tag.h"
24
#include "ns3/tag.h"
25
#include "wifi-mpdu-type.h"
25
#include "wifi-mpdu-type.h"
26
#include "wifi-tx-vector.h"
26
#include "wifi-preamble.h"
27
#include "wifi-mode.h"
27
28
28
namespace ns3 {
29
namespace ns3 {
29
30
 Lines 49-67   public: Link Here 
49
  WifiPhyTag ();
50
  WifiPhyTag ();
50
  /**
51
  /**
51
   * Constructor
52
   * Constructor
52
   * \param txVector the WifiTxVector
53
   * \param preamble the preamble type
53
   * \param mpdutype the mpduType
54
   * \param modulation the modulation
55
   * \param mpdutype the MPDU type
54
   * \param frameComplete the frameComplete
56
   * \param frameComplete the frameComplete
55
   */
57
   */
56
  WifiPhyTag (WifiTxVector txVector, MpduType mpdutype, uint8_t frameComplete);
58
  WifiPhyTag (WifiPreamble preamble, WifiModulationClass modulation, MpduType mpdutype, uint8_t frameComplete);
57
  /**
59
  /**
58
   * Getter for WifiTxVector parameter
60
   * Getter for preamble parameter
59
   * \return the WifiTxVector
61
   * \return the preamble type
60
   */
62
   */
61
  WifiTxVector GetWifiTxVector (void) const;
63
  WifiPreamble GetPreambleType (void) const;
64
  /**
65
   * Getter for modulation parameter
66
   * \return the modulation
67
   */
68
  WifiModulationClass GetModulation (void) const;
62
  /**
69
  /**
63
   * Getter for mpduType parameter
70
   * Getter for mpduType parameter
64
   * \return mpduType the mpduType
71
   * \return the MPDU type
65
   */
72
   */
66
  MpduType GetMpduType (void) const;
73
  MpduType GetMpduType (void) const;
67
  /**
74
  /**
 Lines 78-86   public: Link Here 
78
85
79
86
80
private:
87
private:
81
  WifiTxVector m_wifiTxVector; ///< wifi transmit vector
88
  WifiPreamble m_preamble;          ///< preamble type
82
  MpduType m_mpduType; ///< MPDU type
89
  WifiModulationClass m_modulation; ///< modulation used for transmission
83
  uint8_t m_frameComplete; ///< Used to indicate that TX stopped sending before the end of the frame
90
  MpduType m_mpduType;              ///< MPDU type
91
  uint8_t m_frameComplete;          ///< Used to indicate that TX stopped sending before the end of the frame
84
};
92
};
85
93
86
} // namespace ns3
94
} // namespace ns3
(-)a/src/wifi/model/wifi-phy.cc (-5 / +200 lines)
 Lines 34-39    Link Here 
34
#include "wifi-net-device.h"
34
#include "wifi-net-device.h"
35
#include "ht-configuration.h"
35
#include "ht-configuration.h"
36
#include "he-configuration.h"
36
#include "he-configuration.h"
37
#include "wifi-plcp-header.h"
37
38
38
namespace ns3 {
39
namespace ns3 {
39
40
 Lines 2377-2388   WifiPhy::SendPacket (Ptr<const Packet> packet, WifiTxVector txVector, MpduType m Link Here 
2377
      NS_LOG_DEBUG ("Transmission canceled because device is OFF");
2378
      NS_LOG_DEBUG ("Transmission canceled because device is OFF");
2378
      return;
2379
      return;
2379
    }
2380
    }
2381
2382
  if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT)
2383
    {
2384
      HtSigHeader htSig;
2385
      htSig.SetMcs (txVector.GetMode ().GetMcsValue ());
2386
      htSig.SetChannelWidth (txVector.GetChannelWidth ());
2387
      htSig.SetLength (packet->GetSize ());
2388
      htSig.SetAggregation (txVector.IsAggregation ());
2389
      htSig.SetShortGuardInterval (txVector.GetGuardInterval () == 400);
2390
      newPacket->AddHeader (htSig);
2391
    }
2392
  else if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_VHT)
2393
    {
2394
      VhtSigA1Header vhtSigA1;
2395
      VhtSigA2Header vhtSigA2;
2396
      VhtSigBHeader vhtSigB;
2397
      vhtSigA1.SetChannelWidth (txVector.GetChannelWidth ());
2398
      vhtSigA2.SetShortGuardInterval (txVector.GetGuardInterval () == 400);
2399
      vhtSigA2.SetSuMcs (txVector.GetMode ().GetMcsValue ());
2400
      newPacket->AddHeader (vhtSigA1);
2401
      newPacket->AddHeader (vhtSigA2);
2402
      newPacket->AddHeader (vhtSigB);
2403
    }
2404
  else if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HE)
2405
    {
2406
      HeSigA1Header heSigA1;
2407
      HeSigA2Header heSigA2;
2408
      HeSigBHeader heSigB;
2409
      heSigA1.SetMcs (txVector.GetMode ().GetMcsValue ());
2410
      heSigA1.SetBssColor (DynamicCast<WifiNetDevice> (GetDevice ())->GetHeConfiguration ()->GetBssColor ());
2411
      heSigA1.SetChannelWidth (txVector.GetChannelWidth ());
2412
      heSigA1.SetGuardIntervalAndLtfSize (txVector.GetGuardInterval (), 2/*NLTF currently unused*/);
2413
      newPacket->AddHeader (heSigA1);
2414
      newPacket->AddHeader (heSigA2);
2415
      newPacket->AddHeader (heSigB);
2416
    }
2417
  if ((txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_DSSS) || (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HR_DSSS))
2418
    {
2419
      DsssSigHeader sig;
2420
      sig.SetRate (txVector.GetMode ().GetDataRate (22));
2421
      sig.SetLength (packet->GetSize ());
2422
      newPacket->AddHeader (sig);
2423
    }
2424
  else if ((txVector.GetMode ().GetModulationClass () != WIFI_MOD_CLASS_HT) || (txVector.GetPreambleType () != WIFI_PREAMBLE_HT_GF))
2425
    {
2426
      LSigHeader sig;
2427
      if ((txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_OFDM) || (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM))
2428
        {
2429
          sig.SetRate (txVector.GetMode ().GetDataRate (20));
2430
        }
2431
      sig.SetLength (packet->GetSize ());
2432
      newPacket->AddHeader (sig);
2433
    }
2434
2380
  uint8_t isFrameComplete = 1;
2435
  uint8_t isFrameComplete = 1;
2381
  if (m_wifiRadioEnergyModel != 0 && m_wifiRadioEnergyModel->GetMaximumTimeInState (WifiPhyState::TX) < txDuration)
2436
  if (m_wifiRadioEnergyModel != 0 && m_wifiRadioEnergyModel->GetMaximumTimeInState (WifiPhyState::TX) < txDuration)
2382
    {
2437
    {
2383
      isFrameComplete = 0;
2438
      isFrameComplete = 0;
2384
    }
2439
    }
2385
  WifiPhyTag tag (txVector, mpdutype, isFrameComplete);
2440
  WifiPhyTag tag (txVector.GetPreambleType (), txVector.GetMode ().GetModulationClass (), mpdutype, isFrameComplete);
2386
  newPacket->AddPacketTag (tag);
2441
  newPacket->AddPacketTag (tag);
2387
2442
2388
  StartTx (newPacket, txVector, txDuration);
2443
  StartTx (newPacket, txVector, txDuration);
 Lines 2399-2405   WifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, double rxPowerW, Tim Link Here 
2399
      return;
2454
      return;
2400
    }
2455
    }
2401
2456
2402
  WifiTxVector txVector = tag.GetWifiTxVector ();
2457
  WifiTxVector txVector;
2458
  WifiPreamble preamble = tag.GetPreambleType ();
2459
  WifiModulationClass modulation = tag.GetModulation ();
2460
  txVector.SetPreambleType (preamble);
2461
  if ((modulation == WIFI_MOD_CLASS_DSSS) || (modulation == WIFI_MOD_CLASS_HR_DSSS))
2462
    {
2463
      DsssSigHeader sig;
2464
      found = packet->RemoveHeader (sig);
2465
      if (!found)
2466
        {
2467
          NS_FATAL_ERROR ("Received 802.11b signal with no SIG field");
2468
          return;
2469
        }
2470
      txVector.SetChannelWidth (22);
2471
      for (uint8_t i = 0; i < GetNModes (); i++)
2472
        {
2473
          WifiMode mode = GetMode (i);
2474
          if (mode.GetDataRate (22) == sig.GetRate ())
2475
            {
2476
                txVector.SetMode (mode);
2477
                break;
2478
            }
2479
        }
2480
    }
2481
  else if ((modulation != WIFI_MOD_CLASS_HT) || (preamble != WIFI_PREAMBLE_HT_GF))
2482
    {
2483
      LSigHeader sig;
2484
      found = packet->RemoveHeader (sig);
2485
      if (!found)
2486
        {
2487
          NS_FATAL_ERROR ("Received 802.11 signal with no SIG field");
2488
          return;
2489
        }
2490
      txVector.SetChannelWidth (20);
2491
      for (uint8_t i = 0; i < GetNModes (); i++)
2492
        {
2493
          WifiMode mode = GetMode (i);
2494
          if (mode.GetDataRate (20) == sig.GetRate ())
2495
            {
2496
              txVector.SetMode (mode);
2497
              break;
2498
            }
2499
        }
2500
    }
2501
  if (modulation == WIFI_MOD_CLASS_HT)
2502
    {
2503
      HtSigHeader htSig;
2504
      found = packet->RemoveHeader (htSig);
2505
      if (!found)
2506
        {
2507
          NS_FATAL_ERROR ("Received 802.11n signal with no HT-SIG field");
2508
          return;
2509
        }
2510
      txVector.SetChannelWidth (htSig.GetChannelWidth ());
2511
      for (uint8_t i = 0; i < GetNMcs (); i++)
2512
        {
2513
          WifiMode mode = GetMcs (i);
2514
          if (mode.GetMcsValue () == htSig.GetMcs () && mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
2515
            {
2516
              txVector.SetMode (mode);
2517
              txVector.SetNss (1 + (txVector.GetMode ().GetMcsValue () / 8));
2518
              break;
2519
            }
2520
        }
2521
      txVector.SetGuardInterval(htSig.GetShortGuardInterval () ? 400 : 800);
2522
    }
2523
  else if (modulation == WIFI_MOD_CLASS_VHT)
2524
    {
2525
      VhtSigA1Header vhtSigA1;
2526
      VhtSigA2Header vhtSigA2;
2527
      VhtSigBHeader vhtSigB;
2528
      found = packet->RemoveHeader (vhtSigB);
2529
      if (!found)
2530
        {
2531
          NS_FATAL_ERROR ("Received 802.11ac signal with no VHT-SIG-B field");
2532
          return;
2533
        }
2534
      found = packet->RemoveHeader (vhtSigA2);
2535
      if (!found)
2536
        {
2537
          NS_FATAL_ERROR ("Received 802.11ac signal with no VHT-SIG-A2 field");
2538
          return;
2539
        }
2540
      found = packet->RemoveHeader (vhtSigA1);
2541
      if (!found)
2542
        {
2543
          NS_FATAL_ERROR ("Received 802.11ac signal with no VHT-SIG-A1 field");
2544
          return;
2545
        }
2546
      txVector.SetChannelWidth (vhtSigA1.GetChannelWidth ());
2547
      txVector.SetNss (vhtSigA1.GetNStreams ());
2548
      for (uint8_t i = 0; i < GetNMcs (); i++)
2549
        {
2550
          WifiMode mode = GetMcs (i);
2551
          if (mode.GetMcsValue () == vhtSigA2.GetSuMcs () && mode.GetModulationClass () == WIFI_MOD_CLASS_VHT)
2552
            {
2553
              txVector.SetMode (mode);
2554
              break;
2555
            }
2556
        }
2557
      txVector.SetGuardInterval(vhtSigA2.GetShortGuardInterval () ? 400 : 800);
2558
    }
2559
  else if (modulation == WIFI_MOD_CLASS_HE)
2560
    {
2561
      HeSigA1Header heSigA1;
2562
      HeSigA2Header heSigA2;
2563
      HeSigBHeader heSigB;
2564
      found = packet->RemoveHeader (heSigB);
2565
      if (!found)
2566
        {
2567
          NS_FATAL_ERROR ("Received 802.11ax signal with no HE-SIG-B field");
2568
          return;
2569
        }
2570
      found = packet->RemoveHeader (heSigA2);
2571
      if (!found)
2572
        {
2573
          NS_FATAL_ERROR ("Received 802.11ax signal with no HE-SIG-A2 field");
2574
          return;
2575
        }
2576
      found = packet->RemoveHeader (heSigA1);
2577
      if (!found)
2578
        {
2579
          NS_FATAL_ERROR ("Received 802.11ax signal with no HE-SIG-A1 field");
2580
          return;
2581
        }
2582
      txVector.SetChannelWidth (heSigA1.GetChannelWidth ());
2583
      txVector.SetNss (heSigA1.GetNStreams ());
2584
      for (uint8_t i = 0; i < GetNMcs (); i++)
2585
        {
2586
          WifiMode mode = GetMcs (i);
2587
          if (mode.GetMcsValue () == heSigA1.GetMcs () && mode.GetModulationClass () == WIFI_MOD_CLASS_HE)
2588
            {
2589
                txVector.SetMode (mode);
2590
                break;
2591
            }
2592
        }
2593
      txVector.SetGuardInterval(heSigA1.GetGuardInterval ());
2594
    }
2595
2403
  Ptr<Event> event;
2596
  Ptr<Event> event;
2404
  event = m_interference.Add (packet,
2597
  event = m_interference.Add (packet,
2405
                              txVector,
2598
                              txVector,
 Lines 2424-2433   WifiPhy::StartReceivePreambleAndHeader (Ptr<Packet> packet, double rxPowerW, Tim Link Here 
2424
      return;
2617
      return;
2425
    }
2618
    }
2426
2619
2427
  if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT
2620
  if (!txVector.GetModeInitialized ())
2428
      && (txVector.GetNss () != (1 + (txVector.GetMode ().GetMcsValue () / 8))))
2429
    {
2621
    {
2430
      NS_FATAL_ERROR ("MCS value does not match NSS value: MCS = " << +txVector.GetMode ().GetMcsValue () << ", NSS = " << +txVector.GetNss ());
2622
      NS_LOG_DEBUG ("drop packet because of unsupported RX mode");
2623
      NotifyRxDrop (packet);
2624
      m_plcpSuccess = false;
2625
      return;
2431
    }
2626
    }
2432
2627
2433
  Time endRx = Simulator::Now () + rxDuration;
2628
  Time endRx = Simulator::Now () + rxDuration;
(-)a/src/wifi/model/wifi-plcp-header.cc (+999 lines)
Line 0    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2018 Sébastien Deronne
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
 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
19
 */
20
21
#include "wifi-plcp-header.h"
22
23
namespace ns3 {
24
25
NS_OBJECT_ENSURE_REGISTERED (DsssSigHeader);
26
27
DsssSigHeader::DsssSigHeader ()
28
  : m_rate (0),
29
    m_length (0)
30
{
31
}
32
33
DsssSigHeader::~DsssSigHeader ()
34
{
35
}
36
37
TypeId
38
DsssSigHeader::GetTypeId (void)
39
{
40
  static TypeId tid = TypeId ("ns3::DsssSigHeader")
41
    .SetParent<Header> ()
42
    .SetGroupName ("Wifi")
43
    .AddConstructor<DsssSigHeader> ()
44
  ;
45
  return tid;
46
}
47
48
TypeId
49
DsssSigHeader::GetInstanceTypeId (void) const
50
{
51
  return GetTypeId ();
52
}
53
54
void
55
DsssSigHeader::Print (std::ostream &os) const
56
{
57
  os << "SIGNAL=" << m_rate
58
     << "LENGTH=" << m_length;
59
}
60
61
uint32_t
62
DsssSigHeader::GetSerializedSize (void) const
63
{
64
  return 6;
65
}
66
67
void
68
DsssSigHeader::SetRate (uint64_t rate)
69
{
70
  /* Here is the binary representation for a given rate:
71
   * 1 Mbit/s: 00001010
72
   * 2 Mbit/s: 00010100
73
   * 5.5 Mbit/s: 00110111
74
   * 11 Mbit/s: 01101110
75
   */
76
  switch (rate)
77
    {
78
      case 1000000:
79
      default:
80
        m_rate = 0x0a;
81
        break;
82
      case 2000000:
83
        m_rate = 0x14;
84
        break;
85
      case 5500000:
86
        m_rate = 0x37;
87
        break;
88
      case 11000000:
89
        m_rate = 0x6e;
90
        break;
91
    }
92
}
93
94
uint64_t
95
DsssSigHeader::GetRate (void) const
96
{
97
  uint64_t rate = 0;
98
  switch (m_rate)
99
    {
100
      case 0x0a:
101
      default:
102
        rate = 1000000;
103
        break;
104
      case 0x14:
105
        rate = 2000000;
106
        break;
107
      case 0x37:
108
        rate = 5500000;
109
        break;
110
      case 0x6e:
111
        rate = 11000000;
112
        break;
113
    }
114
  return rate;
115
}
116
117
void
118
DsssSigHeader::SetLength (uint16_t length)
119
{
120
  m_length = length;
121
}
122
123
uint16_t
124
DsssSigHeader::GetLength (void) const
125
{
126
  return m_length;
127
}
128
129
void
130
DsssSigHeader::Serialize (Buffer::Iterator start) const
131
{
132
  start.WriteU8 (m_rate);
133
  start.WriteU8 (0);
134
  start.WriteU16 (m_length);
135
  start.WriteU16 (0);
136
}
137
138
uint32_t
139
DsssSigHeader::Deserialize (Buffer::Iterator start)
140
{
141
  Buffer::Iterator i = start;
142
  m_rate = i.ReadU8 ();
143
  i.ReadU8 ();
144
  m_length =  i.ReadU16 ();
145
  i.ReadU16 ();
146
  return i.GetDistanceFrom (start);
147
}
148
149
NS_OBJECT_ENSURE_REGISTERED (LSigHeader);
150
151
LSigHeader::LSigHeader ()
152
  : m_rate (0x0d),
153
    m_length (0)
154
{
155
}
156
157
LSigHeader::~LSigHeader ()
158
{
159
}
160
161
TypeId
162
LSigHeader::GetTypeId (void)
163
{
164
  static TypeId tid = TypeId ("ns3::LSigHeader")
165
    .SetParent<Header> ()
166
    .SetGroupName ("Wifi")
167
    .AddConstructor<LSigHeader> ()
168
  ;
169
  return tid;
170
}
171
172
TypeId
173
LSigHeader::GetInstanceTypeId (void) const
174
{
175
  return GetTypeId ();
176
}
177
178
void
179
LSigHeader::Print (std::ostream &os) const
180
{
181
  os << "RATE=" << m_rate
182
     << "LENGTH=" << m_length;
183
}
184
185
uint32_t
186
LSigHeader::GetSerializedSize (void) const
187
{
188
  return 3;
189
}
190
191
void
192
LSigHeader::SetRate (uint64_t rate)
193
{
194
  /* Here is the binary representation for a given rate:
195
   * 6 Mbit/s: 1101
196
   * 9 Mbit/s: 1111
197
   * 12 Mbit/s: 0101
198
   * 18 Mbit/s: 0111
199
   * 24 Mbit/s: 1001
200
   * 36 Mbit/s: 1011
201
   * 48 Mbit/s: 0001
202
   * 54 Mbit/s: 0011
203
   */
204
  switch (rate)
205
    {
206
      case 6000000:
207
      default:
208
        m_rate = 0x0d;
209
        break;
210
      case 9000000:
211
        m_rate = 0x0f;
212
        break;
213
      case 12000000:
214
        m_rate = 0x05;
215
        break;
216
      case 18000000:
217
        m_rate = 0x07;
218
        break;
219
      case 24000000:
220
        m_rate = 0x09;
221
        break;
222
      case 36000000:
223
        m_rate = 0x0b;
224
        break;
225
      case 48000000:
226
        m_rate = 0x01;
227
        break;
228
      case 54000000:
229
        m_rate = 0x03;
230
        break;
231
    }
232
}
233
234
uint64_t
235
LSigHeader::GetRate (void) const
236
{
237
  uint64_t rate = 0;
238
  switch (m_rate)
239
    {
240
      case 0x0d:
241
      default:
242
        rate = 6000000;
243
        break;
244
      case 0x0f:
245
        rate = 9000000;
246
        break;
247
      case 0x05:
248
        rate = 12000000;
249
        break;
250
      case 0x07:
251
        rate = 18000000;
252
        break;
253
      case 0x09:
254
        rate = 24000000;
255
        break;
256
      case 0x0b:
257
        rate = 36000000;
258
        break;
259
      case 0x01:
260
        rate = 48000000;
261
        break;
262
      case 0x03:
263
        rate = 54000000;
264
        break;
265
    }
266
  return rate;
267
}
268
269
void
270
LSigHeader::SetLength (uint16_t length)
271
{
272
  m_length = length;
273
}
274
275
uint16_t
276
LSigHeader::GetLength (void) const
277
{
278
  return m_length;
279
}
280
281
void
282
LSigHeader::Serialize (Buffer::Iterator start) const
283
{
284
  uint8_t byte1 = 0;
285
  uint8_t byte2 = 0;
286
287
  byte1 |= m_rate;
288
  byte1 |= (m_length & 0x07) << 5;
289
  start.WriteU8 (byte1);
290
291
  byte2 |= (m_length & 0x0ff8) >> 3;
292
  start.WriteU8 (byte2);
293
  start.WriteU8 (0);
294
}
295
296
uint32_t
297
LSigHeader::Deserialize (Buffer::Iterator start)
298
{
299
  Buffer::Iterator i = start;
300
301
  uint8_t byte1 = i.ReadU8 ();
302
  m_rate = byte1 & 0x0f;
303
  m_length = (byte1 >> 5) & 0x07;
304
305
  uint8_t byte2 = i.ReadU8 ();
306
  m_length |= (byte2 << 3) & 0x0ff8;
307
308
  i.ReadU8 ();
309
  return i.GetDistanceFrom (start);
310
}
311
312
NS_OBJECT_ENSURE_REGISTERED (HtSigHeader);
313
314
HtSigHeader::HtSigHeader ()
315
  : m_mcs (0),
316
    m_cbw20_40 (0),
317
    m_length (0),
318
    m_aggregation (0),
319
    m_sgi (0)
320
{
321
}
322
323
HtSigHeader::~HtSigHeader ()
324
{
325
}
326
327
TypeId
328
HtSigHeader::GetTypeId (void)
329
{
330
  static TypeId tid = TypeId ("ns3::HtSigHeader")
331
    .SetParent<Header> ()
332
    .SetGroupName ("Wifi")
333
    .AddConstructor<HtSigHeader> ()
334
  ;
335
  return tid;
336
}
337
338
TypeId
339
HtSigHeader::GetInstanceTypeId (void) const
340
{
341
  return GetTypeId ();
342
}
343
344
void
345
HtSigHeader::Print (std::ostream &os) const
346
{
347
}
348
349
uint32_t
350
HtSigHeader::GetSerializedSize (void) const
351
{
352
  return 6;
353
}
354
355
void
356
HtSigHeader::SetMcs (uint8_t mcs)
357
{
358
  m_mcs = mcs;
359
}
360
361
uint8_t
362
HtSigHeader::GetMcs (void) const
363
{
364
  return m_mcs;
365
}
366
367
void
368
HtSigHeader::SetChannelWidth (uint16_t channelWidth)
369
{
370
  m_cbw20_40 = (channelWidth > 20) ? 1 : 0;
371
}
372
373
uint16_t
374
HtSigHeader::GetChannelWidth (void) const
375
{
376
  return m_cbw20_40 ? 40 : 20;
377
}
378
379
void
380
HtSigHeader::SetLength (uint16_t length)
381
{
382
  m_length = length;
383
}
384
385
uint16_t
386
HtSigHeader::GetLength (void) const
387
{
388
  return m_length;
389
}
390
391
void
392
HtSigHeader::SetAggregation (bool aggregation)
393
{
394
  m_aggregation = aggregation ? 1 : 0;
395
}
396
397
bool
398
HtSigHeader::GetAggregation (void) const
399
{
400
  return m_aggregation ? true : false;
401
}
402
403
void
404
HtSigHeader::SetShortGuardInterval (bool sgi)
405
{
406
  m_sgi = sgi ? 1 : 0;
407
}
408
409
bool
410
HtSigHeader::GetShortGuardInterval (void) const
411
{
412
  return m_sgi ? true : false;
413
}
414
415
void
416
HtSigHeader::Serialize (Buffer::Iterator start) const
417
{
418
  uint8_t byte = m_mcs;
419
  byte |= ((m_cbw20_40 & 0x01) << 7);
420
  start.WriteU8 (byte);
421
  start.WriteU16 (m_length);
422
  byte = ((m_aggregation & 0x01) << 3);
423
  byte |= ((m_sgi & 0x01) << 7);
424
  start.WriteU8 (byte);
425
  start.WriteU16 (0);
426
}
427
428
uint32_t
429
HtSigHeader::Deserialize (Buffer::Iterator start)
430
{
431
  Buffer::Iterator i = start;
432
  uint8_t byte = i.ReadU8 ();
433
  m_mcs = byte & 0x7f;
434
  m_cbw20_40 = ((byte >> 7) & 0x01);
435
  m_length = i.ReadU16 ();
436
  byte = i.ReadU8 ();
437
  m_aggregation = ((byte >> 3) & 0x01);
438
  m_sgi = ((byte >> 7) & 0x01);
439
  i.ReadU16 ();
440
  return i.GetDistanceFrom (start);
441
}
442
443
NS_OBJECT_ENSURE_REGISTERED (VhtSigA1Header);
444
445
VhtSigA1Header::VhtSigA1Header ()
446
  : m_bw (0),
447
    m_nsts (0)
448
{
449
}
450
451
VhtSigA1Header::~VhtSigA1Header ()
452
{
453
}
454
455
TypeId
456
VhtSigA1Header::GetTypeId (void)
457
{
458
  static TypeId tid = TypeId ("ns3::VhtSigA1Header")
459
    .SetParent<Header> ()
460
    .SetGroupName ("Wifi")
461
    .AddConstructor<VhtSigA1Header> ()
462
  ;
463
  return tid;
464
}
465
466
TypeId
467
VhtSigA1Header::GetInstanceTypeId (void) const
468
{
469
  return GetTypeId ();
470
}
471
472
void
473
VhtSigA1Header::Print (std::ostream &os) const
474
{
475
}
476
477
uint32_t
478
VhtSigA1Header::GetSerializedSize (void) const
479
{
480
  return 3;
481
}
482
483
void
484
VhtSigA1Header::SetChannelWidth (uint16_t channelWidth)
485
{
486
  if (channelWidth == 160)
487
    {
488
      m_bw = 3;
489
    }
490
  else if (channelWidth == 80)
491
    {
492
      m_bw = 2;
493
    }
494
  else if (channelWidth == 40)
495
    {
496
      m_bw = 1;
497
    }
498
  else
499
    {
500
      m_bw = 0;
501
    }
502
}
503
504
uint16_t
505
VhtSigA1Header::GetChannelWidth (void) const
506
{
507
  if (m_bw == 3)
508
    {
509
      return 160;
510
    }
511
  else if (m_bw == 2)
512
    {
513
      return 80;
514
    }
515
  else if (m_bw == 1)
516
    {
517
      return 40;
518
    }
519
  else
520
    {
521
      return 20;
522
    }
523
}
524
525
void
526
VhtSigA1Header::SetNStreams (uint8_t nStreams)
527
{
528
  NS_ASSERT (nStreams <= 8);
529
  m_nsts = (nStreams - 1);
530
}
531
532
uint8_t
533
VhtSigA1Header::GetNStreams (void) const
534
{
535
  return (m_nsts + 1);
536
}
537
538
void
539
VhtSigA1Header::Serialize (Buffer::Iterator start) const
540
{
541
  uint8_t byte = m_bw;
542
  byte |= (0x01 << 2); //Set Reserved bit to 1
543
  start.WriteU8 (byte);
544
  start.WriteU16 ((m_nsts & 0x07) << 2);
545
}
546
547
uint32_t
548
VhtSigA1Header::Deserialize (Buffer::Iterator start)
549
{
550
  Buffer::Iterator i = start;
551
  uint8_t byte = i.ReadU8 ();
552
  m_bw = byte & 0x03;
553
  uint16_t bytes = i.ReadU16 ();
554
  m_nsts = ((bytes >> 2) & 0x07);
555
  return i.GetDistanceFrom (start);
556
}
557
558
NS_OBJECT_ENSURE_REGISTERED (VhtSigA2Header);
559
560
VhtSigA2Header::VhtSigA2Header ()
561
  : m_sgi (0),
562
    m_suMcs (0)
563
{
564
}
565
566
VhtSigA2Header::~VhtSigA2Header ()
567
{
568
}
569
570
TypeId
571
VhtSigA2Header::GetTypeId (void)
572
{
573
  static TypeId tid = TypeId ("ns3::VhtSigA2Header")
574
    .SetParent<Header> ()
575
    .SetGroupName ("Wifi")
576
    .AddConstructor<VhtSigA2Header> ()
577
  ;
578
  return tid;
579
}
580
581
TypeId
582
VhtSigA2Header::GetInstanceTypeId (void) const
583
{
584
  return GetTypeId ();
585
}
586
587
void
588
VhtSigA2Header::Print (std::ostream &os) const
589
{
590
}
591
592
uint32_t
593
VhtSigA2Header::GetSerializedSize (void) const
594
{
595
  return 3;
596
}
597
598
void
599
VhtSigA2Header::SetShortGuardInterval (bool sgi)
600
{
601
  m_sgi = sgi ? 1 : 0;
602
}
603
604
bool
605
VhtSigA2Header::GetShortGuardInterval (void) const
606
{
607
  return m_sgi ? true : false;
608
}
609
610
void
611
VhtSigA2Header::SetSuMcs (uint8_t mcs)
612
{
613
  m_suMcs = mcs;
614
}
615
616
uint8_t
617
VhtSigA2Header::GetSuMcs (void) const
618
{
619
  return m_suMcs;
620
}
621
622
void
623
VhtSigA2Header::Serialize (Buffer::Iterator start) const
624
{
625
  uint8_t byte = m_sgi;
626
  byte |= ((m_suMcs & 0x0f) << 4);
627
  start.WriteU8 (byte);
628
  start.WriteU16 (0);
629
}
630
631
uint32_t
632
VhtSigA2Header::Deserialize (Buffer::Iterator start)
633
{
634
  Buffer::Iterator i = start;
635
  uint8_t byte = i.ReadU8 ();
636
  m_sgi = byte & 0x01;
637
  m_suMcs = ((byte >> 4) & 0x0f);
638
  i.ReadU16 ();
639
  return i.GetDistanceFrom (start);
640
}
641
642
NS_OBJECT_ENSURE_REGISTERED (VhtSigBHeader);
643
644
VhtSigBHeader::VhtSigBHeader ()
645
{
646
}
647
648
VhtSigBHeader::~VhtSigBHeader ()
649
{
650
}
651
652
TypeId
653
VhtSigBHeader::GetTypeId (void)
654
{
655
  static TypeId tid = TypeId ("ns3::VhtSigBHeader")
656
    .SetParent<Header> ()
657
    .SetGroupName ("Wifi")
658
    .AddConstructor<VhtSigBHeader> ()
659
  ;
660
  return tid;
661
}
662
663
TypeId
664
VhtSigBHeader::GetInstanceTypeId (void) const
665
{
666
  return GetTypeId ();
667
}
668
669
void
670
VhtSigBHeader::Print (std::ostream &os) const
671
{
672
}
673
674
uint32_t
675
VhtSigBHeader::GetSerializedSize (void) const
676
{
677
  return 4;
678
}
679
680
void
681
VhtSigBHeader::Serialize (Buffer::Iterator start) const
682
{
683
  start.WriteU32 (0);
684
}
685
686
uint32_t
687
VhtSigBHeader::Deserialize (Buffer::Iterator start)
688
{
689
  Buffer::Iterator i = start;
690
  i.ReadU32 ();
691
  return i.GetDistanceFrom (start);
692
}
693
694
NS_OBJECT_ENSURE_REGISTERED (HeSigA1Header);
695
696
HeSigA1Header::HeSigA1Header ()
697
  : m_format (1),
698
    m_bssColor (0),
699
    m_ul_dl (0),
700
    m_mcs (0),
701
    m_spatialReuse (0),
702
    m_bandwidth (0),
703
    m_gi_ltf_size (0),
704
    m_nsts (0)
705
{
706
}
707
708
HeSigA1Header::~HeSigA1Header ()
709
{
710
}
711
712
TypeId
713
HeSigA1Header::GetTypeId (void)
714
{
715
  static TypeId tid = TypeId ("ns3::HeSigA1Header")
716
    .SetParent<Header> ()
717
    .SetGroupName ("Wifi")
718
    .AddConstructor<HeSigA1Header> ()
719
  ;
720
  return tid;
721
}
722
723
TypeId
724
HeSigA1Header::GetInstanceTypeId (void) const
725
{
726
  return GetTypeId ();
727
}
728
729
void
730
HeSigA1Header::Print (std::ostream &os) const
731
{
732
  os << "BSSColor=" << m_bssColor;
733
}
734
735
uint32_t
736
HeSigA1Header::GetSerializedSize (void) const
737
{
738
  return 4;
739
}
740
741
void
742
HeSigA1Header::SetMcs (uint8_t mcs)
743
{
744
  m_mcs = mcs;
745
}
746
747
uint8_t
748
HeSigA1Header::GetMcs (void) const
749
{
750
  return m_mcs;
751
}
752
753
void
754
HeSigA1Header::SetBssColor (uint8_t bssColor)
755
{
756
  m_bssColor = bssColor;
757
}
758
759
uint8_t
760
HeSigA1Header::GetBssColor (void) const
761
{
762
  return m_bssColor;
763
}
764
765
void
766
HeSigA1Header::SetChannelWidth (uint16_t channelWidth)
767
{
768
  if (channelWidth == 160)
769
    {
770
      m_bandwidth = 3;
771
    }
772
  else if (channelWidth == 80)
773
    {
774
      m_bandwidth = 2;
775
    }
776
  else if (channelWidth == 40)
777
    {
778
      m_bandwidth = 1;
779
    }
780
  else
781
    {
782
      m_bandwidth = 0;
783
    }
784
}
785
786
uint16_t
787
HeSigA1Header::GetChannelWidth (void) const
788
{
789
  if (m_bandwidth == 3)
790
    {
791
      return 160;
792
    }
793
  else if (m_bandwidth == 2)
794
    {
795
      return 80;
796
    }
797
  else if (m_bandwidth == 1)
798
    {
799
      return 40;
800
    }
801
  else
802
    {
803
      return 20;
804
    }
805
}
806
807
void
808
HeSigA1Header::SetGuardIntervalAndLtfSize (uint16_t gi, uint8_t ltf)
809
{
810
  if (gi == 800 && ltf == 1)
811
    {
812
      m_gi_ltf_size = 0;
813
    }
814
  else if (gi == 800 && ltf == 2)
815
    {
816
      m_gi_ltf_size = 1;
817
    }
818
  else if (gi == 1600 && ltf == 2)
819
    {
820
      m_gi_ltf_size = 2;
821
    }
822
  else
823
    {
824
      m_gi_ltf_size = 3;
825
    }
826
}
827
828
uint16_t
829
HeSigA1Header::GetGuardInterval (void) const
830
{
831
  if (m_gi_ltf_size == 3)
832
    {
833
      //we currently do not consider DCM nor STBC fields
834
      return 3200;
835
    }
836
  else if (m_gi_ltf_size == 2)
837
    {
838
      return 1600;
839
    }
840
  else
841
    {
842
      return 800;
843
    }
844
}
845
846
void
847
HeSigA1Header::SetNStreams (uint8_t nStreams)
848
{
849
  NS_ASSERT (nStreams <= 8);
850
  m_nsts = (nStreams - 1);
851
}
852
853
uint8_t
854
HeSigA1Header::GetNStreams (void) const
855
{
856
  return (m_nsts + 1);
857
}
858
859
void
860
HeSigA1Header::Serialize (Buffer::Iterator start) const
861
{
862
  uint8_t byte = m_format;
863
  byte |= ((m_ul_dl & 0x01) << 2);
864
  byte |= ((m_mcs & 0x0f) << 3);
865
  start.WriteU8 (byte);
866
  uint16_t bytes = (m_bssColor & 0x3f);
867
  bytes |= (0x01 << 6); //Reserved set to 1
868
  bytes |= ((m_spatialReuse & 0x0f) << 7);
869
  bytes |= ((m_bandwidth & 0x03) << 11);
870
  bytes |= ((m_gi_ltf_size & 0x03) << 13);
871
  bytes |= ((m_nsts & 0x01) << 15);
872
  start.WriteU16 (bytes);
873
  start.WriteU8 ((m_nsts >> 1) & 0x03);
874
}
875
876
uint32_t
877
HeSigA1Header::Deserialize (Buffer::Iterator start)
878
{
879
  Buffer::Iterator i = start;
880
  uint8_t byte = i.ReadU8 ();
881
  m_format = (byte & 0x01);
882
  m_ul_dl = ((byte >> 2) & 0x01);
883
  m_mcs = ((byte >> 3) & 0x0f);
884
  uint16_t bytes = i.ReadU16 ();
885
  m_bssColor = (bytes & 0x3f);
886
  m_spatialReuse = ((bytes >> 7) & 0x0f);
887
  m_bandwidth = ((bytes >> 11) & 0x03);
888
  m_gi_ltf_size = ((bytes >> 13) & 0x03);
889
  m_nsts = ((bytes >> 15) & 0x01);
890
  byte = i.ReadU8 ();
891
  m_nsts |= (byte & 0x03) << 1;
892
  return i.GetDistanceFrom (start);
893
}
894
895
NS_OBJECT_ENSURE_REGISTERED (HeSigA2Header);
896
897
HeSigA2Header::HeSigA2Header ()
898
{
899
}
900
901
HeSigA2Header::~HeSigA2Header ()
902
{
903
}
904
905
TypeId
906
HeSigA2Header::GetTypeId (void)
907
{
908
  static TypeId tid = TypeId ("ns3::HeSigA2Header")
909
    .SetParent<Header> ()
910
    .SetGroupName ("Wifi")
911
    .AddConstructor<HeSigA2Header> ()
912
  ;
913
  return tid;
914
}
915
916
TypeId
917
HeSigA2Header::GetInstanceTypeId (void) const
918
{
919
  return GetTypeId ();
920
}
921
922
void
923
HeSigA2Header::Print (std::ostream &os) const
924
{
925
}
926
927
uint32_t
928
HeSigA2Header::GetSerializedSize (void) const
929
{
930
  return 4;
931
}
932
933
void
934
HeSigA2Header::Serialize (Buffer::Iterator start) const
935
{
936
  start.WriteU32 (0);
937
}
938
939
uint32_t
940
HeSigA2Header::Deserialize (Buffer::Iterator start)
941
{
942
  Buffer::Iterator i = start;
943
  i.ReadU32 ();
944
  return i.GetDistanceFrom (start);
945
}
946
947
NS_OBJECT_ENSURE_REGISTERED (HeSigBHeader);
948
949
HeSigBHeader::HeSigBHeader ()
950
{
951
}
952
953
HeSigBHeader::~HeSigBHeader ()
954
{
955
}
956
957
TypeId
958
HeSigBHeader::GetTypeId (void)
959
{
960
  static TypeId tid = TypeId ("ns3::HeSigBHeader")
961
    .SetParent<Header> ()
962
    .SetGroupName ("Wifi")
963
    .AddConstructor<HeSigBHeader> ()
964
  ;
965
  return tid;
966
}
967
968
TypeId
969
HeSigBHeader::GetInstanceTypeId (void) const
970
{
971
  return GetTypeId ();
972
}
973
974
void
975
HeSigBHeader::Print (std::ostream &os) const
976
{
977
}
978
979
uint32_t
980
HeSigBHeader::GetSerializedSize (void) const
981
{
982
  return 1;
983
}
984
985
void
986
HeSigBHeader::Serialize (Buffer::Iterator start) const
987
{
988
  start.WriteU8 (0);
989
}
990
991
uint32_t
992
HeSigBHeader::Deserialize (Buffer::Iterator start)
993
{
994
  Buffer::Iterator i = start;
995
  i.ReadU8 ();
996
  return i.GetDistanceFrom (start);
997
}
998
999
} //namespace ns3
(-)a/src/wifi/model/wifi-plcp-header.h (+506 lines)
Line 0    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
 * Copyright (c) 2018 Sébastien Deronne
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
 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
19
 */
20
21
#ifndef WIFI_PLCP_HEADER_H
22
#define WIFI_PLCP_HEADER_H
23
24
#include "ns3/header.h"
25
26
namespace ns3 {
27
28
/**
29
 * \ingroup wifi
30
 *
31
 * Implements the IEEE 802.11b SIG PLCP header
32
 */
33
class DsssSigHeader : public Header
34
{
35
public:
36
  DsssSigHeader ();
37
  virtual ~DsssSigHeader ();
38
39
  /**
40
   * \brief Get the type ID.
41
   * \return the object TypeId
42
   */
43
  static TypeId GetTypeId (void);
44
  TypeId GetInstanceTypeId (void) const;
45
  void Print (std::ostream &os) const;
46
  uint32_t GetSerializedSize (void) const;
47
  void Serialize (Buffer::Iterator start) const;
48
  uint32_t Deserialize (Buffer::Iterator start);
49
50
  /**
51
   * Fill the RATE field of L-SIG (in bit/s).
52
   *
53
   * \param rate the RATE field of L-SIG expressed in bit/s
54
   */
55
  void SetRate (uint64_t rate);
56
  /**
57
   * Return the RATE field of L-SIG (in bit/s).
58
   *
59
   * \return the RATE field of L-SIG expressed in bit/s
60
   */
61
  uint64_t GetRate (void) const;
62
  /**
63
   * Fill the LENGTH field of L-SIG (in bytes).
64
   *
65
   * \param length the LENGTH field of L-SIG expressed in bytes
66
   */
67
  void SetLength (uint16_t length);
68
  /**
69
   * Return the LENGTH field of L-SIG (in bytes).
70
   *
71
   * \return the LENGTH field of L-SIG expressed in bytes
72
   */
73
  uint16_t GetLength (void) const;
74
75
76
private:
77
  uint8_t m_rate;    ///< RATE field
78
  uint16_t m_length; ///< LENGTH field
79
};
80
81
82
/**
83
 * \ingroup wifi
84
 *
85
 * Implements the IEEE 802.11 L-SIG PLCP header
86
 */
87
class LSigHeader : public Header
88
{
89
public:
90
  LSigHeader ();
91
  virtual ~LSigHeader ();
92
93
  /**
94
   * \brief Get the type ID.
95
   * \return the object TypeId
96
   */
97
  static TypeId GetTypeId (void);
98
  TypeId GetInstanceTypeId (void) const;
99
  void Print (std::ostream &os) const;
100
  uint32_t GetSerializedSize (void) const;
101
  void Serialize (Buffer::Iterator start) const;
102
  uint32_t Deserialize (Buffer::Iterator start);
103
104
  /**
105
   * Fill the RATE field of L-SIG (in bit/s).
106
   *
107
   * \param rate the RATE field of L-SIG expressed in bit/s
108
   */
109
  void SetRate (uint64_t rate);
110
  /**
111
   * Return the RATE field of L-SIG (in bit/s).
112
   *
113
   * \return the RATE field of L-SIG expressed in bit/s
114
   */
115
  uint64_t GetRate (void) const;
116
  /**
117
   * Fill the LENGTH field of L-SIG (in bytes).
118
   *
119
   * \param length the LENGTH field of L-SIG expressed in bytes
120
   */
121
  void SetLength (uint16_t length);
122
  /**
123
   * Return the LENGTH field of L-SIG (in bytes).
124
   *
125
   * \return the LENGTH field of L-SIG expressed in bytes
126
   */
127
  uint16_t GetLength (void) const;
128
129
130
private:
131
  uint8_t m_rate;    ///< RATE field
132
  uint16_t m_length; ///< LENGTH field
133
};
134
135
136
/**
137
 * \ingroup wifi
138
 *
139
 * Implements the IEEE 802.11n HT-SIG PLCP header
140
 */
141
class HtSigHeader : public Header
142
{
143
public:
144
  HtSigHeader ();
145
  virtual ~HtSigHeader ();
146
147
  /**
148
   * \brief Get the type ID.
149
   * \return the object TypeId
150
   */
151
  static TypeId GetTypeId (void);
152
  TypeId GetInstanceTypeId (void) const;
153
  void Print (std::ostream &os) const;
154
  uint32_t GetSerializedSize (void) const;
155
  void Serialize (Buffer::Iterator start) const;
156
  uint32_t Deserialize (Buffer::Iterator start);
157
158
  /**
159
   * Fill the MCS field of HT-SIG.
160
   *
161
   * \param length the MCS field of HT-SIG
162
   */
163
  void SetMcs (uint8_t mcs);
164
  /**
165
   * Return the MCS field of HT-SIG.
166
   *
167
   * \return the MCS field of HT-SIG
168
   */
169
  uint8_t GetMcs (void) const;
170
  /**
171
   * Fill the channel width field of HT-SIG (in MHz).
172
   *
173
   * \param width the channel width (in MHz)
174
   */
175
  void SetChannelWidth (uint16_t width);
176
  /**
177
   * Return the channel width (in MHz).
178
   *
179
   * \return the channel width (in MHz)
180
   */
181
  uint16_t GetChannelWidth (void) const;
182
  /**
183
   * Fill the aggregation field of HT-SIG .
184
   *
185
   * \param aggregation whether the PSDU contains A-MPDU or not
186
   */
187
  void SetAggregation (bool aggregation);
188
  /**
189
   * Return the aggregation field of HT-SIG.
190
   *
191
   * \return the aggregation field of HT-SIG
192
   */
193
  bool GetAggregation (void) const;
194
  /**
195
   * Fill the short guard interval field of HT-SIG.
196
   *
197
   * \param sgi whether short guard interval is used or not
198
   */
199
  void SetShortGuardInterval (bool sgi);
200
  /**
201
   * Return the short guard interval field of HT-SIG.
202
   *
203
   * \return the short guard interval field of HT-SIG
204
   */
205
  bool GetShortGuardInterval (void) const;
206
  /**
207
   * Fill the HT length field of HT-SIG (in bytes).
208
   *
209
   * \param length the HT length field of HT-SIG (in bytes)
210
   */
211
  void SetLength (uint16_t length);
212
  /**
213
   * Return the HT length field of HT-SIG (in bytes).
214
   *
215
   * \return the HT length field of HT-SIG (in bytes)
216
   */
217
  uint16_t GetLength (void) const;
218
219
220
private:
221
  uint8_t m_mcs;         ///< Modulation and Coding Scheme index
222
  uint8_t m_cbw20_40;    ///< CBW 20/40
223
  uint16_t m_length;     ///< HT length
224
  uint8_t m_aggregation; ///< Aggregation
225
  uint8_t m_sgi;         ///< Short Guard Interval
226
};
227
228
/**
229
 * \ingroup wifi
230
 *
231
 * Implements the IEEE 802.11ac VHT-SIG-A1 PLCP header
232
 */
233
class VhtSigA1Header : public Header
234
{
235
public:
236
  VhtSigA1Header ();
237
  virtual ~VhtSigA1Header ();
238
239
  /**
240
   * \brief Get the type ID.
241
   * \return the object TypeId
242
   */
243
  static TypeId GetTypeId (void);
244
  TypeId GetInstanceTypeId (void) const;
245
  void Print (std::ostream &os) const;
246
  uint32_t GetSerializedSize (void) const;
247
  void Serialize (Buffer::Iterator start) const;
248
  uint32_t Deserialize (Buffer::Iterator start);
249
250
  /**
251
   * Fill the channel width field of VHT-SIG-A1 (in MHz).
252
   *
253
   * \param width the channel width (in MHz)
254
   */
255
  void SetChannelWidth (uint16_t width);
256
  /**
257
   * Return the channel width (in MHz).
258
   *
259
   * \return the channel width (in MHz)
260
   */
261
  uint16_t GetChannelWidth (void) const;
262
  /**
263
   * Fill the number of streams field of VHT-SIG-A1.
264
   *
265
   * \param nStreams the number of streams
266
   */
267
  void SetNStreams (uint8_t nStreams);
268
  /**
269
   * Return the number of streams.
270
   *
271
   * \return the number of streams
272
   */
273
  uint8_t GetNStreams (void) const;
274
275
private:
276
  uint8_t m_bw;   ///< BW
277
  uint8_t m_nsts; ///< NSTS
278
};
279
280
281
/**
282
 * \ingroup wifi
283
 *
284
 * Implements the IEEE 802.11ac VHT-SIG-A2 PLCP header
285
 */
286
class VhtSigA2Header : public Header
287
{
288
public:
289
  VhtSigA2Header ();
290
  virtual ~VhtSigA2Header ();
291
292
  /**
293
   * \brief Get the type ID.
294
   * \return the object TypeId
295
   */
296
  static TypeId GetTypeId (void);
297
  TypeId GetInstanceTypeId (void) const;
298
  void Print (std::ostream &os) const;
299
  uint32_t GetSerializedSize (void) const;
300
  void Serialize (Buffer::Iterator start) const;
301
  uint32_t Deserialize (Buffer::Iterator start);
302
303
  /**
304
   * Fill the short guard interval field of VHT-SIG-A2.
305
   *
306
   * \param sgi whether short guard interval is used or not
307
   */
308
  void SetShortGuardInterval (bool sgi);
309
  /**
310
   * Return the short GI field of VHT-SIG-A2.
311
   *
312
   * \return the short GI field of VHT-SIG-A2
313
   */
314
  bool GetShortGuardInterval (void) const;
315
  /**
316
   * Fill the SU VHT MCS field of VHT-SIG-A2.
317
   *
318
   * \param length the SU VHT MCS field of VHT-SIG-A2
319
   */
320
  void SetSuMcs (uint8_t mcs);
321
  /**
322
   * Return the SU VHT MCS field of VHT-SIG-A2.
323
   *
324
   * \return the SU VHT MCS field of VHT-SIG-A2
325
   */
326
  uint8_t GetSuMcs (void) const;
327
328
329
private:
330
  uint8_t m_sgi;   ///< Short GI
331
  uint8_t m_suMcs; ///< SU VHT MCS
332
};
333
334
335
/**
336
 * \ingroup wifi
337
 *
338
 * Implements the IEEE 802.11ac VHT-SIG-B PLCP header
339
 */
340
class VhtSigBHeader : public Header
341
{
342
public:
343
  VhtSigBHeader ();
344
  virtual ~VhtSigBHeader ();
345
346
  /**
347
   * \brief Get the type ID.
348
   * \return the object TypeId
349
   */
350
  static TypeId GetTypeId (void);
351
  TypeId GetInstanceTypeId (void) const;
352
  void Print (std::ostream &os) const;
353
  uint32_t GetSerializedSize (void) const;
354
  void Serialize (Buffer::Iterator start) const;
355
  uint32_t Deserialize (Buffer::Iterator start);
356
};
357
358
359
/**
360
 * \ingroup wifi
361
 *
362
 * Implements the IEEE 802.11ax HE-SIG-A1 PLCP header
363
 */
364
class HeSigA1Header : public Header
365
{
366
public:
367
  HeSigA1Header ();
368
  virtual ~HeSigA1Header ();
369
370
  /**
371
   * \brief Get the type ID.
372
   * \return the object TypeId
373
   */
374
  static TypeId GetTypeId (void);
375
  TypeId GetInstanceTypeId (void) const;
376
  void Print (std::ostream &os) const;
377
  uint32_t GetSerializedSize (void) const;
378
  void Serialize (Buffer::Iterator start) const;
379
  uint32_t Deserialize (Buffer::Iterator start);
380
381
  /**
382
   * Fill the MCS field of HE-SIG-A1.
383
   *
384
   * \param length the MCS field of HE-SIG-A1
385
   */
386
  void SetMcs (uint8_t mcs);
387
  /**
388
   * Return the MCS field of HE-SIG-A1.
389
   *
390
   * \return the MCS field of HE-SIG-A1
391
   */
392
  uint8_t GetMcs (void) const;
393
  /**
394
   * Fill the BSS Color field of HE-SIG-A1.
395
   *
396
   * \param bssColor the BSS Color value
397
   */
398
  void SetBssColor (uint8_t bssColor);
399
  /**
400
   * Return the BSS Color field in the HE-SIG-A1.
401
   *
402
   * \return the BSS Color field in the HE-SIG-A1
403
   */
404
  uint8_t GetBssColor (void) const;
405
  /**
406
   * Fill the channel width field of HE-SIG-A1 (in MHz).
407
   *
408
   * \param width the channel width (in MHz)
409
   */
410
  void SetChannelWidth (uint16_t width);
411
  /**
412
   * Return the channel width (in MHz).
413
   *
414
   * \return the channel width (in MHz)
415
   */
416
  uint16_t GetChannelWidth (void) const;
417
  /**
418
   * Fill the GI + LTF size field of HE-SIG-A1.
419
   *
420
   * \param gi the guard interval (in nanoseconds)
421
   * \param ltf the number of HE-LTF
422
   */
423
  void SetGuardIntervalAndLtfSize (uint16_t gi, uint8_t ltf);
424
  /**
425
   * Return the guard interval (in nanoseconds).
426
   *
427
   * \return the guard interval (in nanoseconds)
428
   */
429
  uint16_t GetGuardInterval (void) const;
430
  /**
431
   * Fill the number of streams field of HE-SIG-A1.
432
   *
433
   * \param nStreams the number of streams
434
   */
435
  void SetNStreams (uint8_t nStreams);
436
  /**
437
   * Return the number of streams.
438
   *
439
   * \return the number of streams
440
   */
441
  uint8_t GetNStreams (void) const;
442
443
444
private:
445
  //TODO: add boolean to know whether this is part of a HE SU or HE MU PPDU (fields and positions are different! We currently only support HE SU)
446
  uint8_t m_format;       ///< Format bit
447
  uint8_t m_bssColor;     ///< BSS color field
448
  uint8_t m_ul_dl;        ///< UL/DL bit
449
  uint8_t m_mcs;          ///< MCS field
450
  uint8_t m_spatialReuse; ///< Spatial Reuse field
451
  uint8_t m_bandwidth;    ///< Bandwidth field
452
  uint8_t m_gi_ltf_size;  ///< GI+LTF Size field
453
  uint8_t m_nsts;         ///< NSTS
454
};
455
456
457
/**
458
 * \ingroup wifi
459
 *
460
 * Implements the IEEE 802.11ax HE-SIG-A2 PLCP header
461
 */
462
class HeSigA2Header : public Header
463
{
464
public:
465
  HeSigA2Header ();
466
  virtual ~HeSigA2Header ();
467
468
  /**
469
   * \brief Get the type ID.
470
   * \return the object TypeId
471
   */
472
  static TypeId GetTypeId (void);
473
  TypeId GetInstanceTypeId (void) const;
474
  void Print (std::ostream &os) const;
475
  uint32_t GetSerializedSize (void) const;
476
  void Serialize (Buffer::Iterator start) const;
477
  uint32_t Deserialize (Buffer::Iterator start);
478
};
479
480
481
/**
482
 * \ingroup wifi
483
 *
484
 * Implements the IEEE 802.11ax HE-SIG-B PLCP header
485
 */
486
class HeSigBHeader : public Header
487
{
488
public:
489
  HeSigBHeader ();
490
  virtual ~HeSigBHeader ();
491
492
  /**
493
   * \brief Get the type ID.
494
   * \return the object TypeId
495
   */
496
  static TypeId GetTypeId (void);
497
  TypeId GetInstanceTypeId (void) const;
498
  void Print (std::ostream &os) const;
499
  uint32_t GetSerializedSize (void) const;
500
  void Serialize (Buffer::Iterator start) const;
501
  uint32_t Deserialize (Buffer::Iterator start);
502
};
503
504
} //namespace ns3
505
506
#endif /* WIFI_PLCP_HEADER_H */
(-)a/src/wifi/model/wifi-tx-vector.cc (-9 / +8 lines)
 Lines 32-39   WifiTxVector::WifiTxVector () Link Here 
32
    m_ness (0),
32
    m_ness (0),
33
    m_aggregation (false),
33
    m_aggregation (false),
34
    m_stbc (false),
34
    m_stbc (false),
35
    m_modeInitialized (false),
35
    m_modeInitialized (false)
36
    m_txPowerLevelInitialized (false)
37
{
36
{
38
}
37
}
39
38
 Lines 57-67   WifiTxVector::WifiTxVector (WifiMode mode, Link Here 
57
    m_ness (ness),
56
    m_ness (ness),
58
    m_aggregation (aggregation),
57
    m_aggregation (aggregation),
59
    m_stbc (stbc),
58
    m_stbc (stbc),
60
    m_modeInitialized (true),
59
    m_modeInitialized (true)
61
    m_txPowerLevelInitialized (true)
62
{
60
{
63
}
61
}
64
62
63
bool
64
WifiTxVector::GetModeInitialized (void) const
65
{
66
  return m_modeInitialized;
67
}
68
65
WifiMode
69
WifiMode
66
WifiTxVector::GetMode (void) const
70
WifiTxVector::GetMode (void) const
67
{
71
{
 Lines 75-84   WifiTxVector::GetMode (void) const Link Here 
75
uint8_t
79
uint8_t
76
WifiTxVector::GetTxPowerLevel (void) const
80
WifiTxVector::GetTxPowerLevel (void) const
77
{
81
{
78
  if (!m_txPowerLevelInitialized)
79
    {
80
      NS_FATAL_ERROR ("WifiTxVector txPowerLevel must be set before using");
81
    }
82
  return m_txPowerLevel;
82
  return m_txPowerLevel;
83
}
83
}
84
84
 Lines 141-147   void Link Here 
141
WifiTxVector::SetTxPowerLevel (uint8_t powerlevel)
141
WifiTxVector::SetTxPowerLevel (uint8_t powerlevel)
142
{
142
{
143
  m_txPowerLevel = powerlevel;
143
  m_txPowerLevel = powerlevel;
144
  m_txPowerLevelInitialized = true;
145
}
144
}
146
145
147
void
146
void
(-)a/src/wifi/model/wifi-tx-vector.h (-1 / +4 lines)
 Lines 87-92   public: Link Here 
87
                bool aggregation,
87
                bool aggregation,
88
                bool stbc);
88
                bool stbc);
89
  /**
89
  /**
90
   * \returns whether mode has been initialized
91
   */
92
  bool GetModeInitialized (void) const;
93
  /**
90
   * \returns the selected payload transmission mode
94
   * \returns the selected payload transmission mode
91
   */
95
   */
92
  WifiMode GetMode (void) const;
96
  WifiMode GetMode (void) const;
 Lines 218-224   private: Link Here 
218
  bool     m_stbc;               /**< STBC used or not */
222
  bool     m_stbc;               /**< STBC used or not */
219
223
220
  bool     m_modeInitialized;         /**< Internal initialization flag */
224
  bool     m_modeInitialized;         /**< Internal initialization flag */
221
  bool     m_txPowerLevelInitialized; /**< Internal initialization flag */
222
};
225
};
223
226
224
/**
227
/**
(-)a/src/wifi/test/spectrum-wifi-phy-test.cc (-1 / +1 lines)
 Lines 118-124   SpectrumWifiPhyBasicTest::MakeSignal (double txPowerWatts) Link Here 
118
118
119
  pkt->AddHeader (hdr);
119
  pkt->AddHeader (hdr);
120
  pkt->AddTrailer (trailer);
120
  pkt->AddTrailer (trailer);
121
  WifiPhyTag tag (txVector, mpdutype, 1);
121
  WifiPhyTag tag (txVector.GetPreambleType (), txVector.GetMode ().GetModulationClass (), mpdutype, 1);
122
  pkt->AddPacketTag (tag);
122
  pkt->AddPacketTag (tag);
123
  Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, txPowerWatts, GUARD_WIDTH);
123
  Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, txPowerWatts, GUARD_WIDTH);
124
  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
124
  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
(-)a/src/wifi/test/wifi-test.cc (-5 / +53 lines)
 Lines 44-49    Link Here 
44
#include "ns3/yans-wifi-phy.h"
44
#include "ns3/yans-wifi-phy.h"
45
#include "ns3/mgt-headers.h"
45
#include "ns3/mgt-headers.h"
46
#include "ns3/ht-configuration.h"
46
#include "ns3/ht-configuration.h"
47
#include "ns3/wifi-plcp-header.h"
47
48
48
using namespace ns3;
49
using namespace ns3;
49
50
 Lines 1233-1245   Bug2483TestCase::StoreDistinctTuple (std::string context, Ptr<SpectrumSignalPar Link Here 
1233
      NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag");
1234
      NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag");
1234
      return;
1235
      return;
1235
    }
1236
    }
1236
  WifiTxVector txVector = tag.GetWifiTxVector ();
1237
  uint16_t channelWidth;
1237
  uint16_t channelWidth = txVector.GetChannelWidth ();
1238
  WifiModulationClass modulationClass = tag.GetModulation ();
1238
  WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1239
1240
  WifiPreamble preamble = tag.GetPreambleType ();
1241
  if ((modulationClass != WIFI_MOD_CLASS_HT) || (preamble != WIFI_PREAMBLE_HT_GF))
1242
    {
1243
      LSigHeader sig;
1244
      bool found = packet->RemoveHeader (sig);
1245
      if (!found)
1246
        {
1247
          NS_FATAL_ERROR ("Received 802.11 signal with no SIG field");
1248
          return;
1249
        }
1250
      channelWidth = 20;
1251
    }
1252
  if (modulationClass == WIFI_MOD_CLASS_HT)
1253
    {
1254
      HtSigHeader htSig;
1255
      bool found = packet->RemoveHeader (htSig);
1256
      if (!found)
1257
        {
1258
          NS_FATAL_ERROR ("Received 802.11n signal with no HT-SIG field");
1259
          return;
1260
        }
1261
      channelWidth = htSig.GetChannelWidth ();
1262
    }
1263
  else if (modulationClass == WIFI_MOD_CLASS_VHT)
1264
    {
1265
      VhtSigA1Header vhtSigA1;
1266
      VhtSigA2Header vhtSigA2;
1267
      VhtSigBHeader vhtSigB;
1268
      bool found = packet->RemoveHeader (vhtSigB);
1269
      if (!found)
1270
        {
1271
          NS_FATAL_ERROR ("Received 802.11ac signal with no VHT-SIG-B field");
1272
          return;
1273
        }
1274
      found = packet->RemoveHeader (vhtSigA2);
1275
      if (!found)
1276
        {
1277
          NS_FATAL_ERROR ("Received 802.11ac signal with no VHT-SIG-A2 field");
1278
          return;
1279
        }
1280
      found = packet->RemoveHeader (vhtSigA1);
1281
      if (!found)
1282
        {
1283
          NS_FATAL_ERROR ("Received 802.11ac signal with no VHT-SIG-A1 field");
1284
          return;
1285
        }
1286
      channelWidth = vhtSigA1.GetChannelWidth ();
1287
    }
1239
1288
1240
  // Build a tuple and check if seen before (if so store it)
1289
  // Build a tuple and check if seen before (if so store it)
1241
  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, channelWidth,
1290
  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, channelWidth, numBands, modulationClass);
1242
                                                                       numBands, modulationClass);
1243
  bool found = false;
1291
  bool found = false;
1244
  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1292
  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1245
    {
1293
    {
(-)a/src/wifi/wscript (+2 lines)
 Lines 21-26   def build(bld): Link Here 
21
        'model/wifi-phy-tag.cc',
21
        'model/wifi-phy-tag.cc',
22
        'model/wifi-spectrum-phy-interface.cc',
22
        'model/wifi-spectrum-phy-interface.cc',
23
        'model/wifi-spectrum-signal-parameters.cc',
23
        'model/wifi-spectrum-signal-parameters.cc',
24
        'model/wifi-plcp-header.cc',
24
        'model/wifi-mac-header.cc',
25
        'model/wifi-mac-header.cc',
25
        'model/wifi-mac-trailer.cc',
26
        'model/wifi-mac-trailer.cc',
26
        'model/mac-low.cc',
27
        'model/mac-low.cc',
 Lines 155-160   def build(bld): Link Here 
155
        'model/dsss-error-rate-model.h',
156
        'model/dsss-error-rate-model.h',
156
        'model/wifi-mac-queue.h',
157
        'model/wifi-mac-queue.h',
157
        'model/txop.h',
158
        'model/txop.h',
159
        'model/wifi-plcp-header.h',
158
        'model/wifi-mac-header.h',
160
        'model/wifi-mac-header.h',
159
        'model/wifi-mac-trailer.h',
161
        'model/wifi-mac-trailer.h',
160
        'model/wifi-phy-state-helper.h',
162
        'model/wifi-phy-state-helper.h',

Return to bug 3019