30 #include "ns3/node-list.h"
31 #include "ns3/net-device.h"
32 #include "ns3/simulator.h"
33 #include "ns3/simulator-impl.h"
34 #include "ns3/nstime.h"
90 for (uint32_t i = 0; i <
GetSize (); ++i)
151 MPI_Init (pargc, pargv);
152 MPI_Barrier (MPI_COMM_WORLD);
153 MPI_Comm_rank (MPI_COMM_WORLD, reinterpret_cast <int *> (&
m_sid));
154 MPI_Comm_size (MPI_COMM_WORLD, reinterpret_cast <int *> (&
m_size));
160 for (uint32_t i = 0; i <
GetSize (); ++i)
167 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
177 std::list<SentBuffer>::reverse_iterator i =
m_pendingTx.rbegin ();
180 uint8_t* buffer =
new uint8_t[serializedSize + 16];
181 i->SetBuffer (buffer);
184 uint64_t* pTime = reinterpret_cast <uint64_t *> (buffer);
186 uint32_t* pData =
reinterpret_cast<uint32_t *
> (pTime);
190 p->
Serialize (reinterpret_cast<uint8_t *> (pData), serializedSize);
196 MPI_Isend (reinterpret_cast<void *> (i->GetBuffer ()), serializedSize + 16, MPI_CHAR, nodeSysId,
197 0, MPI_COMM_WORLD, (i->GetRequest ()));
200 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
220 MPI_Get_count (&status, MPI_CHAR, &count);
224 uint64_t* pTime =
reinterpret_cast<uint64_t *
> (
m_pRxBuffers[index]);
225 uint64_t nanoSeconds = *pTime++;
226 uint32_t* pData =
reinterpret_cast<uint32_t *
> (pTime);
227 uint32_t node = *pData++;
228 uint32_t dev = *pData++;
230 Time rxTime = NanoSeconds (nanoSeconds);
232 count -=
sizeof (nanoSeconds) +
sizeof (node) +
sizeof (dev);
234 Ptr<Packet> p = Create<Packet> (
reinterpret_cast<uint8_t *
> (pData), count,
true);
240 for (uint32_t i = 0; i < nDevices; ++i)
261 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
269 std::list<SentBuffer>::iterator i =
m_pendingTx.begin ();
274 MPI_Test (i->GetRequest (), &flag, &status);
275 std::list<SentBuffer>::iterator
current = i;
283 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");
292 MPI_Initialized (&flag);
301 NS_FATAL_ERROR (
"Cannot disable MPI environment without Initializing it first");
304 NS_FATAL_ERROR (
"Can't use distributed simulator without MPI compiled in");