In this section, we'll NS3 the first example, and the simplest example, hello, to start learning.
The following is the source code of hello-simulator.cc:
---------------------------------------------------------------------------------------
#include "ns3/core-module.h"
Declares a log widget called Hellosimulator, by referencing the operation of the name Hellosimulator,
You can implement the output of opening or closing the console log.
Ns_log_component_define ("Hellosimulator");
using namespace Ns3; Namespace's statement
int main (int argc, char *argv[])
{
Ns_log_uncond ("Hello Simulator"); Record related messages unconditionally
}
---------------------------------------------------------------------------------------------
./waf after compiling, run the./waf--run hello-simulator.cc with the following results:
This example is very simple, I believe that some C + + basic friends are quick to understand, then take this example to analyze the characteristics of the two-point NS3 unique.
1. header file
During compilation, each ns-3 include file is placed in a directory called NS3 in the build directory, which avoids conflicts with the include file name. If you look at the NS3 directory you will find a lot of header files.
2. Log
NS3 provides an alternative, multi-level way to log logs. Logs can be completely disabled, or available only to some components, or globally. And NS3 provides a different level of detail for the log levels to choose from. The NS-3 log module provides an intuitive, relatively simple way to use to help users get the information they need for the simulation process.
In an existing system, there are 7 log levels that are more verbose, namely:
? Ns_log_error-log ERROR messages;
? Ns_log_warn-log warning messages;
? Ns_log_debug-log relatively rare, ad-hoc debugging messages;
? Ns_log_info-log Informational messages about program progress;
? Ns_log_function-log a message describing each FUNCTION called;
? Ns_log_logic–log messages describing logical flow within a function;
? Ns_log_all-log everything.
? ns_log_error-log error messages;
? ns_log_warn-record warning messages;
? ns_log_debug-Records relatively infrequent debugging information;
? Ns_log_info-record procedure Progress information;
? ns_log_function-records describe each call function information;
? ns_log_logic– records the information in a function that describes the logic flow;
? ns_log_all-records all information.
We also provide an unconditional log level that has been used all the time, regardless of the log verbosity level or Component selection.
? ns_log_uncond– records related messages unconditionally.
Each level can be called individually, or incrementally.
I am also just beginning to learn, what is wrong, please friends to correct, mutual learning to progress together.
NS3 Example Analysis (1)--hello-simulator.cc