[ndnSIM] how to fill content object
Alex Afanasyev
alexander.afanasyev at ucla.edu
Sun Dec 22 09:37:33 PST 2013
Hi Fabrizio,
You should checkout variants of constructor of NS'3 Packet class: http://www.nsnam.org/doxygen/classns3_1_1_packet.html
Basically, you need to create a "payload packet" which would carry the data you need. For example, you can
std::string data = "foobar";
... payload = Create<Packet> (data.c_str(), data.size());
If you want to carry a structured data, you can also create a custom header class and then use AddHeader/RemoveHeader to get access to the data in the payload.
---
Alex
On Dec 22, 2013, at 7:27 AM, fabrizio saponaro <fab.batta at gmail.com> wrote:
> Hi Alex,
> how can I set the contentObject of a Data manually?
> In my forwarding strategy I've a SendData(Ptr<Face>) that send always the Data with a specific contentObject (for example the string "blablabla") but I don't know how to implement it.
> I tried with:
> Ptr<Data> data = Create<Data> (Create<Packet> (1024));
> Ptr<Name> dataName = Create<Name> ("/dataprefix");
> data->SetName (dataName);
> Ptr<Packet> payload = Create<Packet>();
>
> data->SetPayload(payload); //payload must to contain the string "blablabla"
>
> but payload of SetPayload would be a Ptr<Packet> and I don't know which field of Packet component I've to fill.
>
> Could you help me?
> Thanks,
> Fabrizio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20131222/68eed70d/attachment.html>
More information about the ndnSIM
mailing list