Add data to packet

1,462 views
Skip to first unread message

Sara

unread,
Jun 1, 2012, 10:24:39 AM6/1/12
to ns-3-...@googlegroups.com
Dear All,
I would like to ask how can man add data like string name to the packet in ns3
I want to create the packet and add a specific data to it
thanks a lot

Konstantinos

unread,
Jun 1, 2012, 10:27:52 AM6/1/12
to ns-3-...@googlegroups.com
This should be what you need

http://www.nsnam.org/support/faq/miscellaneous/

Regards,
Konstantinos

Sara

unread,
Jun 1, 2012, 10:51:56 AM6/1/12
to ns-3-...@googlegroups.com
thanks a lot for your reply, in fact I tried to apply as mentioned in the web page  but there is a problem in the buffer, it can not accept any value except zero
in other case it give this error
invalid conversion from ‘int’ to ‘uint8_t* {aka unsigned char*}’ [-fpermissive]
so I do not know what is the problem. However I need to enter a string data to the packet
thanks again
Best Regards
Sara

phuchong kheawchaoom

unread,
Jun 2, 2012, 10:02:47 AM6/2/12
to ns-3-...@googlegroups.com
 stringstream msgx;
                msgx << "data" ;
                uint16_t packetSize = your packet size;
        Ptr<Packet> packet = Create<Packet>((uint8_t*) msgx.str().c_str(), packetSize);

this can enter string data to the packet.

--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ns-3-users/-/mqVKBfH3u7QJ.

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.

Reply all
Reply to author
Forward
0 new messages