Enable explicit setting of the maximum look ahead in distributed simulation.

This commit is contained in:
Peter D. Barnes, Jr.
2014-07-17 15:38:07 -07:00
parent e4f944939c
commit f8bb25d058
2 changed files with 27 additions and 9 deletions

View File

@@ -76,7 +76,7 @@ LbtsMessage::IsFinished ()
return m_isFinished;
}
Time DistributedSimulatorImpl::m_lookAhead = Seconds (0);
Time DistributedSimulatorImpl::m_lookAhead = Seconds (-1);
TypeId
DistributedSimulatorImpl::GetTypeId (void)
@@ -167,14 +167,15 @@ DistributedSimulatorImpl::CalculateLookAhead (void)
#ifdef NS3_MPI
if (MpiInterface::GetSize () <= 1)
{
DistributedSimulatorImpl::m_lookAhead = Seconds (0);
m_grantedTime = Seconds (0);
m_lookAhead = Seconds (0);
}
else
{
DistributedSimulatorImpl::m_lookAhead = GetMaximumSimulationTime ();
m_grantedTime = GetMaximumSimulationTime ();
if (m_lookAhead == Seconds (-1))
{
m_lookAhead = GetMaximumSimulationTime ();
}
// else it was already set by SetLookAhead
NodeContainer c = NodeContainer::GetGlobal ();
for (NodeContainer::Iterator iter = c.Begin (); iter != c.End (); ++iter)
@@ -221,15 +222,17 @@ DistributedSimulatorImpl::CalculateLookAhead (void)
TimeValue delay;
channel->GetAttribute ("Delay", delay);
if (delay.Get ().GetSeconds () < DistributedSimulatorImpl::m_lookAhead.GetSeconds ())
if (delay.Get () < m_lookAhead)
{
DistributedSimulatorImpl::m_lookAhead = delay.Get ();
m_grantedTime = delay.Get ();
m_lookAhead = delay.Get ();
}
}
}
}
// m_lookAhead is now set
m_grantedTime = m_lookAhead;
/*
* Compute the maximum inter-task latency and use that value
* for tasks with no inter-task links.
@@ -277,6 +280,20 @@ DistributedSimulatorImpl::CalculateLookAhead (void)
#endif
}
void
DistributedSimulatorImpl::SetMaximumLookAhead (const Time lookAhead)
{
if (lookAhead > 0)
{
NS_LOG_FUNCTION (this << lookAhead);
m_lookAhead = lookAhead;
}
else
{
NS_LOG_WARN ("attempted to set look ahead negative: " << lookAhead);
}
}
void
DistributedSimulatorImpl::SetScheduler (ObjectFactory schedulerFactory)
{

View File

@@ -122,6 +122,7 @@ public:
virtual Time Now (void) const;
virtual Time GetDelayLeft (const EventId &id) const;
virtual Time GetMaximumSimulationTime (void) const;
virtual void SetMaximumLookAhead (const Time lookAhead);
virtual void SetScheduler (ObjectFactory schedulerFactory);
virtual uint32_t GetSystemId (void) const;
virtual uint32_t GetContext (void) const;