NS3 วิธีติดตั้งและทดสอบ
Installation
1.) ติดตั้งโปรแกรม VirtualBox จาก https://www.virtualbox.org/wiki/Downloads
2.) ติดตั้ง Ubuntu 17.04
3.) Start VM log-in
4.) เปิด Shell
- Update package lists จาก repositories
$ sudo apt-get update
- Install Compiler และ Python
$ sudo apt-get -y install gcc g++ python python-dev
- Install Mecurial, Git Source Control และ Python Tools
$ sudo apt-get -y install mercurial python-setuptools git
- Install Qt สาหรับ NetAnim Animator
$ sudo apt-get -y install qt4-dev-tools libqt4-dev
- Install Library สาหรับสร้าง Python Binding
$ sudo apt-get -y install cmake libc6-dev libc6-dev-i386 g++-multilib
- Install Debugger
$ sudo apt-get -y install gdb valgrind
- Install GNU Scientific Library Support
$ sudo apt-get -y install gsl-bin libgsl2 libgsl-dev
- Install Component สาหรับ support Network Simulation Cradle (NSC)
$ sudo apt-get -y install flex bison libfl-dev
- Install TCP Dump สาหรับอ่าน traces
$ sudo apt-get -y install tcpdump
- Install Database สาหรับ statistics framework
$ sudo apt-get -y install sqlite sqlite3 libsqlite3-dev
- Install XML Tools
$ sudo apt-get -y install libxml2 libxml2-dev
- Install GTK
$ sudo apt-get -y install libgtk2.0-0 libgtk2.0-dev
- Install Tools สาหรับ Virtual Machine กับ ns3
$ sudo apt-get -y install vtun lxc
- Install Code Styles Checker
$ sudo apt-get -y install uncrustify
- Install Doxygen และ In-Line documentation tools อื่นๆ
$ sudo apt-get -y install doxygen graphviz imagemagick
$ sudo apt-get -y install texlive texlive-extra-utils texlive-latex-extra texlive-font-utils texlive-lang-portuguese dvipng
- Install Tools สาหรับ reStructuredText ใน manual และ tutorial
$ sudo apt-get -y install python-sphinx dia
- Install Tools สาหรับ ns-3-pyviz visualizer
$ sudo apt-get -y install python-pygraphviz python-kiwi python-pygoocanvas libgoocanvas-dev ipython
- Install Tools สาหรับโมดูล Openflow
$ sudo apt-get -y install libboost-signals-dev libboost-filesystem-dev
- Install Tools สาหรับ MPI-based distributed emulation
$ sudo apt-get -y install openmpi-bin openmpi-common openmpi-doc libopenmpi-dev
- Install Tools อื่นๆ
$ sudo apt-get -y install autoconf cvs bzr unrar
- Install 7z
$ sudo apt-get -y install p7zip-full
- Install Synaptic
$ sudo apt-get -y install synaptic
5.) เปลี่ยนมาใช้ GCC Version 4.9
$ sudo apt-get install gcc-4.9 g++-4.9
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 2 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
ตรวจสอบ GCC Version
$ gcc -v
6.) สร้างโฟล์เดอร์ ns3 ดาวน์โหลดและ unzip ns3
$ cd ~/
$ mkdir ns3
$ cd ns3
$ wget http://www.nsnam.org/release/ns-allinone-3.26.tar.bz2
$ tar xjf ns-allinone-3.26.tar.bz2
7.) Build ด้วยสคริปต์
$ cd ~/ns3/ns-allinone-3.26/
$ ./build.py --enable-examples --enable-tests
รอ build จนเสร็จ บาง module อาจไม่ได้รับการ build เนื่องจากไม่ได้ระบุไว้ในออปชั่น
8.) Test เพื่อ verify การทางาน
$ cd ~/ns3/ns-allinone-3.26/ns-3.26
$ ./test.py
Test Example
1.) Copy ไฟล์ตัวอย่างออกมา run ในโฟล์เดอร์ scratch
$ cd ~/ns3/ns-allinone-3.26/ns-3.26/examples/tutorial
$ cp first.cc ~/ns3/ns-allinone-3.26/ns-3.26/scratch/
2.) พิจารณาไฟล์ first.cc
$ cd ~/ns3/ns-allinone-3.26/ns-3.26/scratch/
$ gedit first.cc
ไฟล์ first.cc นี้มีการสร้าง node ขึ้นมา 2 โหนด บน point-to-point network โดยมี Server Application run ที่ port 9 บนโหนดหนึ่ง และ Echo client run ที่อีกโหนดหนึ่ง โดย client ทาการส่ง echo ไปที่ server 1 ครั้ง ให้ server ตอบกลับ
3.) ทดลอง Run
$ cd ~/ns3/ns-allinone-3.26/ns-3.26
$ ./waf --run scratch/first
Install NetAnim
1.) ติดตั้ง qmake
$ sudo apt-get -y install qt4-qmake
2.) ติดตั้ง Build NetAnim
$ cd ~/ns3/ns-allinone-3.26/netanim-3.107/
$ make clean
$ qmake NetAnim.pro
$ make
3.) แก้ไข first.cc ให้สร้างไฟล์สาหรับแสดงการทางานใน Net Anim
$ cd ~/ns3/ns-allinone-3.26/ns-3.26/scratch/
$ gedit first.cc
เพิ่มการ include Library
เพิ่มการสร้าง Animation Interface ให้ output file เป็น first_anim.xml
โดยวางโหนด 0 ไว้ที่ตาแหน่ง x-=1.0 y=1.0 และวางโหนด 1 ไว้ที่ตาแหน่ง x-=2.0 y=1.0 โดยทั้งสองโหนดมีขนาด 0.5
4.) ลอง run ไฟล์ first.cc อีกครั้ง
$ cd ~/ns3/ns-allinone-3.26/ns-3.26
$ ./waf --run scratch/first
ไฟล์ first_anim.xml จะถูก save ไว้ที่ ~/ns3/ns-allinone-3.26/ns-3.26/
5.) เปิด NetAnim
$ cd ~/ns3/ns-allinone-3.26/netanim-3.107/
$ ./NetAnim
คลิกไอคอนเปิดไฟล์ browse ไปเลือกไฟล์ ~/ns3/ns-allinone-3.26/ns-3.26/first_anim.xml แล้วกดปุ่ม run simulation
