0
votes

I'm using ns-3 with direct code execution, working on Ubuntu, and after a while, I got everything to work, but the thing is: I have four nodes with each one binary to run, and some of the binaries take input from me at runtime, via std::cin. (They will then send messages to the other nodes based on the input). I need to get this working inside the ns-3-environment and I couldn't figure out how.

So far, if I start my simulation and it gets to the point where a node with an application starts that is waiting for input (in an endless loop), the whole thing blocks, it doesn't start other applications, it never even stops the simulation. If I just curiously type something and hit enter, it says "relocation error: elf-cache/0/libgcc_s.so.1: symbol dl_iterate_phdr, version GLIBC_2.2.5 not defined in file 0001.so.6 with link time reference" and gives me an exit code 127.

So, naturally I would just find out how to do runtime input in ns3, but I can't find any material on this.

1
update---- the relocation error above can be solved using the patch described here: groups.google.com/forum/#!topic/ns-3-users/4CyKNszXgNY Basically you take the file model/libc-dce.cc and add "#include <link.h> ", and in model/libc-ns3.h, you have to add around line 612 "+NATIVE (dl_iterate_phdr) ". If you do this, ns3 will use the original library for this, as hinted here: nsnam.org/docs/dce/manual/html/dce-user-syscalls.html There still remains my original problem: how to I manage input from a file or from std::cin? Any hint or link would be helpful, thank you all.Sorokine

1 Answers

0
votes

So, I found the solution for file input finally. Maybe it's useful for someone.

std::ifstream config_doc("path/here/file.txt", std::ifstream::binary);

worked for me - if you make sure that your path starts at the designated folder for the ns3-node. For example, if it's the 0th (1st) node, it has to be placed inside the folder files-0, like this: (...) /source/ns-3-dce/files-0/path/here/file.txt (if you use path/here/file.txt like above). The node always has its home directory in its files-x directory.