简体   繁体   English

标准NS3协议标头示例是否完整?

[英]Is the standard NS3 protocol header example complete?

I am trying to implement the standard advice for creating a new protocol header in NS3. 我正在尝试实施在NS3中创建新协议标头的标准建议。 I have been following the brief tutorial at http://www.nsnam.org/wiki/HOWTO_create_a_new_type_of_protocol_header_or_trailer . 我一直在关注http://www.nsnam.org/wiki/HOWTO_create_a_new_type_of_protocol_header_or_trailer上的简短教程。

Even just by copying the code into the relevant files, I get errors saying SetData and GetData are undefined. 即使只是将代码复制到相关文件中,我也会收到错误消息,说未定义SetData和GetData。

./libns3.21-applications-debug.so: undefined reference to ns3::LocHeader::GetData() const' ./libns3.21-applications-debug.so: undefined reference to ns3 :: LocHeader :: GetData()const的./libns3.21-applications-debug.so: undefined reference to ./libns3.21-applications-debug.so: undefined reference to vtable for ns3::LocHeader' ./libns3.21-applications-debug.so: undefined reference to ns3::LocHeader::SetData(unsigned int)' ./libns3.21-applications-debug.so: vtable for ns3::LocHeader' ./libns3.21-applications-debug.so: undefined reference to ns3 :: LocHeader :: SetData(unsigned int)的./libns3.21-applications-debug.so: undefined reference to clang: error: linker command failed with exit code 1 (use -v to see invocation)` clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

I don't see function definitions for SetData() or GetData() in any of the example code. 我没有在任何示例代码中看到SetData()或GetData()的函数定义。 Was I supposed to write code that does this myself? 我应该自己编写代码吗? It seems like that would have been included in the example code. 似乎示例代码中已包含该代码。

The answer is yes, it does work if GetData and SetData are implemented by the user. 答案是肯定的,如果用户实现了GetData和SetData,它确实可以工作。

However, there are two steps missing from the example code given. 但是,示例代码缺少两个步骤。

  1. The the new .h and .cc files have to be added to ./wscript, which wasn't immediately obvious. 新的.h和.cc文件必须添加到./wscript中,这并不是立即显而易见的。

  2. The type definition of GetInstanceTypeId contains an error. GetInstanceTypeId的类型定义包含错误。 There was a missing "const": 缺少一个“常量”:

    TypeId YHeader::GetInstanceTypeId (void) { return GetTypeId (); TypeId YHeader :: GetInstanceTypeId(void){return GetTypeId(); } }

should have read: 应该阅读:

TypeId
YHeader::GetInstanceTypeId (void) const
{
return GetTypeId ();
}

I'll suggest an update to the page maintainer. 我建议对页面维护者进行更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM