core: time: replace int64_t operator/(Time,Time) with exact int64x64_t version,

add int64x64_t scaling.
This commit is contained in:
Peter D. Barnes, Jr.
2018-10-19 00:03:07 -04:00
parent 1d5ce0430f
commit dff56925e5
9 changed files with 62 additions and 14 deletions

View File

@@ -698,8 +698,11 @@ private:
friend Time operator - (const Time & lhs, const Time & rhs);
friend Time operator * (const Time & lhs, const int64_t & rhs);
friend Time operator * (const int64_t & lhs, const Time & rhs);
friend int64_t operator / (const Time & lhs, const Time & rhs);
friend Time operator * (const Time & lhs, const int64x64_t & rhs);
friend Time operator * (const int64x64_t & lhs, const Time & rhs);
friend int64x64_t operator / (const Time & lhs, const Time & rhs);
friend Time operator / (const Time & lhs, const int64_t & rhs);
friend Time operator / (const Time & lhs, const int64x64_t & rhs);
friend Time & operator += (Time & lhs, const Time & rhs);
friend Time & operator -= (Time & lhs, const Time & rhs);
/** @} */
@@ -746,6 +749,9 @@ static bool NS_UNUSED_GLOBAL (g_TimeStaticInit) = Time::StaticInit ();
/**
* \ingroup time
* @{
*/
/**
* \brief Equality operator for Time.
* \param [in] lhs The first value
* \param [in] rhs The second value
@@ -866,6 +872,32 @@ operator * (const int64_t & lhs, const Time & rhs)
res.m_data *= lhs;
return res;
}
/**
* \ingroup time
* \brief Multiplication operator for Time.
* \param [in] lhs The first value
* \param [in] rhs The second value
* \returns the product of the two input values.
*/
inline Time
operator * (const Time & lhs, const int64x64_t & rhs)
{
int64x64_t res = lhs.m_data;
res *= rhs;
return Time (res);
}
/**
* \ingroup time
* \brief Multiplication operator for Time.
* \param [in] lhs The first value
* \param [in] rhs The second value
* \returns the product of the two input values.
*/
inline Time
operator * (const int64x64_t & lhs, const Time & rhs)
{
return rhs * lhs;
}
/**
* \ingroup time
* \brief Division operator for Time.
@@ -873,11 +905,12 @@ operator * (const int64_t & lhs, const Time & rhs)
* \param [in] rhs The second value
* \returns the resultof the first input value divided by the second input value.
*/
inline int64_t
inline int64x64_t
operator / (const Time & lhs, const Time & rhs)
{
int64_t res = lhs.m_data / rhs.m_data;
return res;
int64x64_t num = lhs.m_data;
int64x64_t den = rhs.m_data;
return num / den;
}
/**
* \ingroup time
@@ -893,6 +926,20 @@ operator / (const Time & lhs, const int64_t & rhs)
res.m_data /= rhs;
return res;
}
/**
* \ingroup time
* \brief Division operator for Time.
* \param [in] lhs The first value
* \param [in] rhs The second value
* \returns the resultof the first input value divided by the second input value.
*/
inline Time
operator / (const Time & lhs, const int64x64_t & rhs)
{
int64x64_t res = lhs.m_data;
res /= rhs;
return Time (res);
}
/**
* \ingroup time
* \brief Addition operator for Time.
@@ -917,7 +964,6 @@ inline Time & operator -= (Time & lhs, const Time & rhs)
lhs.m_data -= rhs.m_data;
return lhs;
}
/**@}*/
inline Time Abs (const Time & time)
{
@@ -961,6 +1007,8 @@ std::ostream & operator << (std::ostream & os, const Time & time);
*/
std::istream & operator >> (std::istream & is, Time & time);
/**@}*/ // \ingroup time
/**
* \ingroup time
* \defgroup timecivil Standard Time Units.

View File

@@ -111,7 +111,7 @@ TcpHyblaIncrementTest::DoRun ()
NS_TEST_ASSERT_MSG_NE (m_rho, 0.0,
"Rho never updated by implementation");
NS_TEST_ASSERT_MSG_EQ_TOL (calcRho, m_rho, MilliSeconds (10),
NS_TEST_ASSERT_MSG_EQ_TOL (calcRho, m_rho, 0.01,
"Different rho values between implementation and test");
cong->IncreaseWindow (m_state, 1);

View File

@@ -284,7 +284,7 @@ DistributedSimulatorImpl::CalculateLookAhead (void)
void
DistributedSimulatorImpl::SetMaximumLookAhead (const Time lookAhead)
{
if (lookAhead > 0)
if (lookAhead > Time (0))
{
NS_LOG_FUNCTION (this << lookAhead);
m_lookAhead = lookAhead;

View File

@@ -134,7 +134,7 @@ DelayJitterEstimation::RecordRx (Ptr<const Packet> packet)
tag.GetTxTime ();
Time delta = (Simulator::Now () - m_previousRx) - (tag.GetTxTime () - m_previousRxTx);
m_jitter += (Abs (delta) - m_jitter) / 16;
m_jitter += (Abs (delta) - m_jitter) / (int64x64_t)16;
m_previousRx = Simulator::Now ();
m_previousRxTx = tag.GetTxTime ();
m_delay = Simulator::Now () - tag.GetTxTime ();

View File

@@ -259,7 +259,7 @@ DefaultChannelScheduler::AssignExtendedAccess (uint32_t channelNumber, uint32_t
{
// if current remain extends cannot fulfill the requirement for extends
Time remainTime = Simulator::GetDelayLeft (m_extendEvent);
uint32_t remainExtends = remainTime / m_coordinator->GetSyncInterval ();
uint32_t remainExtends = (remainTime / m_coordinator->GetSyncInterval ()).GetHigh ();
if (remainExtends > extends)
{
return true;

View File

@@ -486,7 +486,7 @@ ChannelAccessManager::UpdateBackoff (void)
Time backoffStart = GetBackoffStartFor (state);
if (backoffStart <= Simulator::Now ())
{
uint32_t nIntSlots = (Simulator::Now () - backoffStart) / m_slot;
uint32_t nIntSlots = ((Simulator::Now () - backoffStart) / m_slot).GetHigh ();
/*
* EDCA behaves slightly different to DCA. For EDCA we
* decrement once at the slot boundary at the end of AIFS as

View File

@@ -1462,7 +1462,7 @@ MacLow::ForwardDown (Ptr<const Packet> packet, const WifiMacHeader* hdr, WifiTxV
}
if (queueSize > 1)
{
NS_ASSERT (remainingAmpduDuration > 0);
NS_ASSERT (remainingAmpduDuration > Time (0));
delay = delay + mpduDuration;
}

View File

@@ -965,7 +965,7 @@ MinstrelWifiManager::CalculateTimeUnicastPacket (Time dataTransmissionTime, uint
tt += dataTransmissionTime + GetMac ()->GetAckTimeout ();
//Add average back off (half the current contention window)
tt += NanoSeconds ((cw / 2) * GetMac ()->GetSlot ());
tt += (cw / 2.0) * GetMac ()->GetSlot ();
//Update contention window
cw = std::min (cwMax, (cw + 1) * 2);

View File

@@ -312,7 +312,7 @@ UplinkSchedulerMBQoS::Schedule (void)
(*(ssRecord->GetServiceFlows (ServiceFlow::SF_TYPE_UGS).begin ()))->GetRecord ()->GetLastGrantTime ()
+ MilliSeconds ((*(ssRecord->GetServiceFlows (ServiceFlow::SF_TYPE_UGS).begin ()))->GetUnsolicitedGrantInterval ());
int64_t frame = (timestamp - Simulator::Now ()) / frame_duration;
int64_t frame = ((timestamp - Simulator::Now ()) / frame_duration).GetHigh ();
if (frame <= 1)
{
@@ -663,7 +663,7 @@ UplinkSchedulerMBQoS::CheckDeadline (uint32_t &availableSymbols)
Time deadline = job->GetDeadline ();
Time frame_duration = GetBs ()->GetPhy ()->GetFrameDuration ();
int64_t frame = (deadline - Simulator::Now ()) / frame_duration;
int64_t frame = ((deadline - Simulator::Now ()) / frame_duration).GetHigh ();
NS_LOG_DEBUG ("At " << Simulator::Now ().GetSeconds () << " reserved traffic rate: "
<< job->GetServiceFlow ()->GetMinReservedTrafficRate ()