目标:向兴趣包中哦你中添加自定义项(h,x,y)
实验脚本:ndn-simple.cpp
核心文件:
tlv.hpp
interest.hpp&cpp
forwarder.cpp
consumer.cpp
实验步骤:
第一步:向tlv.hpp中写入自定义项;
第二步,在interest.hpp中写入自定义数据成员,以及相应的get,set函数;
第三步,在interest.cpp中实现get,set函数以及数据编解码过程;
第四步,在forwarder.cpp的onincominginterest()中添加输出方式;
第五步,在consumer.cpp的sendpacket()函数中定义自定义域的值。
第六步,终端输入./waf --run ndn-simple(注意在首次waf时需要加–example,这样就不需要将脚本文件复制到scratch 就可以直接运行。)
具体的细节前面几章文件都有,再次感谢给予帮助的同学们!谢谢!
最终部分结果输出如下:
node 1 get interest with field value 1,123,456,90,70,0,1
node 2 get interest with field value 1,123,456,90,70,0,1
+0.021232000s 2 ndn.Producer:OnInterest(0x141b830, 0x146a080)
+0.021232000s 2 ndn.Producer:OnInterest(): [INFO ] Received content object: /prefix/%FE%00?ndn.InterestLifetime=2000&ndn.Nonce=3506978425&ndn.Hello=1
+0.021232000s 2 ndn.Producer:OnInterest(): [I