All of the command is execute at the bake/source/ns-3.25 (There some different in the path, it will be a little different for several reason. In brief, the working directory is under the ns-3's source directory.)
This is the most simple execute way.
./waf --run scratch/first
- is the tool for compiling the project and run the project.
- is a running command
- a script path, but it suggests to put the script under scratch directory.
- "scratch/first" means you want to execute the "first.cc". if you type "scratch/first.cc", it will result in error. Just keep in mind.
Execute Script & visualization
I want to make the topology in visualization, how to do?
If you have already installed the pyviz package then you can just execute the following command.
./waf --run scratch/first --vis
- with --vis, this command, then you can call the pyviz to help you to draw the nodes and connection for debuggging.
What's more? debug with GDB.
Sometimes segment fault happens, and you don't know what things happen. There are only feww lines of code, and the messages are ambiguous. You want to know which line of code cause error. This time, you need the help of GDB just below.
./waf --run scratch/first --vis --command-template="gdb --args %s"
In this way, you can enter the gdb. Just click "r" then you can execute the code. After the code exception happens, you can type "bt" then enter. You can see the backtrace of the calling function. It's very helpful.
There are a lot of GDB techniques on the Internet, you can learn by yourself if you need it.
Where is the example?
There are two place you can find the source
Under the above path you can find a lot of work, it really works for tutorial if you are not sure how to control specific device.
You can makes the example code work just like
$ ./waf --run lena-fading --vis
$ ./waf --run simple-error-model --vis
The first command is a example for LTE fading, the code path is the src/lte/example/lena-fading.cc.
The second command is inside the examples/error-model/simple-error-model.cc.
But for example code, you don't need to specify the correct path if you have enabled-example during build the NS3.