--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.
I think that the standard way is to re-read the packet payload with
Packet::CopyData (uint8_t *buffer, uint32_t size) and then write it
back to a new packet as you did before. The non-standard way,
conversely, is to use uint8_t const * Packet::PeekData (void) to get a
pointer to the internal buffer of the packet and then directly write
into it. Less clean but you avoid a deep-copy operation.
Regards
Andrea
Glad to be able to help :)
> Is it possible to write other data types in the payload (uint32_t,
> uint64_t, etc...) or we should convert any data type to string and
> then write it in payload ?. Can you please give me an example ?
I strongly suggest to you to implement your own "application packet"
class with its serialize and deserialize methods, and derive from it
further packet classes as needed. For example, as base class I use an
"overlay packet" such as below.
class OvlPacket
{
public:
OvlPacket ();
OvlPacket (const OvlPacket &a);
virtual ~OvlPacket ();
virtual OvlPacket & operator = (const OvlPacket &ref);
virtual void serialize (std::string &str) const;
virtual bool deserialize (const std::string &str);
virtual void print () const;
private:
void initState ();
static const std::string sep;
std::string header;
std::string id;
std::string ipaddr;
std::string counter;
std::string time;
};
I used strings for my datatypes because I'm a very lazy programmer,
but using the proper datatype and convert them to string in the
serialize method, should be the right thing to do.
Hope this helps
Andrea