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

(-)a/src/propagation/model/propagation-loss-model.cc (-14 / +14 lines)
 Lines 130-140    Link Here 
130
                   DoubleValue (1.0),
130
                   DoubleValue (1.0),
131
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_systemLoss),
131
                   MakeDoubleAccessor (&FriisPropagationLossModel::m_systemLoss),
132
                   MakeDoubleChecker<double> ())
132
                   MakeDoubleChecker<double> ())
133
    .AddAttribute ("MinDistance", 
133
    .AddAttribute ("MinLoss", 
134
                   "The distance under which the propagation model refuses to give results (m)",
134
                   "The minimum value (dB) of the total propagation loss, used at short ranges",
135
                   DoubleValue (0.5),
135
                   DoubleValue (0.0),
136
                   MakeDoubleAccessor (&FriisPropagationLossModel::SetMinDistance,
136
                   MakeDoubleAccessor (&FriisPropagationLossModel::SetMinLoss,
137
                                       &FriisPropagationLossModel::GetMinDistance),
137
                                       &FriisPropagationLossModel::GetMinLoss),
138
                   MakeDoubleChecker<double> ())
138
                   MakeDoubleChecker<double> ())
139
  ;
139
  ;
140
  return tid;
140
  return tid;
 Lines 154-167    Link Here 
154
  return m_systemLoss;
154
  return m_systemLoss;
155
}
155
}
156
void
156
void
157
FriisPropagationLossModel::SetMinDistance (double minDistance)
157
FriisPropagationLossModel::SetMinLoss (double minLoss)
158
{
158
{
159
  m_minDistance = minDistance;
159
  m_minLoss = minLoss;
160
}
160
}
161
double
161
double
162
FriisPropagationLossModel::GetMinDistance (void) const
162
FriisPropagationLossModel::GetMinLoss (void) const
163
{
163
{
164
  return m_minDistance;
164
  return m_minLoss;
165
}
165
}
166
void
166
void
167
FriisPropagationLossModel::SetLambda (double frequency, double speed)
167
FriisPropagationLossModel::SetLambda (double frequency, double speed)
 Lines 228-242    Link Here 
228
   * lambda: wavelength (m)
228
   * lambda: wavelength (m)
229
   */
229
   */
230
  double distance = a->GetDistanceFrom (b);
230
  double distance = a->GetDistanceFrom (b);
231
  if (distance <= m_minDistance)
231
  if (distance <= 0)
232
    {
232
    {
233
      return txPowerDbm;
233
      return txPowerDbm - m_minLoss;
234
    }
234
    }
235
  double numerator = m_lambda * m_lambda;
235
  double numerator = m_lambda * m_lambda;
236
  double denominator = 16 * PI * PI * distance * distance * m_systemLoss;
236
  double denominator = 16 * PI * PI * distance * distance * m_systemLoss;
237
  double pr = 10 * log10 (numerator / denominator);
237
  double lossDb = -10 * log10 (numerator / denominator);
238
  NS_LOG_DEBUG ("distance="<<distance<<"m, attenuation coefficient="<<pr<<"dB");
238
  NS_LOG_DEBUG ("distance=" << distance<< "m, loss=" << lossDb <<"dB");
239
  return txPowerDbm + pr;
239
  return txPowerDbm - std::max (lossDb, m_minLoss);
240
}
240
}
241
241
242
// ------------------------------------------------------------------------- //
242
// ------------------------------------------------------------------------- //
(-)a/src/propagation/model/propagation-loss-model.h (-7 / +7 lines)
 Lines 168-184    Link Here 
168
  void SetSystemLoss (double systemLoss);
168
  void SetSystemLoss (double systemLoss);
169
169
170
  /**
170
  /**
171
   * \param minDistance the minimum distance
171
   * \param minLoss the minimum loss (dB)
172
   *
172
   *
173
   * Below this distance, the txpower is returned
173
   * no matter how short the distance, the total propagation loss (in
174
   * unmodified as the rxpower.
174
   * dB) will always be greater or equal than this value 
175
   */
175
   */
176
  void SetMinDistance (double minDistance);
176
  void SetMinLoss (double minLoss);
177
177
178
  /**
178
  /**
179
   * \returns the minimum distance.
179
   * \return the minimum loss.
180
   */
180
   */
181
  double GetMinDistance (void) const;
181
  double GetMinLoss (void) const;
182
182
183
  /**
183
  /**
184
   * \returns the current wavelength (m)
184
   * \returns the current wavelength (m)
 Lines 201-207    Link Here 
201
  static const double PI;
201
  static const double PI;
202
  double m_lambda;
202
  double m_lambda;
203
  double m_systemLoss;
203
  double m_systemLoss;
204
  double m_minDistance;
204
  double m_minLoss;
205
};
205
};
206
206
207
/**
207
/**

Return to bug 1443