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

(-)a/src/devices/wifi/mac-low.cc (-1 / +1 lines)
 Lines 1135-1141    Link Here 
1135
            ", mode=" << txMode <<
1135
            ", mode=" << txMode <<
1136
            ", duration=" << hdr->GetDuration () <<
1136
            ", duration=" << hdr->GetDuration () <<
1137
            ", seq=0x"<< std::hex << m_currentHdr.GetSequenceControl () << std::dec);
1137
            ", seq=0x"<< std::hex << m_currentHdr.GetSequenceControl () << std::dec);
1138
  m_phy->SendPacket (packet, txMode, WIFI_PREAMBLE_LONG, 0);
1138
  m_phy->SendPacket (packet, txMode, WIFI_PREAMBLE_LONG);
1139
}
1139
}
1140
1140
1141
void
1141
void
(-)a/src/devices/wifi/wifi-phy-test.cc (-15 / +18 lines)
 Lines 44-50    Link Here 
44
    Input ();
44
    Input ();
45
    double distance;
45
    double distance;
46
    std::string txMode;
46
    std::string txMode;
47
    uint8_t txPowerLevel;
47
    double txPowerDbm;
48
    uint32_t packetSize;
48
    uint32_t packetSize;
49
    uint32_t nPackets;
49
    uint32_t nPackets;
50
  };
50
  };
 Lines 59-65    Link Here 
59
private:
59
private:
60
  void Send (void);
60
  void Send (void);
61
  void Receive (Ptr<Packet> p, double snr, WifiMode mode, enum WifiPreamble preamble);
61
  void Receive (Ptr<Packet> p, double snr, WifiMode mode, enum WifiPreamble preamble);
62
  Ptr<WifiPhy> m_tx;
62
  Ptr<YansWifiPhy> m_tx;
63
  struct Input m_input;
63
  struct Input m_input;
64
  struct Output m_output;
64
  struct Output m_output;
65
};
65
};
 Lines 69-75    Link Here 
69
{
69
{
70
  Ptr<Packet> p = Create<Packet> (m_input.packetSize);
70
  Ptr<Packet> p = Create<Packet> (m_input.packetSize);
71
  WifiMode mode = WifiMode (m_input.txMode);
71
  WifiMode mode = WifiMode (m_input.txMode);
72
  m_tx->SendPacket (p, mode, WIFI_PREAMBLE_SHORT, m_input.txPowerLevel);
72
  m_tx->SetTxPower (m_input.txPowerDbm);
73
  m_tx->SendPacket (p, mode, WIFI_PREAMBLE_SHORT);
73
}
74
}
74
75
75
void 
76
void 
 Lines 83-89    Link Here 
83
PsrExperiment::Input::Input ()
84
PsrExperiment::Input::Input ()
84
  : distance (5.0),
85
  : distance (5.0),
85
    txMode ("OfdmRate6Mbps"),
86
    txMode ("OfdmRate6Mbps"),
86
    txPowerLevel (0),
87
    txPowerDbm (16.0206),
87
    packetSize (2304),
88
    packetSize (2304),
88
    nPackets (400)
89
    nPackets (400)
89
{}
90
{}
 Lines 137-144    Link Here 
137
    double xB;
138
    double xB;
138
    std::string txModeA;
139
    std::string txModeA;
139
    std::string txModeB;
140
    std::string txModeB;
140
    uint8_t txPowerLevelA;
141
    double txPowerDbmA;
141
    uint8_t txPowerLevelB;
142
    double txPowerDbmB;
142
    uint32_t packetSizeA;
143
    uint32_t packetSizeA;
143
    uint32_t packetSizeB;
144
    uint32_t packetSizeB;
144
    uint32_t nPackets;
145
    uint32_t nPackets;
 Lines 155-162    Link Here 
155
  void SendA (void) const;
156
  void SendA (void) const;
156
  void SendB (void) const;
157
  void SendB (void) const;
157
  void Receive (Ptr<Packet> p, double snr, WifiMode mode, enum WifiPreamble preamble);
158
  void Receive (Ptr<Packet> p, double snr, WifiMode mode, enum WifiPreamble preamble);
158
  Ptr<WifiPhy> m_txA;
159
  Ptr<YansWifiPhy> m_txA;
159
  Ptr<WifiPhy> m_txB;
160
  Ptr<YansWifiPhy> m_txB;
160
  uint32_t m_flowIdA;
161
  uint32_t m_flowIdA;
161
  uint32_t m_flowIdB;
162
  uint32_t m_flowIdB;
162
  struct Input m_input;
163
  struct Input m_input;
 Lines 168-175    Link Here 
168
{
169
{
169
  Ptr<Packet> p = Create<Packet> (m_input.packetSizeA);
170
  Ptr<Packet> p = Create<Packet> (m_input.packetSizeA);
170
  p->AddByteTag (FlowIdTag (m_flowIdA));
171
  p->AddByteTag (FlowIdTag (m_flowIdA));
172
  m_txA->SetTxPower (m_input.txPowerDbmA);
171
  m_txA->SendPacket (p, WifiMode (m_input.txModeA), 
173
  m_txA->SendPacket (p, WifiMode (m_input.txModeA), 
172
		     WIFI_PREAMBLE_SHORT, m_input.txPowerLevelA);
174
		     WIFI_PREAMBLE_SHORT);
173
}
175
}
174
176
175
void 
177
void 
 Lines 177-184    Link Here 
177
{
179
{
178
  Ptr<Packet> p = Create<Packet> (m_input.packetSizeB);
180
  Ptr<Packet> p = Create<Packet> (m_input.packetSizeB);
179
  p->AddByteTag (FlowIdTag (m_flowIdB));
181
  p->AddByteTag (FlowIdTag (m_flowIdB));
182
  m_txB->SetTxPower (m_input.txPowerDbmB);
180
  m_txB->SendPacket (p, WifiMode (m_input.txModeB), 
183
  m_txB->SendPacket (p, WifiMode (m_input.txModeB), 
181
		     WIFI_PREAMBLE_SHORT, m_input.txPowerLevelB);
184
		     WIFI_PREAMBLE_SHORT);
182
}
185
}
183
186
184
void 
187
void 
 Lines 204-211    Link Here 
204
    xB (5),
207
    xB (5),
205
    txModeA ("OfdmRate6Mbps"),
208
    txModeA ("OfdmRate6Mbps"),
206
    txModeB ("OfdmRate6Mbps"),
209
    txModeB ("OfdmRate6Mbps"),
207
    txPowerLevelA (0),
210
    txPowerDbmA (16.0206),
208
    txPowerLevelB (0),
211
    txPowerDbmB (16.0206),
209
    packetSizeA (2304),
212
    packetSizeA (2304),
210
    packetSizeB (2304),
213
    packetSizeB (2304),
211
    nPackets (400)
214
    nPackets (400)
 Lines 276-282    Link Here 
276
  cmd.AddValue ("PacketSize", "The size of each packet sent", input.packetSize);
279
  cmd.AddValue ("PacketSize", "The size of each packet sent", input.packetSize);
277
  cmd.AddValue ("TxMode", "The mode to use to send each packet", input.txMode);
280
  cmd.AddValue ("TxMode", "The mode to use to send each packet", input.txMode);
278
  cmd.AddValue ("NPackets", "The number of packets to send", input.nPackets);
281
  cmd.AddValue ("NPackets", "The number of packets to send", input.nPackets);
279
  cmd.AddValue ("TxPowerLevel", "The power level index to use to send each packet", input.txPowerLevel);
282
  cmd.AddValue ("TxPowerLevel", "The power level index to use to send each packet", input.txPowerDbm);
280
  cmd.Parse (argc, argv);
283
  cmd.Parse (argc, argv);
281
284
282
  struct PsrExperiment::Output output;
285
  struct PsrExperiment::Output output;
 Lines 299-305    Link Here 
299
{
302
{
300
  struct PsrExperiment::Input input;
303
  struct PsrExperiment::Input input;
301
  CommandLine cmd;
304
  CommandLine cmd;
302
  cmd.AddValue ("TxPowerLevel", "The power level index to use to send each packet", input.txPowerLevel);  
305
  cmd.AddValue ("TxPowerLevel", "The power level index to use to send each packet", input.txPowerDbm);  
303
  cmd.AddValue ("TxMode", "The mode to use to send each packet", input.txMode);
306
  cmd.AddValue ("TxMode", "The mode to use to send each packet", input.txMode);
304
  cmd.AddValue ("NPackets", "The number of packets to send", input.nPackets);
307
  cmd.AddValue ("NPackets", "The number of packets to send", input.nPackets);
305
  cmd.AddValue ("PacketSize", "The size of each packet sent", input.packetSize);
308
  cmd.AddValue ("PacketSize", "The size of each packet sent", input.packetSize);
 Lines 351-357    Link Here 
351
  double targetPsr = 0.05;
354
  double targetPsr = 0.05;
352
  struct PsrExperiment::Input input;
355
  struct PsrExperiment::Input input;
353
  CommandLine cmd;
356
  CommandLine cmd;
354
  cmd.AddValue ("TxPowerLevel", "The power level index to use to send each packet", input.txPowerLevel);  
357
  cmd.AddValue ("TxPowerLevel", "The power level index to use to send each packet", input.txPowerDbm);  
355
  cmd.AddValue ("TxMode", "The mode to use to send each packet", input.txMode);
358
  cmd.AddValue ("TxMode", "The mode to use to send each packet", input.txMode);
356
  cmd.AddValue ("NPackets", "The number of packets to send", input.nPackets);
359
  cmd.AddValue ("NPackets", "The number of packets to send", input.nPackets);
357
  cmd.AddValue ("TargetPsr", "The psr needed to assume that we are within range", targetPsr);
360
  cmd.AddValue ("TargetPsr", "The psr needed to assume that we are within range", targetPsr);
(-)a/src/devices/wifi/wifi-phy.h (-8 / +5 lines)
 Lines 159-170    Link Here 
159
  WifiPhy ();
159
  WifiPhy ();
160
  virtual ~WifiPhy ();
160
  virtual ~WifiPhy ();
161
161
162
  virtual double GetTxPowerStart (void) const = 0;
162
  /** 
163
  virtual double GetTxPowerEnd (void) const = 0;
163
   * 
164
  /**
164
   * \return the TX power being used, in dBm
165
   * \returns the number of tx power levels available for this PHY.
166
   */
165
   */
167
  virtual uint32_t GetNTxPower (void) const = 0;
166
  virtual double GetTxPower (void) const = 0;
168
167
169
  /**
168
  /**
170
   * \param callback the callback to invoke
169
   * \param callback the callback to invoke
 Lines 181-190    Link Here 
181
   * \param packet the packet to send
180
   * \param packet the packet to send
182
   * \param mode the transmission mode to use to send this packet
181
   * \param mode the transmission mode to use to send this packet
183
   * \param preamble the type of preamble to use to send this packet.
182
   * \param preamble the type of preamble to use to send this packet.
184
   * \param txPowerLevel a power level to use to send this packet. The real
185
   *        transmission power is calculated as txPowerMin + txPowerLevel * (txPowerMax - txPowerMin) / nTxLevels
186
   */
183
   */
187
  virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, uint8_t txPowerLevel) = 0;
184
  virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble) = 0;
188
185
189
  /**
186
  /**
190
   * \param listener the new listener
187
   * \param listener the new listener
(-)a/src/devices/wifi/yans-wifi-phy.cc (-65 / +13 lines)
 Lines 75-97    Link Here 
75
                   MakeDoubleAccessor (&YansWifiPhy::SetRxGain,
75
                   MakeDoubleAccessor (&YansWifiPhy::SetRxGain,
76
                                       &YansWifiPhy::GetRxGain),
76
                                       &YansWifiPhy::GetRxGain),
77
                   MakeDoubleChecker<double> ())
77
                   MakeDoubleChecker<double> ())
78
    .AddAttribute ("TxPowerLevels",
78
    .AddAttribute ("TxPower",
79
                   "Number of transmission power levels available between "
79
                   "TX power to be used (dBm).",
80
                   "TxPowerBase and TxPowerEnd included.",
81
                   UintegerValue (1),
82
                   MakeUintegerAccessor (&YansWifiPhy::m_nTxPower),
83
                   MakeUintegerChecker<uint32_t> ())
84
    .AddAttribute ("TxPowerEnd",
85
                   "Maximum available transmission level (dbm).",
86
                   DoubleValue (16.0206),
80
                   DoubleValue (16.0206),
87
                   MakeDoubleAccessor (&YansWifiPhy::SetTxPowerEnd, 
81
                   MakeDoubleAccessor (&YansWifiPhy::SetTxPower, 
88
                                       &YansWifiPhy::GetTxPowerEnd),
82
                                       &YansWifiPhy::GetTxPower),
89
                   MakeDoubleChecker<double> ())
90
    .AddAttribute ("TxPowerStart",
91
                   "Minimum available transmission level (dbm).",
92
                   DoubleValue (16.0206),
93
                   MakeDoubleAccessor (&YansWifiPhy::SetTxPowerStart, 
94
                                       &YansWifiPhy::GetTxPowerStart),
95
                   MakeDoubleChecker<double> ())
83
                   MakeDoubleChecker<double> ())
96
    .AddAttribute ("RxNoiseFigure",
84
    .AddAttribute ("RxNoiseFigure",
97
                   "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
85
                   "Loss (dB) in the Signal-to-Noise-Ratio due to non-idealities in the receiver."
 Lines 191-212    Link Here 
191
  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
179
  m_interference.SetNoiseFigure (DbToRatio (noiseFigureDb));
192
}
180
}
193
void 
181
void 
194
YansWifiPhy::SetTxPowerStart (double start)
182
YansWifiPhy::SetTxPower (double txPowerDbm)
195
{
183
{
196
  NS_LOG_FUNCTION (this << start);
184
  NS_LOG_FUNCTION (this << txPowerDbm);
197
  m_txPowerBaseDbm = start;
185
  m_txPowerDbm = txPowerDbm;
198
}
199
void 
200
YansWifiPhy::SetTxPowerEnd (double end)
201
{
202
  NS_LOG_FUNCTION (this << end);
203
  m_txPowerEndDbm = end;
204
}
205
void 
206
YansWifiPhy::SetNTxPower (uint32_t n)
207
{
208
  NS_LOG_FUNCTION (this << n);
209
  m_nTxPower = n;
210
}
186
}
211
void 
187
void 
212
YansWifiPhy::SetTxGain (double gain)
188
YansWifiPhy::SetTxGain (double gain)
 Lines 254-267    Link Here 
254
  return RatioToDb (m_interference.GetNoiseFigure ());
230
  return RatioToDb (m_interference.GetNoiseFigure ());
255
}
231
}
256
double 
232
double 
257
YansWifiPhy::GetTxPowerStart (void) const
233
YansWifiPhy::GetTxPower (void) const
258
{
234
{
259
  return m_txPowerBaseDbm;
235
  return m_txPowerDbm;
260
}
261
double 
262
YansWifiPhy::GetTxPowerEnd (void) const
263
{
264
  return m_txPowerEndDbm;
265
}
236
}
266
double 
237
double 
267
YansWifiPhy::GetTxGain (void) const
238
YansWifiPhy::GetTxGain (void) const
 Lines 489-497    Link Here 
489
}
460
}
490
461
491
void 
462
void 
492
YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiMode txMode, WifiPreamble preamble, uint8_t txPower)
463
YansWifiPhy::SendPacket (Ptr<const Packet> packet, WifiMode txMode, WifiPreamble preamble)
493
{
464
{
494
  NS_LOG_FUNCTION (this << packet << txMode << preamble << (uint32_t)txPower);
465
  NS_LOG_FUNCTION (this << packet << txMode << preamble);
495
  /* Transmission can happen if:
466
  /* Transmission can happen if:
496
   *  - we are syncing on a packet. It is the responsability of the
467
   *  - we are syncing on a packet. It is the responsability of the
497
   *    MAC layer to avoid doing this but the PHY does nothing to 
468
   *    MAC layer to avoid doing this but the PHY does nothing to 
 Lines 509-516    Link Here 
509
  uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;   
480
  uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;   
510
  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
481
  bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble);
511
  NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble);
482
  NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz (), GetChannelNumber (), dataRate500KbpsUnits, isShortPreamble);
512
  m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower);
483
  m_state->SwitchToTx (txDuration, packet, txMode, preamble, m_txPowerDbm);
513
  m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble);
484
  m_channel->Send (this, packet, m_txPowerDbm + m_txGainDb, txMode, preamble);
514
}
485
}
515
486
516
uint32_t 
487
uint32_t 
 Lines 523-533    Link Here 
523
{
494
{
524
  return m_deviceRateSet[mode];
495
  return m_deviceRateSet[mode];
525
}
496
}
526
uint32_t 
527
YansWifiPhy::GetNTxPower (void) const
528
{
529
  return m_nTxPower;
530
}
531
497
532
void
498
void
533
YansWifiPhy::Configure80211a (void)
499
YansWifiPhy::Configure80211a (void)
 Lines 727-750    Link Here 
727
  return m_edThresholdW;
693
  return m_edThresholdW;
728
}
694
}
729
695
730
double 
731
YansWifiPhy::GetPowerDbm (uint8_t power) const
732
{
733
  NS_ASSERT (m_txPowerBaseDbm <= m_txPowerEndDbm);
734
  NS_ASSERT (m_nTxPower > 0);
735
  double dbm;
736
  if (m_nTxPower > 1)
737
    {
738
      dbm = m_txPowerBaseDbm + power * (m_txPowerEndDbm - m_txPowerBaseDbm) / (m_nTxPower - 1);
739
    }
740
  else 
741
    {
742
      NS_ASSERT_MSG (m_txPowerBaseDbm == m_txPowerEndDbm, "cannot have TxPowerEnd != TxPowerStart with TxPowerLevels == 1");
743
      dbm = m_txPowerBaseDbm;
744
    }
745
  return dbm;
746
}
747
748
void
696
void
749
YansWifiPhy::EndReceive (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event)
697
YansWifiPhy::EndReceive (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event)
750
{
698
{
(-)a/src/devices/wifi/yans-wifi-phy.h (-11 / +4 lines)
 Lines 97-105    Link Here 
97
                           WifiPreamble preamble);
97
                           WifiPreamble preamble);
98
98
99
  void SetRxNoiseFigure (double noiseFigureDb);
99
  void SetRxNoiseFigure (double noiseFigureDb);
100
  void SetTxPowerStart (double start);
100
  void SetTxPower (double powerDbm);
101
  void SetTxPowerEnd (double end);
102
  void SetNTxPower (uint32_t n);
103
  void SetTxGain (double gain);
101
  void SetTxGain (double gain);
104
  void SetRxGain (double gain);
102
  void SetRxGain (double gain);
105
  void SetEdThreshold (double threshold);
103
  void SetEdThreshold (double threshold);
 Lines 119-130    Link Here 
119
  
117
  
120
118
121
119
122
  virtual double GetTxPowerStart (void) const;
120
  virtual double GetTxPower (void) const;
123
  virtual double GetTxPowerEnd (void) const;
124
  virtual uint32_t GetNTxPower (void) const;
125
  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
121
  virtual void SetReceiveOkCallback (WifiPhy::RxOkCallback callback);
126
  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
122
  virtual void SetReceiveErrorCallback (WifiPhy::RxErrorCallback callback);
127
  virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble, uint8_t txPowerLevel);
123
  virtual void SendPacket (Ptr<const Packet> packet, WifiMode mode, enum WifiPreamble preamble);
128
  virtual void RegisterListener (WifiPhyListener *listener);
124
  virtual void RegisterListener (WifiPhyListener *listener);
129
  virtual bool IsStateCcaBusy (void);
125
  virtual bool IsStateCcaBusy (void);
130
  virtual bool IsStateIdle (void);
126
  virtual bool IsStateIdle (void);
 Lines 157-163    Link Here 
157
  double DbToRatio (double db) const;
153
  double DbToRatio (double db) const;
158
  double WToDbm (double w) const;
154
  double WToDbm (double w) const;
159
  double RatioToDb (double ratio) const;
155
  double RatioToDb (double ratio) const;
160
  double GetPowerDbm (uint8_t power) const;
161
  void EndReceive (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event);
156
  void EndReceive (Ptr<Packet> packet, Ptr<InterferenceHelper::Event> event);
162
157
163
private:
158
private:
 Lines 165-173    Link Here 
165
  double   m_ccaMode1ThresholdW;
160
  double   m_ccaMode1ThresholdW;
166
  double   m_txGainDb;
161
  double   m_txGainDb;
167
  double   m_rxGainDb;
162
  double   m_rxGainDb;
168
  double   m_txPowerBaseDbm;
163
  double   m_txPowerDbm;
169
  double   m_txPowerEndDbm;
170
  uint32_t m_nTxPower;
171
164
172
  Ptr<YansWifiChannel> m_channel;
165
  Ptr<YansWifiChannel> m_channel;
173
  uint16_t m_channelNumber;
166
  uint16_t m_channelNumber;

Return to bug 917