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

(-)a/src/common/pcap-writer.cc (-19 / +33 lines)
 Lines 169-175    Link Here 
169
}
169
}
170
170
171
171
172
void PcapWriter::WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t channelFreqMhz, 
172
void PcapWriter::WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber,                                        
173
                                        uint32_t rate, bool isShortPreamble, bool isTx, 
173
                                        uint32_t rate, bool isShortPreamble, bool isTx, 
174
                                        double signalDbm, double noiseDbm)
174
                                        double signalDbm, double noiseDbm)
175
{  
175
{  
 Lines 251-260    Link Here 
251
251
252
      Write32(PRISM_DID_CHANNEL);
252
      Write32(PRISM_DID_CHANNEL);
253
      Write16(PRISM_STATUS_PRESENT);
253
      Write16(PRISM_STATUS_PRESENT);
254
      Write16(PRISM_ITEM_LENGTH); 
254
      Write16(PRISM_ITEM_LENGTH);             
255
      // convert from frequency to channel number. This conversion is
255
      Write32((uint32_t) channelNumber);
256
      // correct only for IEEE 802.11b/g channels 1-13.
257
      Write32((2437 - 2407) / 5);
258
256
259
      Write32(PRISM_DID_RSSI);
257
      Write32(PRISM_DID_RSSI);
260
      Write16(PRISM_STATUS_PRESENT);
258
      Write16(PRISM_STATUS_PRESENT);
 Lines 335-348    Link Here 
335
#define	RADIOTAP_FLAG_DATAPAD	   0x20	
333
#define	RADIOTAP_FLAG_DATAPAD	   0x20	
336
#define	RADIOTAP_FLAG_BADFCS	   0x40	
334
#define	RADIOTAP_FLAG_BADFCS	   0x40	
337
335
338
#define	RADIOTAP_CHANNEL_TURBO	  0x0010
336
#define	RADIOTAP_CHANNEL_TURBO	         0x0010
339
#define	RADIOTAP_CHANNEL_CCK	  0x0020
337
#define	RADIOTAP_CHANNEL_CCK	         0x0020
340
#define	RADIOTAP_CHANNEL_OFDM	  0x0040
338
#define	RADIOTAP_CHANNEL_OFDM	         0x0040
341
#define	RADIOTAP_CHANNEL_2GHZ	  0x0080
339
#define	RADIOTAP_CHANNEL_2GHZ	         0x0080
342
#define	RADIOTAP_CHANNEL_5GHZ	  0x0100
340
#define	RADIOTAP_CHANNEL_5GHZ	         0x0100
343
#define	RADIOTAP_CHANNEL_PASSIVE  0x0200
341
#define	RADIOTAP_CHANNEL_PASSIVE         0x0200
344
#define	RADIOTAP_CHANNEL_DYN	  0x0400
342
#define	RADIOTAP_CHANNEL_DYN_CCK_OFDM    0x0400
345
#define	RADIOTAP_CHANNEL_GFSK	  0x0800
343
#define	RADIOTAP_CHANNEL_GFSK	         0x0800
344
#define	RADIOTAP_CHANNEL_GSM             0x1000
345
#define	RADIOTAP_CHANNEL_STATIC_TURBO    0x2000
346
#define	RADIOTAP_CHANNEL_HALF_RATE       0x4000
347
#define	RADIOTAP_CHANNEL_QUARTER_RATE    0x8000
346
348
347
#define RADIOTAP_RX_PRESENT (RADIOTAP_TSFT | RADIOTAP_FLAGS | RADIOTAP_RATE | RADIOTAP_CHANNEL | RADIOTAP_DBM_ANTSIGNAL | RADIOTAP_DBM_ANTNOISE)
349
#define RADIOTAP_RX_PRESENT (RADIOTAP_TSFT | RADIOTAP_FLAGS | RADIOTAP_RATE | RADIOTAP_CHANNEL | RADIOTAP_DBM_ANTSIGNAL | RADIOTAP_DBM_ANTNOISE)
348
#define RADIOTAP_RX_LENGTH (8+8+1+1+2+2+1+1)
350
#define RADIOTAP_RX_LENGTH (8+8+1+1+2+2+1+1)
 Lines 388-399    Link Here 
388
390
389
      Write8(rate); 
391
      Write8(rate); 
390
392
391
      Write16((uint16_t) 2437); 
393
      Write16(channelFreqMhz); 
392
394
      
393
      // we might want to make this setting depend on the WifiMode and
395
      uint16_t channelFlags;
394
      // on the ChannelFrequency at some time in the future. But for now
396
      if (channelFreqMhz < 2500)
395
      // I think a fixed setting is more than enough for most purposes.
397
        {
396
      Write16(RADIOTAP_CHANNEL_OFDM | RADIOTAP_CHANNEL_2GHZ); 
398
          // TODO: when 802.11g WifiModes will be implemented
399
          // we will need to check dinamically whether channelFlags
400
          // needs to be set to RADIOTAP_CHANNEL_CCK,
401
          // RADIOTAP_CHANNEL_DYN or RADIOTAP_CHANNEL_OFDM.          
402
          channelFlags = RADIOTAP_CHANNEL_2GHZ | RADIOTAP_CHANNEL_CCK;
403
        }
404
      else
405
        {
406
          // TODO: we should handle correctly the case of half rate
407
          // (10 MHz channel) and quarter rate (5 Mhz channel). 
408
          channelFlags = RADIOTAP_CHANNEL_5GHZ | RADIOTAP_CHANNEL_OFDM;
409
        }                
410
      Write16(channelFlags); 
397
    
411
    
398
      if (!isTx)
412
      if (!isTx)
399
        {
413
        {
(-)a/src/common/pcap-writer.h (-1 / +3 lines)
 Lines 116-121    Link Here 
116
   * transmitted. This is because it is possible to have the receiver
116
   * transmitted. This is because it is possible to have the receiver
117
   * tuned on a given channel and still to be able to receive packets
117
   * tuned on a given channel and still to be able to receive packets
118
   * on a nearby channel.
118
   * on a nearby channel.
119
   * @param channelNumber the channel number, as defined by the
120
   * IEEE 802.11 standard. 
119
   * @param rate the PHY data rate in units of 500kbps (i.e., the same
121
   * @param rate the PHY data rate in units of 500kbps (i.e., the same
120
   * units used both for the radiotap and for the prism header) 
122
   * units used both for the radiotap and for the prism header) 
121
   * @param isShortPreamble true if short preamble is used, false otherwise
123
   * @param isShortPreamble true if short preamble is used, false otherwise
 Lines 124-130    Link Here 
124
   * @param signalDbm signal power in dBm
126
   * @param signalDbm signal power in dBm
125
   * @param noiseDbm  noise power in dBm
127
   * @param noiseDbm  noise power in dBm
126
   */
128
   */
127
  void WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t channelFreqMhz, 
129
  void WriteWifiMonitorPacket(Ptr<const Packet> packet, uint16_t channelFreqMhz,  uint16_t channelNumber,
128
                              uint32_t rate, bool isShortPreamble, bool isTx, 
130
                              uint32_t rate, bool isShortPreamble, bool isTx, 
129
                              double signalDbm, double noiseDbm);
131
                              double signalDbm, double noiseDbm);
130
132
(-)a/src/devices/wifi/wifi-phy.cc (-4 / +4 lines)
 Lines 205-219    Link Here 
205
}
205
}
206
206
207
void 
207
void 
208
WifiPhy::NotifyPromiscSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
208
WifiPhy::NotifyPromiscSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
209
{
209
{
210
  m_phyPromiscSniffRxTrace (packet, channelFreqMhz, rate, isShortPreamble, signalDbm, noiseDbm);
210
  m_phyPromiscSniffRxTrace (packet, channelFreqMhz, channelNumber, rate, isShortPreamble, signalDbm, noiseDbm);
211
}
211
}
212
212
213
void 
213
void 
214
WifiPhy::NotifyPromiscSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble)
214
WifiPhy::NotifyPromiscSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble)
215
{
215
{
216
  m_phyPromiscSniffTxTrace (packet, channelFreqMhz, rate, isShortPreamble);
216
  m_phyPromiscSniffTxTrace (packet, channelFreqMhz, channelNumber, rate, isShortPreamble);
217
}
217
}
218
218
219
WifiMode 
219
WifiMode 
(-)a/src/devices/wifi/wifi-phy.h (-4 / +4 lines)
 Lines 341-347    Link Here 
341
   * @param signalDbm signal power in dBm
341
   * @param signalDbm signal power in dBm
342
   * @param noiseDbm  noise power in dBm
342
   * @param noiseDbm  noise power in dBm
343
   */
343
   */
344
  void NotifyPromiscSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble, 
344
  void NotifyPromiscSniffRx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble, 
345
                             double signalDbm, double noiseDbm);
345
                             double signalDbm, double noiseDbm);
346
346
347
  /** 
347
  /** 
 Lines 361-367    Link Here 
361
   * units used both for the radiotap and for the prism header) 
361
   * units used both for the radiotap and for the prism header) 
362
   * @param isShortPreamble true if short preamble is used, false otherwise
362
   * @param isShortPreamble true if short preamble is used, false otherwise
363
   */
363
   */
364
  void NotifyPromiscSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint32_t rate, bool isShortPreamble);
364
  void NotifyPromiscSniffTx (Ptr<const Packet> packet, uint16_t channelFreqMhz, uint16_t channelNumber, uint32_t rate, bool isShortPreamble);
365
  
365
  
366
366
367
private:
367
private:
 Lines 422-428    Link Here 
422
   *
422
   *
423
   * \see class CallBackTraceSource
423
   * \see class CallBackTraceSource
424
   */
424
   */
425
  TracedCallback<Ptr<const Packet>, uint16_t, uint32_t, bool, double, double> m_phyPromiscSniffRxTrace;
425
  TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool, double, double> m_phyPromiscSniffRxTrace;
426
426
427
  /**
427
  /**
428
   * A trace source that emulates a wifi device in monitor mode
428
   * A trace source that emulates a wifi device in monitor mode
 Lines 434-440    Link Here 
434
   *
434
   *
435
   * \see class CallBackTraceSource
435
   * \see class CallBackTraceSource
436
   */
436
   */
437
  TracedCallback<Ptr<const Packet>, uint16_t, uint32_t, bool> m_phyPromiscSniffTxTrace;
437
  TracedCallback<Ptr<const Packet>, uint16_t, uint16_t, uint32_t, bool> m_phyPromiscSniffTxTrace;
438
438
439
};
439
};
440
440
(-)a/src/devices/wifi/yans-wifi-phy.cc (-2 / +2 lines)
 Lines 451-457    Link Here 
451
  NotifyTxBegin (packet);
451
  NotifyTxBegin (packet);
452
  uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;   
452
  uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;   
453
  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
453
  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
454
  NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble);
454
  NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble);
455
  m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
455
  m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
456
  m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
456
  m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
457
}
457
}
 Lines 657-663    Link Here 
657
      bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());  
657
      bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());  
658
      double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
658
      double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30;
659
      double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNoiseFigure() + 30 ;
659
      double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNoiseFigure() + 30 ;
660
      NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
660
      NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm);
661
      m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
661
      m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ());
662
    } 
662
    } 
663
  else 
663
  else 
(-)a/src/helper/yans-wifi-helper.cc (-4 / +4 lines)
 Lines 31-48    Link Here 
31
31
32
namespace ns3 {
32
namespace ns3 {
33
33
34
static void PcapSniffTxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet, uint16_t channelFreqMhz,  
34
static void PcapSniffTxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet, uint16_t channelFreqMhz,  uint16_t channelNumber, 
35
                              uint32_t rate, bool isShortPreamble)
35
                              uint32_t rate, bool isShortPreamble)
36
{
36
{
37
  const double unusedValue = 0;
37
  const double unusedValue = 0;
38
  writer->WriteWifiMonitorPacket(packet, channelFreqMhz, rate, isShortPreamble, true, unusedValue, unusedValue); 
38
  writer->WriteWifiMonitorPacket(packet, channelFreqMhz, channelNumber, rate, isShortPreamble, true, unusedValue, unusedValue); 
39
}
39
}
40
40
41
41
42
static void PcapSniffRxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet, uint16_t channelFreqMhz,  
42
static void PcapSniffRxEvent (Ptr<PcapWriter> writer, Ptr<const Packet> packet, uint16_t channelFreqMhz,  uint16_t channelNumber,
43
                              uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
43
                              uint32_t rate, bool isShortPreamble, double signalDbm, double noiseDbm)
44
{
44
{
45
  writer->WriteWifiMonitorPacket(packet, channelFreqMhz, rate, isShortPreamble, false, signalDbm, noiseDbm); 
45
  writer->WriteWifiMonitorPacket(packet, channelFreqMhz, channelNumber, rate, isShortPreamble, false, signalDbm, noiseDbm); 
46
}
46
}
47
47
48
48

Return to bug 644