[Ns-developers] Questions about Packet, Buffers, and zero payloads
Tom Henderson
tomh at tomh.org
Thu Jun 11 12:12:53 PDT 2009
George, I took a stab at your questions below.
>-----Original Message-----
>From: George Riley [mailto:riley at ece.gatech.edu]
>Sent: Wednesday, June 10, 2009 10:47 AM
>To: 'ns-developers'
>Subject: [Ns-developers] Questions about Packet, Buffers, and zero payloads
>
>Hi All,
>I am nearing completion on the MPI-based distributed simulation for
>ns-3.
>The code to do time synchronization is working perfectly, as is the code
>to detect transient messages. I have implemented the code to send
>packets
>using MPI sends and packet serializatino, but am puzzled by a couple
>of issues
>and could use some advise
>
>After quite a bit of trying various methods, the code ended up looking
>like this:
>
> // Serialize the packet
> i->buffer = p->Serialize();
> // Add the dest node and dest device
> i->buffer.AddAtStart(sizeof(node) + sizeof(dev));
> Buffer::Iterator it = i->buffer.Begin();
> it.WriteU32(node);
> it.WriteU32(dev);
>
> // Find the system id for the destination node
> Ptr<Node> destNode = NodeList::GetNode(node);
> uint32_t nodeSysId = destNode->GetSystemId();
> MPI_Isend((void*)i->buffer.PeekData(), i->buffer.GetSize(),
>MPI_CHAR, nodeSysId,
> 0, MPI_COMM_WORLD, &(i->request));
> cout << "MPI Packet sent" << endl;
>
>This seems to work; but one question is does the "AddAtStart" after
>the serialization
>cause a buffer re-alloc and copy? If so this is not acceptable.
It seems to depend on whether there is space in the buffer; if you look at the implementation, there is an isDirty flag that might return true.
>Second question is
>that the i->buffer.GetSize() on the MPI_Isend returns the size of the
>buffer including
>the zero-byte (and non-existent) payload. Shouldn't we only send the
>actual packet data
>without the zero payload? How do I get the zero payload back on the
>receiving end?
>I did not see where this is handled in Packet::Serialize() and
>Packet::DeSerialize().
I believe that these are presently converted to real data bytes upon serialization, and not restored to their previous state upon deserialization. Whether we should or shouldn't do this, I think that it is safest to do it that way but maybe it could be optimized for MPI if needed.
More information about the Ns-developers
mailing list