简体   繁体   中英

Is the standard NS3 protocol header example complete?

I am trying to implement the standard advice for creating a new protocol header in NS3. I have been following the brief tutorial at 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.

./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)`

I don't see function definitions for SetData() or GetData() in any of the example code. 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.

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.

  2. The type definition of GetInstanceTypeId contains an error. There was a missing "const":

    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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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