2014-10-28 104 views
0

我想实现在NS3中创建新协议标头的标准建议。我一直在关注http://www.nsnam.org/wiki/HOWTO_create_a_new_type_of_protocol_header_or_trailer的简短教程。标准NS3协议标题示例是否完整?

即使只是将代码复制到相关文件中,我也会收到错误,指出SetData和GetData未定义。

./libns3.21-applications-debug.so: undefined reference to ns3::LocHeader::GetData() const' ./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)' clang: error: linker command failed with exit code 1 (use -v to see invocation)`

我在任何示例代码中都看不到SetData()或GetData()的函数定义。我是否应该自己编写代码?看来这样的代码将包含在示例代码中。

回答

0

答案是肯定的,如果GetData和SetData是由用户实现的,它的确可以工作。

但是,给出的示例代码中缺少两个步骤。

  1. 新的.h和.cc文件必须添加到./wscript文件中,该文件不是很明显。

  2. GetInstanceTypeId的类型定义包含错误。有一个丢失的 “常量”:

    TYPEID YHeader :: GetInstanceTypeId(无效){ 回报 GetTypeId(); }

应改为:

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

我会建议一个更新页面的维护者。