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

(-)original/src/network/utils/radiotap-header.cc (-4 / +99 lines)
 Lines 16-21    Link Here 
16
 * Foundation, Include., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 * Foundation, Include., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
17
 *
18
 * Author: Nicola Baldo <nbaldo@cttc.es>
18
 * Author: Nicola Baldo <nbaldo@cttc.es>
19
 * Author: Hany Assasa <hany.assasa@imdea.org>
19
 */
20
 */
20
21
21
#include <iomanip>
22
#include <iomanip>
 Lines 38-44   RadiotapHeader::RadiotapHeader() Link Here 
38
    m_channelFreq (0),
39
    m_channelFreq (0),
39
    m_channelFlags (CHANNEL_FLAG_NONE),
40
    m_channelFlags (CHANNEL_FLAG_NONE),
40
    m_antennaSignal (0),
41
    m_antennaSignal (0),
41
    m_antennaNoise (0)
42
    m_antennaNoise (0),
43
    m_ampduStatusRef (0),
44
    m_ampduStatusFlags (0),
45
    m_ampduStatusCRC (0),
46
    m_ampduStatusReserved (0)
42
{
47
{
43
  NS_LOG_FUNCTION (this);
48
  NS_LOG_FUNCTION (this);
44
}
49
}
 Lines 107-112   RadiotapHeader::Serialize (Buffer::Itera Link Here 
107
  //
112
  //
108
  if (m_present & RADIOTAP_CHANNEL) // bit 3
113
  if (m_present & RADIOTAP_CHANNEL) // bit 3
109
    {
114
    {
115
      start.WriteU8(0, m_channelPad);
110
      start.WriteU16 (m_channelFreq);
116
      start.WriteU16 (m_channelFreq);
111
      start.WriteU16 (m_channelFlags);
117
      start.WriteU16 (m_channelFlags);
112
    }
118
    }
 Lines 128-133   RadiotapHeader::Serialize (Buffer::Itera Link Here 
128
    {
134
    {
129
      start.WriteU8 (m_antennaNoise);
135
      start.WriteU8 (m_antennaNoise);
130
    }
136
    }
137
138
  //
139
  // A-MPDU Status, information about the received A-MPDU.
140
  //
141
  if (m_present & RADIOTAP_MCS) // bit 19
142
    {
143
      start.WriteU8 (0);
144
      start.WriteU8 (0);
145
      start.WriteU8 (0);
146
    }
147
148
  //
149
  // A-MPDU Status, information about the received A-MPDU.
150
  //
151
  if (m_present & RADIOTAP_AMPDU_STATUS) // bit 20
152
    {
153
      start.WriteU8(0, m_ampduStatusPad);
154
      start.WriteU32 (m_ampduStatusRef);
155
      start.WriteU16 (m_ampduStatusFlags);
156
      start.WriteU8 (m_ampduStatusCRC);
157
      start.WriteU8 (m_ampduStatusReserved);
158
    }
131
}
159
}
132
160
133
uint32_t
161
uint32_t
 Lines 176-184   RadiotapHeader::Deserialize (Buffer::Ite Link Here 
176
  //
204
  //
177
  if (m_present & RADIOTAP_CHANNEL) // bit 3
205
  if (m_present & RADIOTAP_CHANNEL) // bit 3
178
    {
206
    {
207
      m_channelPad = (2 - bytesRead % 2) % 2;
208
      start.Next(m_channelPad);
179
      m_channelFreq = start.ReadU16 ();
209
      m_channelFreq = start.ReadU16 ();
180
      m_channelFlags = start.ReadU16 ();
210
      m_channelFlags = start.ReadU16 ();
181
      bytesRead += 4;
211
      bytesRead += 4 + m_channelPad;
182
    }
212
    }
183
213
184
  //
214
  //
 Lines 211-216   RadiotapHeader::Deserialize (Buffer::Ite Link Here 
211
      ++bytesRead;
241
      ++bytesRead;
212
    }
242
    }
213
243
244
  //
245
  // A-MPDU Status, information about the received A-MPDU.
246
  //
247
  if (m_present & RADIOTAP_MCS) // bit 19
248
    {
249
      m_antennaNoise = start.ReadU8 ();
250
      m_antennaNoise = start.ReadU8 ();
251
      m_antennaNoise = start.ReadU8 ();
252
      bytesRead += 3;
253
    }
254
255
  //
256
  // A-MPDU Status, information about the received A-MPDU.
257
  //
258
  if (m_present & RADIOTAP_AMPDU_STATUS) // bit 20
259
    {
260
      m_ampduStatusPad = (4 - bytesRead % 4) % 4;
261
      start.Next(m_ampduStatusPad);
262
      m_ampduStatusRef = start.ReadU32 ();
263
      m_ampduStatusFlags = start.ReadU16 ();
264
      m_ampduStatusCRC = start.ReadU8 ();
265
      m_ampduStatusReserved = start.ReadU8 ();
266
      bytesRead += 8 + m_ampduStatusPad;
267
    }
268
214
  NS_ASSERT_MSG (m_length == bytesRead, "RadiotapHeader::Deserialize(): expected and actual lengths inconsistent");
269
  NS_ASSERT_MSG (m_length == bytesRead, "RadiotapHeader::Deserialize(): expected and actual lengths inconsistent");
215
  return bytesRead;
270
  return bytesRead;
216
}
271
}
 Lines 225-231   RadiotapHeader::Print (std::ostream &os) Link Here 
225
     << " freq=" << m_channelFreq
280
     << " freq=" << m_channelFreq
226
     << " chflags=" << std::hex << (uint32_t)m_channelFlags << std::dec
281
     << " chflags=" << std::hex << (uint32_t)m_channelFlags << std::dec
227
     << " signal=" << (int16_t) m_antennaSignal
282
     << " signal=" << (int16_t) m_antennaSignal
228
     << " noise=" << (int16_t) m_antennaNoise;
283
     << " noise=" << (int16_t) m_antennaNoise
284
     << " ampduStatusFlags=" << (int16_t) m_ampduStatusFlags;
229
}
285
}
230
286
231
void
287
void
 Lines 294-299   RadiotapHeader::GetRate (void) const Link Here 
294
  return m_rate;
350
  return m_rate;
295
}
351
}
296
352
353
void
354
RadiotapHeader::SetAmpduStatus (uint32_t referenceNumber, uint16_t flags, uint8_t crc)
355
{
356
  NS_LOG_FUNCTION (this << referenceNumber << flags);
357
  m_ampduStatusRef = referenceNumber;
358
  m_ampduStatusFlags = flags;
359
  m_ampduStatusCRC = crc;
360
  if (!(m_present & RADIOTAP_AMPDU_STATUS))
361
    {
362
      m_ampduStatusPad = (4 - m_length % 4) % 4;;
363
      m_present |= RADIOTAP_AMPDU_STATUS;
364
      m_length += 8 + m_ampduStatusPad;
365
    }
366
367
  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
368
}
369
370
uint16_t
371
RadiotapHeader::GetAmpduStatusFlags () const
372
{
373
  NS_LOG_FUNCTION (this);
374
  return m_ampduStatusFlags;
375
}
376
377
void
378
RadiotapHeader::SetMCS (uint32_t value)
379
{
380
  NS_LOG_FUNCTION (this << value);
381
382
  if (!(m_present & RADIOTAP_MCS))
383
    {
384
      m_present |= RADIOTAP_MCS;
385
      m_length += 3;
386
    }
387
388
  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
389
}
390
297
void 
391
void 
298
RadiotapHeader::SetChannelFrequencyAndFlags (uint16_t frequency, uint16_t flags)
392
RadiotapHeader::SetChannelFrequencyAndFlags (uint16_t frequency, uint16_t flags)
299
{
393
{
 Lines 303-310   RadiotapHeader::SetChannelFrequencyAndFl Link Here 
303
397
304
  if (!(m_present & RADIOTAP_CHANNEL))
398
  if (!(m_present & RADIOTAP_CHANNEL))
305
    {
399
    {
400
      m_channelPad = (2 - m_length % 2) % 2;
306
      m_present |= RADIOTAP_CHANNEL;
401
      m_present |= RADIOTAP_CHANNEL;
307
      m_length += 4;
402
      m_length += 4 + m_channelPad;
308
    }
403
    }
309
404
310
  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
405
  NS_LOG_LOGIC (this << " m_length=" << m_length << " m_present=0x" << std::hex << m_present << std::dec);
(-)original/src/network/utils/radiotap-header.h (-6 / +43 lines)
 Lines 16-21    Link Here 
16
 * Foundation, Include., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 * Foundation, Include., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
17
 *
18
 * Author: Nicola Baldo <nbaldo@cttc.es>
18
 * Author: Nicola Baldo <nbaldo@cttc.es>
19
 * Author: Hany Assasa <hany.assasa@imdea.org>
19
 */
20
 */
20
21
21
#ifndef RADIOTAP_HEADER_H
22
#ifndef RADIOTAP_HEADER_H
 Lines 159-164   public: Link Here 
159
  uint8_t GetRate (void) const;
160
  uint8_t GetRate (void) const;
160
161
161
  enum {
162
  enum {
163
    A_MPDU_STATUS_NONE                = 0x0000, /**< No flags set */
164
    A_MPDU_STATUS_REPORT_ZERO_LENGTH  = 0x0001, /**< Driver reports 0-length subframes */
165
    A_MPDU_STATUS_IS_ZERO_LENGTH      = 0x0002, /**< Frame is 0-length subframe (valid only if 0x0001 is set) */
166
    A_MPDU_STATUS_LAST_KNOWN          = 0x0004, /**< Last subframe is known (should be set for all subframes in an A-MPDU) */
167
    A_MPDU_STATUS_LAST                = 0x0008, /**< This frame is the last subframe */
168
    A_MPDU_STATUS_DELIMITER_CRC_ERROR = 0x0010, /**< Delimiter CRC error */
169
    A_MPDU_STATUS_DELIMITER_CRC_KNOWN = 0x0020  /**< Delimiter CRC value known: the delimiter CRC value field is valid */
170
  };
171
172
  /**
173
   * @brief Set A-MPDU status.
174
   * @param status The status of the frame which is part of an A-MPDU.
175
   */
176
  void SetAmpduStatus (uint32_t referenceNumber, uint16_t falgs, uint8_t crc);
177
178
  /**
179
   * @brief Get A-MPDU status.
180
   * @returns The status of the frame which is part of an A-MPDU.
181
   */
182
  uint16_t GetAmpduStatusFlags (void) const;
183
184
  enum {
162
    CHANNEL_FLAG_NONE          = 0x0000, /**< No flags set */
185
    CHANNEL_FLAG_NONE          = 0x0000, /**< No flags set */
163
    CHANNEL_FLAG_TURBO         = 0x0010, /**< Turbo Channel */
186
    CHANNEL_FLAG_TURBO         = 0x0010, /**< Turbo Channel */
164
    CHANNEL_FLAG_CCK           = 0x0020, /**< CCK channel */
187
    CHANNEL_FLAG_CCK           = 0x0020, /**< CCK channel */
 Lines 227-232   public: Link Here 
227
   */
250
   */
228
  uint8_t GetAntennaNoisePower (void) const;
251
  uint8_t GetAntennaNoisePower (void) const;
229
252
253
  void SetMCS (uint32_t value);
254
230
private:
255
private:
231
  enum {
256
  enum {
232
    RADIOTAP_TSFT              = 0x00000001,
257
    RADIOTAP_TSFT              = 0x00000001,
 Lines 239-261   private: Link Here 
239
    RADIOTAP_LOCK_QUALITY      = 0x00000080,
264
    RADIOTAP_LOCK_QUALITY      = 0x00000080,
240
    RADIOTAP_TX_ATTENUATION    = 0x00000100,
265
    RADIOTAP_TX_ATTENUATION    = 0x00000100,
241
    RADIOTAP_DB_TX_ATTENUATION = 0x00000200,
266
    RADIOTAP_DB_TX_ATTENUATION = 0x00000200,
242
    RADIOTAP_DBM_TX_POWER      = 0x00000200,
267
    RADIOTAP_DBM_TX_POWER      = 0x00000400,
243
    RADIOTAP_ANTENNA           = 0x00000400,
268
    RADIOTAP_ANTENNA           = 0x00000800,
244
    RADIOTAP_DB_ANTSIGNAL      = 0x00000800,
269
    RADIOTAP_DB_ANTSIGNAL      = 0x00001000,
245
    RADIOTAP_DB_ANTNOISE       = 0x00001000,
270
    RADIOTAP_DB_ANTNOISE       = 0x00002000,
271
    RADIOTAP_RX_FLAGS          = 0x00004000,
272
    RADIOTAP_MCS               = 0x00080000,
273
    RADIOTAP_AMPDU_STATUS      = 0x00100000, // The presence of this field indicates the frame was received as part of an A-MPDU.
274
    RADIOTAP_VHT               = 0x00200000,
246
    RADIOTAP_EXT               = 0x10000000
275
    RADIOTAP_EXT               = 0x10000000
247
  };
276
  };
248
 
277
 
249
  uint16_t m_length;        //!< entire length of radiotap data + header
278
  uint16_t m_length;        //!< Entire length of radiotap data + header
250
  uint32_t m_present;       //!< bits describing which fields follow header
279
  uint32_t m_present;       //!< Bits describing which fields follow header
251
280
252
  uint64_t m_tsft;          //!< Time Synchronization Function Timer (when the first bit of the MPDU arrived at the MAC)
281
  uint64_t m_tsft;          //!< Time Synchronization Function Timer (when the first bit of the MPDU arrived at the MAC)
253
  uint8_t m_flags;          //!< Properties of transmitted and received frames.
282
  uint8_t m_flags;          //!< Properties of transmitted and received frames.
254
  uint8_t m_rate;           //!< TX/RX data rate in units of 500 kbps
283
  uint8_t m_rate;           //!< TX/RX data rate in units of 500 kbps
284
  uint8_t m_channelPad;     //!< Tx/Rx channel Padding.
255
  uint16_t m_channelFreq;   //!< Tx/Rx frequency in MHz.
285
  uint16_t m_channelFreq;   //!< Tx/Rx frequency in MHz.
256
  uint16_t m_channelFlags;  //!< Tx/Rx channel flags.
286
  uint16_t m_channelFlags;  //!< Tx/Rx channel flags.
257
  int8_t m_antennaSignal;   //!< RF signal power at the antenna, dB difference from an arbitrary, fixed reference.
287
  int8_t m_antennaSignal;   //!< RF signal power at the antenna, dB difference from an arbitrary, fixed reference.
258
  int8_t m_antennaNoise;    //!< RF noise power at the antenna, dB difference from an arbitrary, fixed reference.
288
  int8_t m_antennaNoise;    //!< RF noise power at the antenna, dB difference from an arbitrary, fixed reference.
289
290
  uint8_t m_ampduStatusPad;       //!< A-MPDU Status Flags, Padding before A-MPDU Status Field.
291
  uint32_t m_ampduStatusRef;      //!< A-MPDU Status Flags, reference number.
292
  uint16_t m_ampduStatusFlags;    //!< A-MPDU Status Flags, information about the received A-MPDU.
293
  uint8_t m_ampduStatusCRC;       //!< A-MPDU Status Flags, delimiter CRC value.
294
  uint8_t m_ampduStatusReserved;  //!< A-MPDU Status Flags, reserved.
295
259
};
296
};
260
297
261
} // namespace ns3
298
} // namespace ns3
(-)original/src/wifi/helper/yans-wifi-helper.cc (-19 / +58 lines)
 Lines 16-21    Link Here 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
17
 *
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
 * Author: Hany Assasa <hany.assasa@imdea.org>
19
 */
20
 */
20
21
21
#include "ns3/trace-helper.h"
22
#include "ns3/trace-helper.h"
 Lines 33-38    Link Here 
33
#include "ns3/names.h"
34
#include "ns3/names.h"
34
#include "ns3/abort.h"
35
#include "ns3/abort.h"
35
#include "ns3/log.h"
36
#include "ns3/log.h"
37
#include "ns3/ampdu-subframe-header.h"
36
38
37
namespace ns3 {
39
namespace ns3 {
38
40
 Lines 248-259   YansWifiPhyHelper::Create (Ptr<Node> nod Link Here 
248
static void
250
static void
249
PcapSniffTxEvent (
251
PcapSniffTxEvent (
250
  Ptr<PcapFileWrapper> file,
252
  Ptr<PcapFileWrapper> file,
251
  Ptr<const Packet>    packet,
253
  Ptr<const Packet>   packet,
252
  uint16_t             channelFreqMhz,
254
  uint16_t            channelFreqMhz,
253
  uint16_t             channelNumber,
255
  uint16_t            channelNumber,
254
  uint32_t             rate,
256
  uint32_t            rate,
255
  bool                 isShortPreamble,
257
  bool                isShortPreamble,
256
  WifiTxVector         txvector)
258
  WifiTxVector        txvector,
259
  uint8_t             packetType)
257
{
260
{
258
  uint32_t dlt = file->GetDataLinkType ();
261
  uint32_t dlt = file->GetDataLinkType ();
259
262
 Lines 281-287   PcapSniffTxEvent ( Link Here 
281
          {
284
          {
282
            frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_PREAMBLE;
285
            frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_PREAMBLE;
283
          }
286
          }
284
          
287
285
        if (txvector.IsShortGuardInterval ())
288
        if (txvector.IsShortGuardInterval ())
286
          {
289
          {
287
            frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_GUARD;
290
            frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_GUARD;
 Lines 316-321   PcapSniffTxEvent ( Link Here 
316
319
317
        header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags);
320
        header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags);
318
321
322
        if (txvector.IsAggregated())
323
          {
324
            uint16_t ampduStatus_Flags = 0;
325
            ampduStatus_Flags |= RadiotapHeader::A_MPDU_STATUS_DELIMITER_CRC_KNOWN;
326
            ampduStatus_Flags |= RadiotapHeader::A_MPDU_STATUS_LAST_KNOWN;
327
            if (packetType == 2)
328
              ampduStatus_Flags |= RadiotapHeader::A_MPDU_STATUS_LAST;
329
330
            /* For PCAP file, MPDU Delimiter and Padding should be removed by the MAC Driver */
331
            AmpduSubframeHeader hdr;
332
            uint32_t extractedLength;
333
334
            p->RemoveHeader (hdr);
335
            extractedLength = hdr.GetLength ();
336
            p = p->CreateFragment (0, static_cast<uint32_t> (extractedLength));
337
            header.SetAmpduStatus (10, ampduStatus_Flags, hdr.GetCrc());
338
          }
339
319
        p->AddHeader (header);
340
        p->AddHeader (header);
320
        file->Write (Simulator::Now (), p);
341
        file->Write (Simulator::Now (), p);
321
        return;
342
        return;
 Lines 327-341   PcapSniffTxEvent ( Link Here 
327
348
328
static void
349
static void
329
PcapSniffRxEvent (
350
PcapSniffRxEvent (
330
  Ptr<PcapFileWrapper> file,
351
  Ptr<PcapFileWrapper> 	file,
331
  Ptr<const Packet>    packet,
352
  Ptr<const Packet>    	packet,
332
  uint16_t             channelFreqMhz,
353
  uint16_t             	channelFreqMhz,
333
  uint16_t             channelNumber,
354
  uint16_t             	channelNumber,
334
  uint32_t             rate,
355
  uint32_t             	rate,
335
  bool                 isShortPreamble,
356
  bool                 	isShortPreamble,
336
  WifiTxVector         txvector,
357
  WifiTxVector         	txvector,
337
  double               signalDbm,
358
  struct snrDbm         snr,
338
  double               noiseDbm)
359
  uint8_t               packetType)
339
{
360
{
340
  uint32_t dlt = file->GetDataLinkType ();
361
  uint32_t dlt = file->GetDataLinkType ();
341
362
 Lines 363-369   PcapSniffRxEvent ( Link Here 
363
          {
384
          {
364
            frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_PREAMBLE;
385
            frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_PREAMBLE;
365
          }
386
          }
366
          
387
367
        if (txvector.IsShortGuardInterval ())
388
        if (txvector.IsShortGuardInterval ())
368
          {
389
          {
369
            frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_GUARD;
390
            frameFlags |= RadiotapHeader::FRAME_FLAG_SHORT_GUARD;
 Lines 398-405   PcapSniffRxEvent ( Link Here 
398
419
399
        header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags);
420
        header.SetChannelFrequencyAndFlags (channelFreqMhz, channelFlags);
400
421
401
        header.SetAntennaSignalPower (signalDbm);
422
        header.SetAntennaSignalPower (snr.signal);
402
        header.SetAntennaNoisePower (noiseDbm);
423
        header.SetAntennaNoisePower (snr.noise);
424
425
        if (txvector.IsAggregated())
426
          {
427
            uint16_t ampduStatus_Flags = 0;
428
            ampduStatus_Flags |= RadiotapHeader::A_MPDU_STATUS_DELIMITER_CRC_KNOWN;
429
            ampduStatus_Flags |= RadiotapHeader::A_MPDU_STATUS_LAST_KNOWN;
430
            if (packetType == 2)
431
              ampduStatus_Flags |= RadiotapHeader::A_MPDU_STATUS_LAST;
432
433
            /* For PCAP file, MPDU Delimiter and Padding should be removed by the MAC Driver */
434
            AmpduSubframeHeader hdr;
435
            uint32_t extractedLength;
436
437
            p->RemoveHeader (hdr);
438
            extractedLength = hdr.GetLength ();
439
            p = p->CreateFragment (0, static_cast<uint32_t> (extractedLength));
440
            header.SetAmpduStatus (10, ampduStatus_Flags, hdr.GetCrc());
441
          }
403
442
404
        p->AddHeader (header);
443
        p->AddHeader (header);
405
        file->Write (Simulator::Now (), p);
444
        file->Write (Simulator::Now (), p);
(-)original/src/wifi/model/mac-low.cc (+1 lines)
 Lines 1545-1550   MacLow::ForwardDown (Ptr<const Packet> p Link Here 
1545
      AmpduTag ampdutag;
1545
      AmpduTag ampdutag;
1546
      ampdutag.SetAmpdu (true);
1546
      ampdutag.SetAmpdu (true);
1547
      Time delay = Seconds (0);
1547
      Time delay = Seconds (0);
1548
      txVector.SetAggregated (queueSize > 1);
1548
      for ( ; queueSize > 0; queueSize--)
1549
      for ( ; queueSize > 0; queueSize--)
1549
        {
1550
        {
1550
          dequeuedPacket = m_aggregateQueue->Dequeue (&newHdr);
1551
          dequeuedPacket = m_aggregateQueue->Dequeue (&newHdr);
(-)original/src/wifi/model/wifi-phy.cc (-4 / +5 lines)
 Lines 613-630   WifiPhy::NotifyRxDrop (Ptr<const Packet> Link Here 
613
}
613
}
614
614
615
void
615
void
616
WifiPhy::NotifyMonitorSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, WifiTxVector txvector, double signalDbm, double noiseDbm)
616
WifiPhy::NotifyMonitorSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, WifiTxVector txvector, struct snrDbm snr, uint8_t packetType)
617
{
617
{
618
  m_phyMonitorSniffRxTrace (packet, channelFreqMhz, channelNumber, rate, isShortPreamble, txvector, signalDbm, noiseDbm);
618
  m_phyMonitorSniffRxTrace (packet, channelFreqMhz, channelNumber, rate, isShortPreamble, txvector, snr, packetType);
619
}
619
}
620
620
621
void
621
void
622
WifiPhy::NotifyMonitorSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, WifiTxVector txvector)
622
WifiPhy::NotifyMonitorSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, WifiTxVector txvector, uint8_t packetType)
623
{
623
{
624
  m_phyMonitorSniffTxTrace (packet, channelFreqMhz, channelNumber, rate, isShortPreamble, txvector);
624
  m_phyMonitorSniffTxTrace (packet, channelFreqMhz, channelNumber, rate, isShortPreamble, txvector, packetType);
625
}
625
}
626
626
627
627
628
628
// Clause 15 rates (DSSS)
629
// Clause 15 rates (DSSS)
629
630
630
WifiMode
631
WifiMode
(-)original/src/wifi/model/wifi-phy.h (-10 / +18 lines)
 Lines 38-43   namespace ns3 { Link Here 
38
class WifiChannel;
38
class WifiChannel;
39
class NetDevice;
39
class NetDevice;
40
40
41
struct snrDbm
42
{
43
  double signal;
44
  double noise;
45
};
46
41
/**
47
/**
42
 * \brief receive notifications about phy events.
48
 * \brief receive notifications about phy events.
43
 */
49
 */
 Lines 998-1010   public: Link Here 
998
   *        units used both for the radiotap and for the prism header)
1004
   *        units used both for the radiotap and for the prism header)
999
   * \param isShortPreamble true if short preamble is used, false otherwise
1005
   * \param isShortPreamble true if short preamble is used, false otherwise
1000
   * \param txVector the txvector that holds rx parameters
1006
   * \param txVector the txvector that holds rx parameters
1001
   * \param signalDbm signal power in dBm
1007
   * \param signalDbm signal power and noise power in dBm
1002
   * \param noiseDbm  noise power in dBm
1008
   * \param packetType
1003
   */
1009
   */
1004
  void NotifyMonitorSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz,
1010
  void NotifyMonitorSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz,
1005
                             uint16_t channelNumber, uint32_t rate,
1011
                             uint16_t channelNumber, uint32_t rate,
1006
                             bool isShortPreamble, WifiTxVector txvector,
1012
                             bool isShortPreamble, WifiTxVector txvector,
1007
                             double signalDbm, double noiseDbm);
1013
                             struct snrDbm snr, uint8_t packetType);
1008
1014
1009
  /**
1015
  /**
1010
   * TracedCallback signature for monitor mode receive events.
1016
   * TracedCallback signature for monitor mode receive events.
 Lines 1023-1036   public: Link Here 
1023
   *        units used both for the radiotap and for the prism header)
1029
   *        units used both for the radiotap and for the prism header)
1024
   * \param isShortPreamble true if short preamble is used, false otherwise
1030
   * \param isShortPreamble true if short preamble is used, false otherwise
1025
   * \param txVector the txvector that holds rx parameters
1031
   * \param txVector the txvector that holds rx parameters
1026
   * \param signalDbm signal power in dBm
1032
   * \param signalDbm signal power and noise power in dBm
1027
   * \param noiseDbm noise power in dBm
1033
   * \param packetType
1028
   */
1034
   */
1029
  typedef void (* MonitorSnifferRxCallback)
1035
  typedef void (* MonitorSnifferRxCallback)
1030
    (Ptr<const Packet> packet, uint16_t channelFreqMhz,
1036
    (Ptr<const Packet> packet, uint16_t channelFreqMhz,
1031
     uint16_t channelNumber, uint32_t rate,
1037
     uint16_t channelNumber, uint32_t rate,
1032
     bool isShortPreamble, WifiTxVector txvector,
1038
     bool isShortPreamble, WifiTxVector txvector,
1033
     double signalDbm, double noiseDbm);
1039
     struct snrDbm snr, uint8_t);
1040
1034
1041
1035
  /**
1042
  /**
1036
   * Public method used to fire a MonitorSniffer trace for a wifi packet being transmitted.
1043
   * Public method used to fire a MonitorSniffer trace for a wifi packet being transmitted.
 Lines 1047-1053   public: Link Here 
1047
   */
1054
   */
1048
  void NotifyMonitorSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz,
1055
  void NotifyMonitorSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz,
1049
                             uint16_t channelNumber, uint32_t rate,
1056
                             uint16_t channelNumber, uint32_t rate,
1050
                             bool isShortPreamble, WifiTxVector txvector);
1057
                             bool isShortPreamble, WifiTxVector txvector, uint8_t packetType);
1051
1058
1052
  /**
1059
  /**
1053
   * TracedCallback signature for monitor mode transmit events.
1060
   * TracedCallback signature for monitor mode transmit events.
 Lines 1060-1070   public: Link Here 
1060
   *        units used both for the radiotap and for the prism header)
1067
   *        units used both for the radiotap and for the prism header)
1061
   * \param isShortPreamble true if short preamble is used, false otherwise
1068
   * \param isShortPreamble true if short preamble is used, false otherwise
1062
   * \param txVector the txvector that holds tx parameters
1069
   * \param txVector the txvector that holds tx parameters
1070
   * \param packetType Type of the packet
1063
   */
1071
   */
1064
  typedef void (* MonitorSnifferTxCallback)
1072
  typedef void (* MonitorSnifferTxCallback)
1065
    (const Ptr<const Packet> packet, uint16_t channelFreqMhz,
1073
    (const Ptr<const Packet> packet, uint16_t channelFreqMhz,
1066
     uint16_t channelNumber, uint32_t rate,
1074
     uint16_t channelNumber, uint32_t rate,
1067
     bool isShortPreamble, WifiTxVector txvector);
1075
     bool isShortPreamble, WifiTxVector txvector, uint8_t packetType);
1068
1076
1069
 /**
1077
 /**
1070
  * Assign a fixed random variable stream number to the random variables
1078
  * Assign a fixed random variable stream number to the random variables
 Lines 1200-1206   private: Link Here 
1200
   *
1208
   *
1201
   * \see class CallBackTraceSource
1209
   * \see class CallBackTraceSource
1202
   */
1210
   */
1203
  TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool, WifiTxVector, double, double> m_phyMonitorSniffRxTrace;
1211
  TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool, WifiTxVector, struct snrDbm, uint8_t> m_phyMonitorSniffRxTrace;
1204
1212
1205
  /**
1213
  /**
1206
   * A trace source that emulates a wifi device in monitor mode
1214
   * A trace source that emulates a wifi device in monitor mode
 Lines 1212-1218   private: Link Here 
1212
   *
1220
   *
1213
   * \see class CallBackTraceSource
1221
   * \see class CallBackTraceSource
1214
   */
1222
   */
1215
  TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool, WifiTxVector> m_phyMonitorSniffTxTrace;
1223
  TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool, WifiTxVector, uint8_t> m_phyMonitorSniffTxTrace;
1216
    
1224
    
1217
  uint32_t m_totalAmpduNumSymbols; //!< Number of symbols previously transmitted for the MPDUs in an A-MPDU, used for the computation of the number of symbols needed for the last MPDU in the A-MPDU
1225
  uint32_t m_totalAmpduNumSymbols; //!< Number of symbols previously transmitted for the MPDUs in an A-MPDU, used for the computation of the number of symbols needed for the last MPDU in the A-MPDU
1218
  uint32_t m_totalAmpduSize;       //!< Total size of the previously transmitted MPDUs in an A-MPDU, used for the computation of the number of symbols needed for the last MPDU in the A-MPDU
1226
  uint32_t m_totalAmpduSize;       //!< Total size of the previously transmitted MPDUs in an A-MPDU, used for the computation of the number of symbols needed for the last MPDU in the A-MPDU
(-)original/src/wifi/model/wifi-tx-vector.cc (-1 / +29 lines)
 Lines 17-22    Link Here 
17
 *
17
 *
18
 * Author: Nicola Baldo <nbaldo@cttc.es>
18
 * Author: Nicola Baldo <nbaldo@cttc.es>
19
 *       : Ghada Badawy <gbadawy@gmail.com>
19
 *       : Ghada Badawy <gbadawy@gmail.com>
20
 *		 : Hany Assasa <hany.assasa@imdea.org>
20
 */
21
 */
21
22
22
#include "ns3/wifi-tx-vector.h"
23
#include "ns3/wifi-tx-vector.h"
 Lines 30-35   WifiTxVector::WifiTxVector () Link Here 
30
    m_nss (1),
31
    m_nss (1),
31
    m_ness (0),
32
    m_ness (0),
32
    m_stbc (false),
33
    m_stbc (false),
34
    m_aggregated (false),
33
    m_modeInitialized (false),
35
    m_modeInitialized (false),
34
    m_txPowerLevelInitialized (false)
36
    m_txPowerLevelInitialized (false)
35
{
37
{
 Lines 44-49   WifiTxVector::WifiTxVector (WifiMode mod Link Here 
44
    m_nss(nss),
46
    m_nss(nss),
45
    m_ness(ness),
47
    m_ness(ness),
46
    m_stbc(stbc),
48
    m_stbc(stbc),
49
    m_aggregated (false),
47
    m_modeInitialized (true),
50
    m_modeInitialized (true),
48
    m_txPowerLevelInitialized (true)
51
    m_txPowerLevelInitialized (true)
49
{
52
{
 Lines 58-63   WifiTxVector::GetMode (void) const Link Here 
58
    }
61
    }
59
  return m_mode;
62
  return m_mode;
60
}
63
}
64
61
uint8_t 
65
uint8_t 
62
WifiTxVector::GetTxPowerLevel (void) const
66
WifiTxVector::GetTxPowerLevel (void) const
63
{
67
{
 Lines 67-92   WifiTxVector::GetTxPowerLevel (void) con Link Here 
67
    }
71
    }
68
  return m_txPowerLevel;
72
  return m_txPowerLevel;
69
}
73
}
74
70
uint8_t 
75
uint8_t 
71
WifiTxVector::GetRetries (void) const
76
WifiTxVector::GetRetries (void) const
72
{
77
{
73
  return m_retries;
78
  return m_retries;
74
}
79
}
80
75
bool 
81
bool 
76
WifiTxVector::IsShortGuardInterval (void) const
82
WifiTxVector::IsShortGuardInterval (void) const
77
{
83
{
78
 return m_shortGuardInterval;
84
 return m_shortGuardInterval;
79
}
85
}
86
80
uint8_t 
87
uint8_t 
81
WifiTxVector::GetNss (void) const
88
WifiTxVector::GetNss (void) const
82
{
89
{
83
  return m_nss;
90
  return m_nss;
84
}
91
}
92
85
uint8_t 
93
uint8_t 
86
WifiTxVector::GetNess (void) const
94
WifiTxVector::GetNess (void) const
87
{
95
{
88
  return m_ness;
96
  return m_ness;
89
}
97
}
98
90
bool 
99
bool 
91
WifiTxVector::IsStbc (void) const
100
WifiTxVector::IsStbc (void) const
92
{
101
{
 Lines 99-136   WifiTxVector::SetMode (WifiMode mode) Link Here 
99
  m_mode=mode;
108
  m_mode=mode;
100
  m_modeInitialized = true;
109
  m_modeInitialized = true;
101
}
110
}
111
102
void 
112
void 
103
WifiTxVector::SetTxPowerLevel (uint8_t powerlevel)
113
WifiTxVector::SetTxPowerLevel (uint8_t powerlevel)
104
{
114
{
105
  m_txPowerLevel=powerlevel;
115
  m_txPowerLevel=powerlevel;
106
  m_txPowerLevelInitialized = true;
116
  m_txPowerLevelInitialized = true;
107
}
117
}
118
108
void 
119
void 
109
WifiTxVector::SetRetries (uint8_t retries)
120
WifiTxVector::SetRetries (uint8_t retries)
110
{
121
{
111
  m_retries = retries;
122
  m_retries = retries;
112
}
123
}
124
113
void 
125
void 
114
WifiTxVector::SetShortGuardInterval (bool guardinterval)
126
WifiTxVector::SetShortGuardInterval (bool guardinterval)
115
{
127
{
116
  m_shortGuardInterval=guardinterval;
128
  m_shortGuardInterval=guardinterval;
117
}
129
}
130
118
void 
131
void 
119
WifiTxVector::SetNss (uint8_t nss)
132
WifiTxVector::SetNss (uint8_t nss)
120
{
133
{
121
  m_nss= nss;
134
  m_nss= nss;
122
}
135
}
136
123
void 
137
void 
124
WifiTxVector::SetNess (uint8_t ness)
138
WifiTxVector::SetNess (uint8_t ness)
125
{
139
{
126
  m_ness=ness;
140
  m_ness=ness;
127
}
141
}
142
128
void 
143
void 
129
WifiTxVector::SetStbc (bool stbc)
144
WifiTxVector::SetStbc (bool stbc)
130
{
145
{
131
  m_stbc=stbc;
146
  m_stbc=stbc;
132
}
147
}
133
148
149
bool
150
WifiTxVector::IsAggregated (void) const
151
{
152
  return m_aggregated;
153
}
154
155
void
156
WifiTxVector::SetAggregated (bool aggregated)
157
{
158
  m_aggregated = aggregated;
159
}
160
134
std::ostream & operator << ( std::ostream &os, const WifiTxVector &v)
161
std::ostream & operator << ( std::ostream &os, const WifiTxVector &v)
135
{ 
162
{ 
136
  os << "mode:" << v.GetMode() <<
163
  os << "mode:" << v.GetMode() <<
 Lines 139-145   std::ostream & operator << ( std::ostrea Link Here 
139
    " Short GI: " << v.IsShortGuardInterval() <<
166
    " Short GI: " << v.IsShortGuardInterval() <<
140
    " Nss: " << (uint32_t)v.GetNss() <<
167
    " Nss: " << (uint32_t)v.GetNss() <<
141
    " Ness: " << (uint32_t)v.GetNess() <<
168
    " Ness: " << (uint32_t)v.GetNess() <<
142
    " STBC: " << v.IsStbc();
169
    " STBC: " << v.IsStbc() <<
170
    " Aggregation: " << v.IsAggregated();
143
  return os;
171
  return os;
144
}
172
}
145
173
(-)original/src/wifi/model/wifi-tx-vector.h (-1 / +14 lines)
 Lines 17-22    Link Here 
17
 *
17
 *
18
 * Author: Nicola Baldo <nbaldo@cttc.es>
18
 * Author: Nicola Baldo <nbaldo@cttc.es>
19
 *       : Ghada Badawy <gbadawy@gmail.com>
19
 *       : Ghada Badawy <gbadawy@gmail.com>
20
 *       : Hany Assasa <hany.assasa@imdea.org>
20
 */
21
 */
21
22
22
#ifndef WIFI_TX_VECTOR_H
23
#ifndef WIFI_TX_VECTOR_H
 Lines 146-153   public: Link Here 
146
   * \param stbc enable or disable STBC
147
   * \param stbc enable or disable STBC
147
   */
148
   */
148
  void SetStbc (bool stbc);
149
  void SetStbc (bool stbc);
150
  /**
151
   * Checks whether the PSDU contains A-MPDU.
152
   *  \returns true if this packet has A-MPDU aggregation,
153
   *           false otherwise.
154
   */
155
  bool IsAggregated (void) const;
156
  /**
157
   * Sets if PSDU contains A-MPDU.
158
   *
159
   * \param aggregated whether the packet contains A-MPDU or not.
160
   */
161
  void SetAggregated(bool aggregated);
149
162
150
  
151
private:
163
private:
152
164
153
  WifiMode m_mode;         /**< The DATARATE parameter in Table 15-4. 
165
  WifiMode m_mode;         /**< The DATARATE parameter in Table 15-4. 
 Lines 162-167   private: Link Here 
162
  uint8_t  m_nss; /**< number of streams */
174
  uint8_t  m_nss; /**< number of streams */
163
  uint8_t  m_ness; /**< number of streams in beamforming */
175
  uint8_t  m_ness; /**< number of streams in beamforming */
164
  bool     m_stbc; /**< STBC used or not */
176
  bool     m_stbc; /**< STBC used or not */
177
  bool     m_aggregated;  /** Flag whether the PSDU contains A-MPDU. */
165
178
166
  bool     m_modeInitialized; //*< Internal initialization flag */
179
  bool     m_modeInitialized; //*< Internal initialization flag */
167
  bool     m_txPowerLevelInitialized; //*< Internal initialization flag */
180
  bool     m_txPowerLevelInitialized; //*< Internal initialization flag */
(-)original/src/wifi/model/yans-wifi-phy.cc (-4 / +6 lines)
 Lines 779-785   YansWifiPhy::SendPacket (Ptr<const Packe Link Here 
779
      dataRate500KbpsUnits = txVector.GetMode ().GetDataRate () * txVector.GetNss () / 500000;
779
      dataRate500KbpsUnits = txVector.GetMode ().GetDataRate () * txVector.GetNss () / 500000;
780
    }
780
    }
781
  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
781
  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
782
  NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, txVector);
782
  NotifyMonitorSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, txVector, packetType);
783
  m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector, preamble);
783
  m_state->SwitchToTx (txDuration, packet, GetPowerDbm (txVector.GetTxPowerLevel ()), txVector, preamble);
784
  m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + m_txGainDb, txVector, preamble, packetType, txDuration);
784
  m_channel->Send (this, packet, GetPowerDbm (txVector.GetTxPowerLevel ()) + m_txGainDb, txVector, preamble, packetType, txDuration);
785
}
785
}
 Lines 1097-1105   YansWifiPhy::EndReceive (Ptr<Packet> pac Link Here 
1097
              dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () * event->GetTxVector ().GetNss () / 500000;
1097
              dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () * event->GetTxVector ().GetNss () / 500000;
1098
            }
1098
            }
1099
          bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
1099
          bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());
1100
          double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
1100
          struct snrDbm snr;
1101
          double noiseDbm = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
1101
          snr.signal = RatioToDb (event->GetRxPowerW ()) + 30;
1102
          NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, event->GetTxVector (), signalDbm, noiseDbm);
1102
          snr.noise = RatioToDb (event->GetRxPowerW () / snrPer.snr) - GetRxNoiseFigure () + 30;
1103
1104
          NotifyMonitorSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, event->GetTxVector (), snr, packetType);
1103
          m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ());
1105
          m_state->SwitchFromRxEndOk (packet, snrPer.snr, event->GetTxVector (), event->GetPreambleType ());
1104
        }
1106
        }
1105
      else
1107
      else

Return to bug 2096