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

(-)a/src/applications/model/onoff-application.cc (-1 / +4 lines)
 Lines 166-171    Link Here 
166
        MakeCallback (&OnOffApplication::ConnectionSucceeded, this),
166
        MakeCallback (&OnOffApplication::ConnectionSucceeded, this),
167
        MakeCallback (&OnOffApplication::ConnectionFailed, this));
167
        MakeCallback (&OnOffApplication::ConnectionFailed, this));
168
    }
168
    }
169
  m_cbrRateFailSafe = m_cbrRate;
170
169
  // Insure no pending event
171
  // Insure no pending event
170
  CancelEvents ();
172
  CancelEvents ();
171
  // If we are not yet connected, there is nothing to do here
173
  // If we are not yet connected, there is nothing to do here
 Lines 193-205    Link Here 
193
{
195
{
194
  NS_LOG_FUNCTION (this);
196
  NS_LOG_FUNCTION (this);
195
197
196
  if (m_sendEvent.IsRunning ())
198
  if (m_sendEvent.IsRunning () && m_cbrRateFailSafe == m_cbrRate )
197
    { // Cancel the pending send packet event
199
    { // Cancel the pending send packet event
198
      // Calculate residual bits since last packet sent
200
      // Calculate residual bits since last packet sent
199
      Time delta (Simulator::Now () - m_lastStartTime);
201
      Time delta (Simulator::Now () - m_lastStartTime);
200
      int64x64_t bits = delta.To (Time::S) * m_cbrRate.GetBitRate ();
202
      int64x64_t bits = delta.To (Time::S) * m_cbrRate.GetBitRate ();
201
      m_residualBits += bits.GetHigh ();
203
      m_residualBits += bits.GetHigh ();
202
    }
204
    }
205
  m_cbrRateFailSafe = m_cbrRate;
203
  Simulator::Cancel (m_sendEvent);
206
  Simulator::Cancel (m_sendEvent);
204
  Simulator::Cancel (m_startStopEvent);
207
  Simulator::Cancel (m_startStopEvent);
205
}
208
}
(-)a/src/applications/model/onoff-application.h (+1 lines)
 Lines 145-150    Link Here 
145
  Ptr<RandomVariableStream>  m_onTime;       // rng for On Time
145
  Ptr<RandomVariableStream>  m_onTime;       // rng for On Time
146
  Ptr<RandomVariableStream>  m_offTime;      // rng for Off Time
146
  Ptr<RandomVariableStream>  m_offTime;      // rng for Off Time
147
  DataRate        m_cbrRate;      // Rate that data is generated
147
  DataRate        m_cbrRate;      // Rate that data is generated
148
  DataRate        m_cbrRateFailSafe;      // Rate that data is generated (check copy)
148
  uint32_t        m_pktSize;      // Size of packets
149
  uint32_t        m_pktSize;      // Size of packets
149
  uint32_t        m_residualBits; // Number of generated, but not sent, bits
150
  uint32_t        m_residualBits; // Number of generated, but not sent, bits
150
  Time            m_lastStartTime; // Time last packet sent
151
  Time            m_lastStartTime; // Time last packet sent

Return to bug 1798