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

(-)a/src/csma/model/csma-net-device.cc (-2 / +2 lines)
 Lines 490-496    Link Here 
490
          m_txMachineState = BUSY;
490
          m_txMachineState = BUSY;
491
          m_phyTxBeginTrace (m_currentPkt);
491
          m_phyTxBeginTrace (m_currentPkt);
492
492
493
          Time tEvent = Seconds (m_bps.CalculateTxTime (m_currentPkt->GetSize ()));
493
          Time tEvent = m_bps.CalculateBytesTxTime (m_currentPkt->GetSize ());
494
          NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << tEvent.GetSeconds () << "sec");
494
          NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << tEvent.GetSeconds () << "sec");
495
          Simulator::Schedule (tEvent, &CsmaNetDevice::TransmitCompleteEvent, this);
495
          Simulator::Schedule (tEvent, &CsmaNetDevice::TransmitCompleteEvent, this);
496
        }
496
        }
 Lines 626-632    Link Here 
626
  //
626
  //
627
  // We use the Ethernet interframe gap of 96 bit times.
627
  // We use the Ethernet interframe gap of 96 bit times.
628
  //
628
  //
629
  m_tInterframeGap = Seconds (m_bps.CalculateTxTime (96/8));
629
  m_tInterframeGap = m_bps.CalculateBytesTxTime (96/8);
630
630
631
  //
631
  //
632
  // This device is up whenever a channel is attached to it.
632
  // This device is up whenever a channel is attached to it.
(-)a/src/network/utils/data-rate.cc (+14 lines)
 Lines 232-237    Link Here 
232
  return static_cast<double>(bytes)*8/m_bps;
232
  return static_cast<double>(bytes)*8/m_bps;
233
}
233
}
234
234
235
Time DataRate::CalculateBytesTxTime (uint32_t bytes) const
236
{
237
  NS_LOG_FUNCTION (this << bytes);
238
  // \todo avoid to use double (if possible).
239
  return Seconds (static_cast<double>(bytes)*8/m_bps);
240
}
241
242
Time DataRate::CalculateBitsTxTime (uint32_t bits) const
243
{
244
  NS_LOG_FUNCTION (this << bits);
245
  // \todo avoid to use double (if possible).
246
  return Seconds (static_cast<double>(bits)/m_bps);
247
}
248
235
uint64_t DataRate::GetBitRate () const
249
uint64_t DataRate::GetBitRate () const
236
{
250
{
237
  NS_LOG_FUNCTION (this);
251
  NS_LOG_FUNCTION (this);
(-)a/src/network/utils/data-rate.h (-3 / +22 lines)
 Lines 27-32    Link Here 
27
#include "ns3/nstime.h"
27
#include "ns3/nstime.h"
28
#include "ns3/attribute.h"
28
#include "ns3/attribute.h"
29
#include "ns3/attribute-helper.h"
29
#include "ns3/attribute-helper.h"
30
#include "ns3/deprecated.h"
30
31
31
namespace ns3 {
32
namespace ns3 {
32
33
 Lines 42-50    Link Here 
42
 * from strings, natural multiplication e.g.:
43
 * from strings, natural multiplication e.g.:
43
 * \code
44
 * \code
44
 * DataRate x("56kbps");
45
 * DataRate x("56kbps");
45
 * double nBits = x*ns3::Seconds(19.2);
46
 * double nBits = x*ns3::Seconds (19.2);
46
 * uint32_t nBytes = 20;
47
 * uint32_t nBytes = 20;
47
 * double txtime = x.CalclulateTxTime(nBytes);
48
 * Time txTime = x.CalclulateBytesTxTime (nBytes);
48
 * \endcode
49
 * \endcode
49
 * This class also supports the regular comparison operators <, >, <=, >=, ==,
50
 * This class also supports the regular comparison operators <, >, <=, >=, ==,
50
 * and !=
51
 * and !=
 Lines 148-156    Link Here 
148
   *
149
   *
149
   * Calculates the transmission time at this data rate
150
   * Calculates the transmission time at this data rate
150
   * \param bytes The number of bytes (not bits) for which to calculate
151
   * \param bytes The number of bytes (not bits) for which to calculate
152
   * \return The transmission time for the number of bytes specified
153
   */
154
  Time CalculateBytesTxTime (uint32_t bytes) const;
155
156
  /**
157
   * \brief Calculate transmission time
158
   *
159
   * Calculates the transmission time at this data rate
160
   * \param bits The number of bits (not bytes) for which to calculate
161
   * \return The transmission time for the number of bits specified
162
   */
163
  Time CalculateBitsTxTime (uint32_t bits) const;
164
165
  /**
166
   * \brief Calculate transmission time
167
   *
168
   * Calculates the transmission time at this data rate
169
   * \param bytes The number of bytes (not bits) for which to calculate
151
   * \return The transmission time in seconds for the number of bytes specified
170
   * \return The transmission time in seconds for the number of bytes specified
152
   */
171
   */
153
  double CalculateTxTime (uint32_t bytes) const;
172
  double CalculateTxTime (uint32_t bytes) const NS_DEPRECATED;
154
173
155
  /**
174
  /**
156
   * Get the underlying bitrate
175
   * Get the underlying bitrate
(-)a/src/network/utils/simple-net-device.cc (-2 / +2 lines)
 Lines 420-426    Link Here 
420
          Time txTime = Time (0);
420
          Time txTime = Time (0);
421
          if (m_bps > DataRate (0))
421
          if (m_bps > DataRate (0))
422
            {
422
            {
423
              txTime = Seconds (m_bps.CalculateTxTime (packet->GetSize ()));
423
              txTime = m_bps.CalculateBytesTxTime (packet->GetSize ());
424
            }
424
            }
425
          m_channel->Send (p, protocolNumber, to, from, this);
425
          m_channel->Send (p, protocolNumber, to, from, this);
426
          TransmitCompleteEvent = Simulator::Schedule (txTime, &SimpleNetDevice::TransmitComplete, this);
426
          TransmitCompleteEvent = Simulator::Schedule (txTime, &SimpleNetDevice::TransmitComplete, this);
 Lines 460-466    Link Here 
460
      Time txTime = Time (0);
460
      Time txTime = Time (0);
461
      if (m_bps > DataRate (0))
461
      if (m_bps > DataRate (0))
462
        {
462
        {
463
          txTime = Seconds (m_bps.CalculateTxTime (packet->GetSize ()));
463
          txTime = m_bps.CalculateBytesTxTime (packet->GetSize ());
464
        }
464
        }
465
      TransmitCompleteEvent = Simulator::Schedule (txTime, &SimpleNetDevice::TransmitComplete, this);
465
      TransmitCompleteEvent = Simulator::Schedule (txTime, &SimpleNetDevice::TransmitComplete, this);
466
    }
466
    }
(-)a/src/point-to-point/model/point-to-point-net-device.cc (-1 / +1 lines)
 Lines 218-224    Link Here 
218
  m_currentPkt = p;
218
  m_currentPkt = p;
219
  m_phyTxBeginTrace (m_currentPkt);
219
  m_phyTxBeginTrace (m_currentPkt);
220
220
221
  Time txTime = Seconds (m_bps.CalculateTxTime (p->GetSize ()));
221
  Time txTime = m_bps.CalculateBytesTxTime (p->GetSize ());
222
  Time txCompleteTime = txTime + m_tInterframeGap;
222
  Time txCompleteTime = txTime + m_tInterframeGap;
223
223
224
  NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << txCompleteTime.GetSeconds () << "sec");
224
  NS_LOG_LOGIC ("Schedule TransmitCompleteEvent in " << txCompleteTime.GetSeconds () << "sec");
(-)a/src/spectrum/model/half-duplex-ideal-phy.cc (-3 / +3 lines)
 Lines 282-289    Link Here 
282
        m_txPacket = p;
282
        m_txPacket = p;
283
        ChangeState (TX);
283
        ChangeState (TX);
284
        Ptr<HalfDuplexIdealPhySignalParameters> txParams = Create<HalfDuplexIdealPhySignalParameters> ();
284
        Ptr<HalfDuplexIdealPhySignalParameters> txParams = Create<HalfDuplexIdealPhySignalParameters> ();
285
        double txTimeSeconds = m_rate.CalculateTxTime (p->GetSize ());
285
        Time txTimeSeconds = m_rate.CalculateBytesTxTime (p->GetSize ());
286
        txParams->duration = Seconds (txTimeSeconds);
286
        txParams->duration = txTimeSeconds;
287
        txParams->txPhy = GetObject<SpectrumPhy> ();
287
        txParams->txPhy = GetObject<SpectrumPhy> ();
288
        txParams->txAntenna = m_antenna;
288
        txParams->txAntenna = m_antenna;
289
        txParams->psd = m_txPsd;
289
        txParams->psd = m_txPsd;
 Lines 291-297    Link Here 
291
291
292
        NS_LOG_LOGIC (this << " tx power: " << 10 * std::log10 (Integral (*(txParams->psd))) + 30 << " dBm");
292
        NS_LOG_LOGIC (this << " tx power: " << 10 * std::log10 (Integral (*(txParams->psd))) + 30 << " dBm");
293
        m_channel->StartTx (txParams);
293
        m_channel->StartTx (txParams);
294
        Simulator::Schedule (Seconds (txTimeSeconds), &HalfDuplexIdealPhy::EndTx, this);
294
        Simulator::Schedule (txTimeSeconds, &HalfDuplexIdealPhy::EndTx, this);
295
      }
295
      }
296
      break;
296
      break;
297
297

Return to bug 1974