diff --git a/src/mtp/model/multithreaded-simulator-impl.cc b/src/mtp/model/multithreaded-simulator-impl.cc index b6406a25b..408eb8209 100644 --- a/src/mtp/model/multithreaded-simulator-impl.cc +++ b/src/mtp/model/multithreaded-simulator-impl.cc @@ -138,10 +138,16 @@ MultithreadedSimulatorImpl::ScheduleWithContext(uint32_t context, EventImpl* event) { NS_LOG_FUNCTION(this << context << delay.GetTimeStep() << event); - const bool useSaved = (context < m_savedNodeList.GetN()); - Ptr node = useSaved ? m_savedNodeList.Get(context) : NodeList::GetNode(context); - LogicalProcess* remote = MtpInterface::GetSystem(node->GetSystemId()); - remote->ScheduleWithContext(remote, context, delay, event); + LogicalProcess* remote = nullptr; + if (m_savedNodeList.GetN() > context) + { + remote = MtpInterface::GetSystem(m_savedNodeList.Get(context)->GetSystemId()); + } + else + { + remote = MtpInterface::GetSystem(NodeList::GetNode(context)->GetSystemId()); + } + MtpInterface::GetSystem()->ScheduleWithContext(remote, context, delay, event); } EventId @@ -301,7 +307,7 @@ MultithreadedSimulatorImpl::Partition() NS_LOG_FUNCTION(this); uint32_t systemId = 0; const NodeContainer nodes = NodeContainer::GetGlobal(); - m_savedNodeList = NodeContainer::GetGlobal(); + m_savedNodeList = nodes; bool* visited = new bool[nodes.GetN()]{false}; std::queue> q;