I think it may be helpful to write a guide for newbie on the network simulator ns3 for chinese. But this guide will be in English. To develop the ability to google the possible solution to problems in English is a must for programmers, which needs some endeavor to overcome such obstacle.
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-6 g++-6
cd /usr/bin
sudo rm gcc
sudo ln -s gcc-6 gcc
sudo rm g++
sudo ln -s g++-6 g++
reference: Ubuntu升级GCC版本 https://blog.csdn.net/gatieme/article/details/52871438
Downlaod ns3 in github(https://github.com/nsnam/ns-3-dev-git)
And you can download a specific version:
For example download ns3.26(https://github.com/nsnam/ns-3-dev-git/tree/ns-3.26).
Of course, you can download the code with the git method, which may be a bit slower since all the versions will be downloaded.
git clone https://github.com/nsnam/ns-3-dev-git.git
cd ns-3-dev-git/
git tag
git checkout ns-3.26
Cope the content under the folder ns-3-dev to a new created folder ns3.26
Change the warning flags in the fille (waf-tools/cflags.py) which may lead compiling failure.
Original:
self.warnings_flags = [['-Wall'], ['-Werror'], ['-Wextra']]
Changed version:
self.warnings_flags = [['-Wall'], ['-Wno-unused-parameter'], ['-Wextra']]
cd ns-3.26/
sudo su
./waf configure
./waf
In this part, I will use the codes (https://github.com/SoonyangZhang/possion-traffic) as an example to show how to add you own module to ns3. This module is a Possion traffic generator. The one way transmission delay of each received packet will be traced (at receiver side). Each successfully received packet will be acknowledged by the receiver, and the round trip delay will be traced also.
Create a new folder named ‘traces’ under ns-3.26 to collect data. The reason in in the possiontrace.cc.
void PossionTrace::OpenTraceOwdFile(std::string name){
char buf[FILENAME_MAX];
memset(buf,0,FILENAME_MAX);
std::string path = std::string (getcwd(buf, FILENAME_MAX)) + "/traces/"
+name+"_owd.txt";
m_owd.open(path.c_str(), std::fstream::out);
}
void PossionTrace::OpenTraceRttFile(std::string name){
char buf[FILENAME_MAX];
memset(buf,0,FILENAME_MAX);
std::string path = std::string (getcwd(buf, FILENAME_MAX)) + "/traces/"
+name+"_rtt.txt";
m_rtt.open(path.c_str(), std::fstream::out);
}
Put the folder possion folder (download from github)to src in ns-3.26.
put the possion-traffic.cc (in scratch file on github) under scratch file in ns-3.26. Of course, the wscript should be included.
cd ns-3.26
sudo su
./waf configure
./waf
./waf --run scratch/possion-traffic
And the traced data can be got under traces file.
I upload the ns3 with the possion traffic generator in BaiduWangpan (url: https://pan.baidu.com/s/1o6R7y6I_T0VoeJOl0Mo4uQ extraction code: jbav ).
And this version include a trace module (mytrace) and a congestion control module for real time video transmission (nada, https://github.com/cisco/ns3-rmcat).
https://blog.csdn.net/u010643777/article/details/80171171
https://blog.csdn.net/u010643777/article/details/85017577
Change the environment configuration (Ln 499) in wscript under ns3.26
Original:
env.append_value('CXXFLAGS', '-std=c++11')
Modified:
env.append_value('CXXFLAGS', '-std=c++14')
With introduced third party libraries, when you first run simulation, do the command as the following:
sudo su
source /etc/profile
./waf --run "scratch/your-project"