You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ns-3-users
hello,
I want to send a string value in the packet header, I added the variable but I don't know how to serialize and desirialize a string : for Integer we use the methodes (i.WriteU8(variable) and i.WriteU16(variable) ect.. ).
what are the functions used for a string variable?
Thank you.
Tom Henderson
unread,
Jul 23, 2022, 11:42:17 AM7/23/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ns-3-...@googlegroups.com, Sedrati Foued
You probably want this method:
/**
* \param buffer a byte buffer to copy in the internal buffer.
* \param size number of bytes to copy.
*
* Write the data in buffer and advance the iterator position
* by size bytes.
*/
void Write (uint8_t const*buffer, uint32_t size);
If you have
std::string m_string;
as a member of your header class (MyHeader), when you are in Serialize()
method you should be able to do something like:
You can do something similar using the matching Read() method. You
will need to pay attention to the size-- you need to read out the same
number of bytes that you wrote in (but you won't necessarily know the
size of the string at Read () time). So, you probably will want to pad
your string out to a well-defined fixed size and use that size value on
the Read () method.