[Ns-developers] Question about fixing Tag Serialization bug
mathieu.lacage at gmail.com
Sat Nov 19 03:36:19 PST 2011
On Thu, Nov 17, 2011 at 22:40, Young, Jeffrey S
<jeff.young at gtri.gatech.edu> wrote:
> I have been using the distributed interface for some simulations with NS-3, and I would really like to be able to use PacketTags with the MPI interface. I noticed that there is an outstanding bug related to this problem (https://www.nsnam.org/bugzilla/show_bug.cgi?id=582), and the code that would address this seems to be the Packet::Serialize, Packet::Deserialize, and Packet::GetSerializedSize() functions in packet.cc.
> I attempted to add some code to handle serialization/deserialization of tags. For the serialization of the tags, I iterated over the PacketTagList for the packet using a PacketTagIterator object, serialized to a TagBuffer and then to the output buffer. However, I then realized that I couldn't think of a good way to deserialize the byte stream without knowing what type of Tag is encoded in the input buffer.
> Is anyone familiar with this particular problem, and would you have any suggestions for a good, generic solution? I had thought that possibly I should encode the TypeID of the Tag into the bytestream, but this still seems somewhat complicated since there are many different types of PacketTags.
Yes, you need to encode the TypeId. The best way to do this would be
to encode it as a string using TypeId::GetName (encoding using its
16bit integer is fraught with dangers because the 16bit integer is not
guaranteed to be the same within different processes)
I would suggest a format such as:
[ lentypeidname, typeidnamenullterminated, payloadlen, payload ] with
the length fields encoded as 32bit integers.
I am eagerly waiting for the patch: one less bug open :)
Mathieu Lacage <mathieu.lacage at gmail.com>
More information about the Ns-developers