3 ์์ํ๊ธฐ
3.1 ๊ฐ์
3.2 ์ ์ ์กฐ๊ฑด
3.2.1 ns-3 ๋ฆด๋ฆฌ์ค๋ฅผ ์์ค ์์นด์ด๋ธ๋ก ๋ค์ด๋ก๋
3.3 Git์ ์ฌ์ฉํ์ฌ ns-3 ๋ค์ด๋ก๋
3.3.1 Bake๋ฅผ ์ฌ์ฉํ์ฌ ns-3 ๋ก๋
3.4 ns-3 ์กฐ๋ฆฝ
3.4.1 build.py๋ก ๋น๋ํ๊ธฐ
3.4.2 ๋ฒ ์ดํฌ๋ก ๋ง๋ค๊ธฐ
3.4.3 Waf๋ก ๊ตฌ์ถ
3.5 ns-3 ํ
์คํธ
3.6 ์คํฌ๋ฆฝํธ ์คํ
3.6.1 ๋ช
๋ น์ค ์ธ์
3.6.2 ๋๋ฒ๊น
3.6.3 ์์
๋๋ ํ ๋ฆฌ
์ฅ 3
์์ํ๊ธฐ
์ด ์ฅ์ ns-3์ ํ ๋ฒ๋ ์ค์นํ ์ ์ด ์๋ ์ปดํจํฐ์์ ์์ํ๋๋ก ๋ ์๋ฅผ ์ค๋น์ํค๊ธฐ ์ํ ๊ฒ์ ๋๋ค. ์ง์๋๋ ํ๋ซํผ, ์ ์ ์กฐ๊ฑด, ns-3์ ์ป๋ ๋ฐฉ๋ฒ, ns-3์ ๋น๋ํ๋ ๋ฐฉ๋ฒ, ๋น๋๋ฅผ ํ ์คํธํ๊ณ ๊ฐ๋จํ ํ๋ก๊ทธ๋จ์ ์คํํ๋ ๋ฐฉ๋ฒ์ ๋ค๋ฃน๋๋ค.
3.1 ๊ฐ์
ns-3 ์๋ฎฌ๋ ์ดํฐ๋ ํ์ ์ํํธ์จ์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์์คํ ์ผ๋ก ๊ตฌ์ถ๋์์ต๋๋ค. ์กฐ๋ฆฝํ๋ ๋์ ์ฌ์ฉ์ ํ๋ก๊ทธ๋จ์ ์ฝ๋๋ ์ด๋ฌํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์ฐ๊ฒฐ๋ฉ๋๋ค. C++ ๋๋ Python ํ๋ก๊ทธ๋๋ฐ ์ธ์ด๋ ์ฌ์ฉ์ ์ ์ ํ๋ก๊ทธ๋จ์ ์์ฑํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค.
Ns-3์ ์์ค์ฝ๋๋ก ๋ฐฐํฌ๋๋๋ฐ, ์ด๋ ๋จผ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๊ตฌ์ถํ ํ ์ฌ์ฉ์ ํ๋ก๊ทธ๋จ์ ๊ตฌ์ถํ๊ธฐ ์ํด์๋ ๋์ ์์คํ ์ ์ํํธ์จ์ด ๊ฐ๋ฐ ํ๊ฒฝ์ด ์์ด์ผ ํจ์ ์๋ฏธํฉ๋๋ค. ์์น์ ์ผ๋ก ns-3์ ํน์ ์์คํ ์ ์ํ ๊ธฐ์ฑ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ก ๋ฐฐํฌ๋ ์ ์์ผ๋ฉฐ, ํฅํ์๋ ์ด๋ฌํ ๋ฐฉ์์ผ๋ก ๋ฐฐํฌ๋ ์๋ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ์์ฆ์๋ ์ค์ ๋ก ๋ง์ ์ฌ์ฉ์๊ฐ ns-3 ์์ฒด๋ฅผ ํธ์งํ์ฌ ์์ ์ ์ํํ๋ฏ๋ก ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋น๋ํ๊ธฐ ์ํ ์์ค ์ฝ๋๊ฐ ์๋ ๊ฒ์ด ์ ์ฉํฉ๋๋ค. ์ด์์ฒด์ ์ฉ ๊ธฐ์ฑ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฐ ํจํค์ง ์ ์ ์์ ์ ๋งก๊ณ ์ถ์ ๋ถ์ ๋ฉ์ผ๋ง ๋ฆฌ์คํธ์ ๋ฌธ์ํด ์ฃผ์ธ์. ns ๊ฐ๋ฐ์.
๋ค์์ผ๋ก ns-3๋ฅผ ๋ค์ด๋ก๋ํ๊ณ ๋น๋ํ๋ ์ธ ๊ฐ์ง ๋ฐฉ๋ฒ์ ์ดํด๋ณด๊ฒ ์ต๋๋ค. ์ฒซ ๋ฒ์งธ๋ ๋ฉ์ธ ์ฌ์ดํธ์์ ๊ณต์ ๋ฆด๋ฆฌ์ค๋ฅผ ๋ค์ด๋ก๋ํ๊ณ ๋น๋ํ๋ ๊ฒ์ ๋๋ค. ๋ ๋ฒ์งธ๋ ๊ธฐ๋ณธ ns-3 ์ค์น์ ๊ฐ๋ฐ ๋ฒ์ ์ฌ๋ณธ์ ์ ํํ๊ณ ์กฐ๋ฆฝํ๋ ๊ฒ์ ๋๋ค. ์ธ ๋ฒ์งธ๋ ์ถ๊ฐ ๋น๋ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ์ฌ ns-3์ ๋ํ ๋ ๋ง์ ํ์ฅ์ ๋ก๋ํ๋ ๊ฒ์ ๋๋ค. ๋๊ตฌ๊ฐ ์กฐ๊ธ์ฉ ๋ค๋ฅด๊ธฐ ๋๋ฌธ์ ํ๋์ฉ ์ดํด๋ณด๊ฒ ์ต๋๋ค.
์๋ จ๋ Linux ์ฌ์ฉ์๋ ์ ns-3๊ฐ ํจํค์ง ๊ด๋ฆฌ์๋ฅผ ์ฌ์ฉํ๋ ๋๋ถ๋ถ์ ๋ค๋ฅธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ฒ๋ผ ํจํค์ง๋ก ์ ๊ณต๋์ง ์๋์ง ๊ถ๊ธํดํ ์ ์์ต๋๋ค. ๋ค์ํ Linux ๋ฐฐํฌํ(์: Debian)์ ์ํ ๋ฐ์ด๋๋ฆฌ ํจํค์ง๊ฐ ์์ง๋ง ๋๋ถ๋ถ์ ์ฌ์ฉ์๋ ๊ฒฐ๊ตญ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํธ์งํ๊ณ ns-3์ ์ง์ ๋ค์ ๋น๋ํด์ผ ํ๋ฏ๋ก ์์ค ์ฝ๋๋ฅผ ์ฌ์ฉํ ์ ์๋ ๊ฒ์ด ํธ๋ฆฌํฉ๋๋ค. ์ด๋ฌํ ์ด์ ๋ก ์ฐ๋ฆฌ๋ ์์ค์์ ์ค์นํ๋ ๋ฐ ์ค์ ์ ๋ ๊ฒ์ ๋๋ค.
๋๋ถ๋ถ์ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ํ ns-3 ๊ถํ ๋ฟ๋ฆฌ ํ์ํ์ง ์์ ๊ฒฝ์ฐ ๊ถํ์ด ์๋ ์ฌ์ฉ์ ๊ณ์ ์ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
3.2 ์ ์ ์กฐ๊ฑด
์ฌ์ฉ ๊ฐ๋ฅํ ns-3 ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ ์ฒด ์ธํธ์๋ ํ์ฌ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋ํ ์ฌ๋ฌ ๊ฐ์ง ์ข
์์ฑ์ด ์์ง๋ง ๋๋ถ๋ถ์ ๊ฒฝ์ฐ ns-3์ C++ ์ปดํ์ผ๋ฌ, C++ ์ปดํ์ผ๋ฌ, ์์ค ์ฝ๋ ํธ์ง๊ธฐ์ธ Python(์: ์ ๋ ฅ, ์ด๋งฅ์ค ๋๋ ์) ๋ฐ ๊ฐ๋ฐ ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ Git ๋ฒ์ ์ ์ด ์์คํ
. ๋๋ถ๋ถ์ ์ต์ด ์ฌ์ฉ์๋ ๊ตฌ์ฑ์์ ์ผ๋ถ ns-3 ๊ณ ๊ธ ๊ธฐ๋ฅ์ด ๋๋ฝ๋์๋ค๊ณ ๋ณด๊ณ ํ๋๋ผ๋ ๊ฑฑ์ ํ ํ์๊ฐ ์์ง๋ง ์ ์ฒด ์ค์น๋ฅผ ์ํ๋ ์ฌ์ฉ์๋ฅผ ์ํด ํ๋ก์ ํธ์์๋ ์ ์ฉํ ํ๊ณผ ์๋ น์ด ๋ง์ด ํฌํจ๋ ํ์ด์ง๊ฐ ํฌํจ๋ ์ํค๋ฅผ ์ ๊ณตํฉ๋๋ค. ๊ทธ๋ฌํ ํ์ด์ง ์ค ํ๋๋ ๋ค์ํ ์์คํ
์ ๋ํ ์ค์น ์ง์นจ์ด ํฌํจ๋ ์ค์น ํ์ด์ง์
๋๋ค.
์ด Wiki์ ์ ์ ์กฐ๊ฑด ์น์ ์์๋ ์ผ๋ฐ์ ์ธ ns-3 ์ต์ ์ ์ง์ํ๋ ๋ฐ ํ์ํ ํจํค์ง๋ฅผ ์ค๋ช ํ๊ณ ์ผ๋ฐ์ ์ธ Linux ๋๋ macOS์ ํจํค์ง๋ฅผ ์ค์นํ๋ ๋ฐ ์ฌ์ฉ๋๋ ๋ช ๋ น๋ ์ ๊ณตํฉ๋๋ค.
์ด ๊ธฐํ๋ฅผ ํ์ฉํ์ฌ ns-3 ์ํค ํ์ด์ง ๋๋ ๊ธฐ๋ณธ ์น์ฌ์ดํธ๋ฅผ ํ์ํ ์ ์์ต๋๋ค.
๋๊ตฌ ํจํค์ง/๋ฒ์
- C++ ์ปดํ์ผ๋ฌ
clang++ ๋๋ g++(g++ ๋ฒ์ 4.9 ์ด์) - Python
python2 ๋ฒ์ >= 2.7.10 ๋๋ python3 ๋ฒ์ >=3.4 - ํ๋ด
๋ชจ๋ ์ต์ ๋ฒ์ (GitLab.com์ ns-3์ ์ก์ธ์คํ๊ธฐ ์ํด) - ํ๋ฅด
๋ชจ๋ ์ต์ ๋ฒ์ (nsโ3 ๋ฆด๋ฆฌ์ค ์์ถ ํ๊ธฐ์ฉ) - ๋ฒ์ง2
๋ชจ๋ ์ต์ ๋ฒ์ (nsโ3 ๋ฆด๋ฆฌ์ค ์์ถ ํ๊ธฐ์ฉ)
Python์ ๊ธฐ๋ณธ ๋ฒ์ ์ ํ์ธํ๋ ค๋ฉด ๋ค์์ ์
๋ ฅํ์ญ์์ค. python -V
. g++ ๋ฒ์ ์ ํ์ธํ๋ ค๋ฉด ๋ค์์ ์
๋ ฅํ์ธ์. g++ -v
. ๋๊ตฌ๊ฐ ์๊ฑฐ๋ ๋๋ฌด ์ค๋๋ ๊ฒฝ์ฐ ns-3 ์ํค ํ์ด์ง์ ์ค์น ๊ฐ์ด๋๋ฅผ ์ฐธ์กฐํ์ธ์.
์ด์ ๋ถํฐ๋ ๋ ์๊ฐ Linux, MacOS ๋๋ Linux ์๋ฎฌ๋ ์ดํฐ๋ฅผ ์คํํ๊ณ ์๊ณ ์ต์ํ ์์ ๋๊ตฌ๊ฐ ์๋ค๊ณ ๊ฐ์ ํฉ๋๋ค.
3.2.1 ns-3 ๋ฆด๋ฆฌ์ค๋ฅผ ์์ค ์์นด์ด๋ธ๋ก ๋ค์ด๋ก๋
์ด๋ ns-3์ ์ต์ ๋ฆด๋ฆฌ์ค ๋ฐ ํจํค์ง ๋ฒ์ ์ ๋ค์ด๋ก๋ํ๊ณ ์คํํ๋ ค๋ ์ ๊ท ์ฌ์ฉ์๋ฅผ ์ํ ์กฐ์น ๊ณผ์ ์ ๋๋ค. ns-3 ๋ฆด๋ฆฌ์ค๋ ์์ถ๋ ์์ค ์์นด์ด๋ธ๋ก ๊ฒ์๋ฉ๋๋ค. ํ๋ฅด๋ณผ. ํ๋ฅด๋ณผ ์ฌ๋ฌ ํ์ผ์ ํจ๊ป ๊ฒฐํฉํ๋ ํน์ ์ํํธ์จ์ด ์์นด์ด๋ธ ํ์์ ๋๋ค. ์์นด์ด๋ธ๋ ์ผ๋ฐ์ ์ผ๋ก ์์ถ๋ฉ๋๋ค. ns-3 ๋ถํ ํ๋ก์ธ์ค๋ฅผ ํตํด ํ๋ฅด๋ณผ ๊ฐ๋จํฉ๋๋ค. ๋ฆด๋ฆฌ์ค๋ฅผ ์ ํํ๊ณ ๋ค์ด๋ก๋ํ์ฌ ์์ถ์ ํ๋ฉด ๋ฉ๋๋ค.
์ฌ์ฉ์๋ก์ ๋ค์๊ณผ ๊ฐ์ ๋ก์ปฌ ๋๋ ํ ๋ฆฌ์ ns-3์ ๋น๋ํ๋ค๊ณ ๊ฐ์ ํด ๋ณด๊ฒ ์ต๋๋ค. ์์ ๊ณต๊ฐ. Linux ์ฝ์์ ๋ค์์ ์ ๋ ฅํ์ฌ ๋ฆด๋ฆฌ์ค์ ์์ ๋ณต์ฌ๋ณธ์ ์ป์ ์ ์์ต๋๋ค(๋ฌผ๋ก ์ ์ ํ ๋ฒ์ ๋ฒํธ๋ก ๋์ฒด).
$ cd
$ mkdir workspace
$ cd workspace
$ wget https://www.nsnam.org/release/ns-allinone-3.29.tar.bz2
$ tar xjf ns-allinone-3.29.tar.bz2
์์ ์ฌ์ฉ๋ ์ ํธ๋ฆฌํฐ์ ์ฃผ์ํ์ธ์. wget๋ ์ธํฐ๋ท์์ ๊ฐ์ฒด๋ฅผ ๋ค์ด๋ก๋ํ๊ธฐ ์ํ ๋ช ๋ น์ค ๋๊ตฌ์ ๋๋ค. ์ค์นํ์ง ์์ ๊ฒฝ์ฐ ๋ธ๋ผ์ฐ์ ๋ฅผ ์ฌ์ฉํ์ฌ ์ด๋ฅผ ์ํํ ์ ์์ต๋๋ค.
๋ค์ ๋จ๊ณ์ ๋ฐ๋ผ ns-allinone-3.29 ๋๋ ํ ๋ฆฌ๋ก ์ด๋ํ๋ฉด ์ฌ๋ฌ ํ์ผ๊ณผ ๋๋ ํ ๋ฆฌ๊ฐ ํ์๋ฉ๋๋ค.
$ cd ns-allinone-3.29
$ ls
bake constants.py ns-3.29 README
build.py netanim-3.108 pybindgen-0.17.0.post58+ngcf00cc0 util.py
์ด์ ns-3 ๊ธฐ๋ณธ ๋ฐฐํฌํ์ ๊ตฌ์ถํ ์ค๋น๊ฐ ๋์์ผ๋ฉฐ ns-3 ๊ตฌ์ถ ์น์ ์ผ๋ก ์ด๋ํ ์ ์์ต๋๋ค.
3.3 Git์ ์ฌ์ฉํ์ฌ ns-3 ๋ค์ด๋ก๋
ns-3 ์ฝ๋๋ GitLab.com์ Git ๋ฆฌํฌ์งํ ๋ฆฌ์์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
Git ๋ฆฌํฌ์งํ ๋ฆฌ ์ฌ์ฉ์ ์์ํ๋ ๊ฐ์ฅ ์ฌ์ด ๋ฐฉ๋ฒ์ ํ๊ฒฝ์ ํฌํฌํ๊ฑฐ๋ ๋ณต์ ํ๋ ๊ฒ์ ๋๋ค. ns-3-์๋ฆฌ๋ ผ. ์ด๋ ๊ฐ์ฅ ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ๋๋ ns-3 ํ์ ์์คํ ์ ๋ก๋ ๋ฐ ์ด์ ๋ธ๋ฆฌ๋ฅผ ๊ด๋ฆฌํ๋ ์คํฌ๋ฆฝํธ ์ธํธ์ ๋๋ค. Git์ ์ฒ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ "ํฌํฌ"์ "๋ณต์ "๋ผ๋ ์ฉ์ด๊ฐ ๋ฏ์ค ์๋ ์์ต๋๋ค. ๊ทธ๋ ๋ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด GitLab.com์ ์๋ ์ ์ฅ์๋ฅผ ๊ฐ๋จํ ๋ณต์ (์์ ๋ง์ ๋ณต์ฌ๋ณธ ๋ง๋ค๊ธฐ)ํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
$ cd
$ mkdir workspace
$ cd workspace
$ git clone https://gitlab.com/nsnam/ns-3-allinone.git
$ cd ns-3-allinone
์ด ๋จ๊ณ์์ ๋๋ ํฐ๋ฆฌ ๋ณด๊ธฐ๋ ns-3-์๋ฆฌ๋ ผ ์์์ ์ค๋ช ํ ๋ฆด๋ฆฌ์ค ์์นด์ด๋ธ ๋๋ ํ ๋ฆฌ์ ์ฝ๊ฐ ๋ค๋ฆ ๋๋ค. ๋ค์๊ณผ ๊ฐ์์ผ ํฉ๋๋ค.
$ ls
build.py constants.py download.py README util.py
์คํฌ๋ฆฝํธ๊ฐ ์์ผ๋ ์ฐธ๊ณ ํด์ฃผ์ธ์ ๋ค์ด๋ก๋.py, ๊ทธ๋ฌ๋ฉด ns-3 ๋ฐ ๊ทธ์ ์๋ฐ๋๋ ์์ค ์ฝ๋๊ฐ ์ถ๊ฐ๋ก ์ถ์ถ๋ฉ๋๋ค. ์ฌ๊ธฐ์๋ ์ต์ ns-3 ๊ฐ๋ฐ ์ค๋ ์ท์ ๋ค์ด๋ก๋ํ๊ฑฐ๋ ๋ค์ ์ค ํ๋๋ฅผ ์ ํํ ์ ์์ต๋๋ค.
$ python download.py
๋๋ ํ๋๊ทธ๋ฅผ ์ฌ์ฉํ์ฌ ns-3 ๋ฆด๋ฆฌ์ค๋ฅผ ์ ํธํฉ๋๋ค. -n
๋ฆด๋ฆฌ์ค ๋ฒํธ๋ฅผ ํ์ํ๋ ค๋ฉด ๋ค์์ ์ํํ์ญ์์ค.
$ python download.py -n ns-3.29
์ด ๋จ๊ณ ํ์ ๋๋ ํ ๋ฆฌ๋ก ns-3-์๋ฆฌ๋ ผ ์ถ๊ฐ ์ ์ฅ์๊ฐ ๋ค์ด๋ก๋๋ฉ๋๋ค ns-3, ๊ตฝโโ๋ค, ํผ๋น์ ะธ ๋คํ๋.
์ฃผ์
Ubuntu16.04๊ฐ ๊นจ๋ํ ์์คํ
์์๋ ๋ช
๋ น์ ๋ค์๊ณผ ๊ฐ์ด ๋ณ๊ฒฝํด์ผ ํ์ต๋๋ค. $ sudo python3 download.py -n ns-3.29
(์ดํ ๋ฒ์ญ์ ์ฃผ).
3.3.1 Bake๋ฅผ ์ฌ์ฉํ์ฌ ns-3 ๋ก๋
์์ ๋ ๊ฐ์ง ๋ฐฉ๋ฒ(์์ค ์์นด์ด๋ธ ๋๋ ์ ์ฅ์ ns-3-์๋ฆฌ๋ ผ Git์ ํตํด)๋ ์ฌ๋ฌ ์ ๋์จ์ ์ฌ์ฉํ์ฌ ๊ฐ์ฅ ๊ฐ๋จํ ns-3 ์ค์น๋ฅผ ์ป๋ ๋ฐ ์ ์ฉํฉ๋๋ค(ํผ๋น์ Python ๋ฐ์ธ๋ฉ์ ์์ฑํ๊ณ ๋คํ๋ ๋คํธ์ํฌ ์ ๋๋ฉ์ด์ ์ ๊ฒฝ์ฐ). ns-3-allinone์์ ๊ธฐ๋ณธ์ ์ผ๋ก ์ ๊ณต๋๋ ์ธ ๋ฒ์งธ ์ ์ฅ์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. ๊ตฝโโ๋ค.
๋นต ๊ตฝ๊ธฐ ns-3 ํ๋ก์ ํธ๋ฅผ ์ํด ๊ฐ๋ฐ๋ ์ฌ๋ฌ ์ ์ฅ์์ ์ํํธ์จ์ด๋ฅผ ๊ณต๋์ผ๋ก ๊ตฌ์ถํ๊ธฐ ์ํ ๋๊ตฌ์ ๋๋ค. ๋นต ๊ตฝ๊ธฐ ns-3์ ๊ฐ๋ฐ ๋ฒ์ ์ ๊ตฌํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ ๋ฟ๋ง ์๋๋ผ ํ๊ฒฝ๊ณผ ๊ฐ์ ns-3 ๋ฐฐํฌํ์ ๊ธฐ๋ณธ ๋ฒ์ ํ์ฅ์ ๋ค์ด๋ก๋ํ๊ณ ๋น๋ํ๋ ๋ฐ์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค. ์ง์ ์ฝ๋ ์คํ, CradleNetwork ์๋ฎฌ๋ ์ด์ ํฌ๋๋ค, ์๋ก์ด Python ๋ฐ์ธ๋ฉ ๋ฐ ๋ค์ํ ns-3 "์ฑ"์ ์์ฑํ๋ ๊ธฐ๋ฅ์ ๋๋ค.
์ฃผ์
CradleNetwork ์๋ฎฌ๋ ์ด์
Cradle์ ๋คํธ์ํฌ ์๋ฎฌ๋ ์ดํฐ ๋ด์์ ์ค์ TCP/IP ๋คํธ์ํฌ ์คํ์ ์ฌ์ฉํ ์ ์๊ฒ ํด์ฃผ๋ ํ๋ ์์ํฌ์
๋๋ค.
ns-3 ์ค์น์ ๊ณ ๊ธ ๊ธฐ๋ฅ์ด๋ ์ถ๊ฐ ๊ธฐ๋ฅ์ด ํ์ํ ๊ฒฝ์ฐ ์ด ์ค์น ๊ฒฝ๋ก๋ฅผ ๋ฐ๋ฅผ ์ ์์ต๋๋ค.
์ต์ ns-3 ๋ฆด๋ฆฌ์ค ๋นต ๊ตฝ๊ธฐ tar ๋ฆด๋ฆฌ์ค์ ์ถ๊ฐ๋์์ต๋๋ค. ๋ฆด๋ฆฌ์ค์๋ ๋ฆด๋ฆฌ์ค ๋น์์ ์ต์ ์ํํธ์จ์ด ๋ฒ์ ์ ๋ค์ด๋ก๋ํ ์ ์๋ ๊ตฌ์ฑ ํ์ผ์ด ํฌํจ๋์ด ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ๋ฒ์ ์ ๋๋ค. ๋นต ๊ตฝ๊ธฐns-3.29 ๋ฆด๋ฆฌ์ค์ ํจ๊ป ๋ฐฐํฌ๋๋ ns-3 ์ดํ ๋ฆด๋ฆฌ์ค์ ๊ตฌ์ฑ ์์๋ฅผ ๊ฒ์ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ง๋ง ์ดํ ๋ฆด๋ฆฌ์ค์ ๊ตฌ์ฑ ์์๋ฅผ ๊ฒ์ํ๋ ๋ฐ๋ ์ฌ์ฉํ ์ ์์ต๋๋ค(ํจํค์ง ์ค๋ช ํ์ผ์ด bakingconf.xml ์ ๋ฐ์ดํธ๋์ง ์์์ต๋๋ค).
์ต์ ์ฌ๋ณธ์ ์ป์ ์๋ ์์ต๋๋ค. ๊ตฝโโ๋คLinux ์ฝ์์ ๋ค์ ๋ช ๋ น์ ์ ๋ ฅํฉ๋๋ค(Git๊ฐ ์ค์น๋์ด ์๋ค๊ณ ๊ฐ์ ).
$ cd
$ mkdir workspace
$ cd workspace
$ git clone https://gitlab.com/nsnam/bake.git
git ๋ช ๋ น์ ์คํํ๋ฉด ๋ค์๊ณผ ๊ฐ์ ๋ด์ฉ์ด ํ์๋ฉ๋๋ค.
Cloning into 'bake'...
remote: Enumerating objects: 2086, done.
remote: Counting objects: 100% (2086/2086), done.
remote: Compressing objects: 100% (649/649), done.
remote: Total 2086 (delta 1404), reused 2078 (delta 1399)
Receiving objects: 100% (2086/2086), 2.68 MiB | 3.82 MiB/s, done.
Resolving deltas: 100% (1404/1404), done.
๋ช ๋ น์ด ์๋ฃ๋ ํ ๋ณต์ ์ด๋ฆ์ด ์ง์ ๋ ๋๋ ํ ๋ฆฌ๊ฐ ์์ด์ผ ํฉ๋๋ค. ๊ตฝโโ๋ค, ๊ทธ ๋ด์ฉ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
$ cd bake
$ ls
bake bakeconf.xml bake.py doc examples generate-binary.py test TODO
์ฌ๋ฌ Python ์คํฌ๋ฆฝํธ, ์ฆ Python ๋ชจ๋์ด๋ผ๋ ์ด๋ฆ์ ๋ก๋ํ์ต๋๋ค. ๊ตฝโโ๋ค ๋ฐ XML ๊ตฌ์ฑ ํ์ผ. ๋ค์ ๋จ๊ณ๋ ์ด ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํ์ฌ ์ํ๋ ns-3 ๋ฐฐํฌํ์ ๋ค์ด๋ก๋ํ๊ณ ๋น๋ํ๋ ๊ฒ์ ๋๋ค. ์ฌ๋ฌ ๊ฐ์ง ์ฌ์ฉ์ ์ ์ ๋์์ ์ฌ์ฉํ ์ ์์ต๋๋ค:
-
ns-3.29: ๋ฆด๋ฆฌ์ค์ ํด๋นํ๋ ๋ชจ๋; tarball์ ๋ฆด๋ฆฌ์ค์ ์ ์ฌํ ๊ตฌ์ฑ ์์๋ฅผ ๋ค์ด๋ก๋ํฉ๋๋ค.
-
ns-3-dev: ์ ์ฌํ ๋ชจ๋์ด์ง๋ง ๊ฐ๋ฐ ํธ๋ฆฌ์ ์ฝ๋๋ฅผ ์ฌ์ฉํฉ๋๋ค.
-
ns-์๋ฆฌ๋ ผ-3.29: Click Routing, Network Simulation Cradle, Openflow for ns-3 ๋ฑ ๊ธฐํ ์ถ๊ฐ ๊ธฐ๋ฅ์ ํฌํจํ๋ ๋ชจ๋์ ๋๋ค.
-
ns-3-์๋ฆฌ๋ ผ: ๋ชจ๋์ ๋ฆด๋ฆฌ์ค ๋ฒ์ ๊ณผ ์ ์ฌ allinone, ๊ทธ๋ฌ๋ ๊ฐ๋ฐ ์ฝ๋์ฉ์ ๋๋ค.
์ฃผ์
โ ๋ผ์ฐํฐ ์์ฑ์ ์ํ ๋ชจ๋์ ์ํํธ์จ์ด ์ํคํ
์ฒ.
์คํํ๋ก์ฐ(Openflow)๋ ๋ผ์ฐํฐ์ ์ค์์น ๋ฑ์ด ๋ฐ์ดํฐ ๋คํธ์ํฌ๋ฅผ ํตํด ์ ์ก๋๋ ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌํ๋ ๊ณผ์ ์ ๊ด๋ฆฌํ๋ ํ๋กํ ์ฝ๋ก, ์ํํธ์จ์ด ์ ์ ๋คํธ์ํฌ ๊ธฐ์ ์ ๊ตฌํํ๋ค.
ํ์ฌ ๊ฐ๋ฐ ์ค๋
์ท(๋น๋ฆด๋ฆฌ์ค) ns-3์ ๋ค์์์ ์ฐพ์ ์ ์์ต๋๋ค.
๊ฐ๋ฐ์๋ ์ด๋ฌํ ๋ฆฌํฌ์งํ ๋ฆฌ๋ฅผ ์ผ๊ด๋ ์์ ์์๋ก ์ ์งํ๋ ค๊ณ ๋ ธ๋ ฅํ์ง๋ง ์ด๋ ๊ฐ๋ฐ ์์ญ์ ์๊ณ ๋ฆด๋ฆฌ์ค๋์ง ์์ ์ฝ๋๋ฅผ ํฌํจํ๋ฏ๋ก ์๋ก์ด ๊ธฐ๋ฅ์ ์ฌ์ฉํ ๊ณํ์ด ์๋ค๋ฉด ๊ณต์ ๋ฆด๋ฆฌ์ค๋ฅผ ์ ํํ์ญ์์ค.
๋ฆฌํฌ์งํ ๋ฆฌ ๋ชฉ๋ก์ ๊ฒ์ํ๊ฑฐ๋ ns-3 ๋ฆด๋ฆฌ์ค ์น ํ์ด์ง๋ก ์ด๋ํ์ฌ ์ต์ ๋ฒ์ ์ ์ฝ๋๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.
์ด์ ํ์ํ ns-3 ๊ตฌ์ฑ์์๋ฅผ ์ป๊ธฐ ์ํด ๋๊ตฌ๋ฅผ ์ฌ์ฉํ๊ฒ ์ต๋๋ค. ๋นต ๊ตฝ๊ธฐ. ์ํ์ ๋ํ ๋ช ๊ฐ์ง ์๊ฐ๋ฅผ ํด๋ณด์. ๋นต ๊ตฝ๊ธฐ.
Bake๋ ํจํค์ง ์์ค๋ฅผ ๋๋ ํฐ๋ฆฌ์ ๋ก๋ํ๋ ๋ฐฉ์์ผ๋ก ์๋ํฉ๋๋ค. ๋น๋ ๋๋ ํฐ๋ฆฌ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ค์นํฉ๋๋ค. ๋นต ๊ตฝ๊ธฐ ๋ฐ์ด๋๋ฆฌ๋ฅผ ์ฐธ์กฐํ์ฌ ์คํํ ์ ์์ง๋ง ์คํํ๋ ค๋ ๊ฒฝ์ฐ ๋นต ๊ตฝ๊ธฐ ๋ค์ด๋ก๋๋ ๋๋ ํ ๋ฆฌ๊ฐ ์๋ ๋ค์ ๊ฒฝ๋ก๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ๊ตฝโโ๋ค ์๋ฅผ ๋ค์ด ๋ค์๊ณผ ๊ฐ์ด ๊ฒฝ๋ก(PATH ํ๊ฒฝ ๋ณ์)์ ์ถ๊ฐํฉ๋๋ค(Linux bash ์ ธ์ ์). "bake" ๋๋ ํฐ๋ฆฌ๋ก ์ด๋ํ ํ ๋ค์ ํ๊ฒฝ ๋ณ์๋ฅผ ์ค์ ํฉ๋๋ค.
$ export BAKE_HOME=`pwd`
$ export PATH=$PATH:$BAKE_HOME:$BAKE_HOME/build/bin
$ export PYTHONPATH=$PYTHONPATH:$BAKE_HOME:$BAKE_HOME/build/lib
๊ทธ๋ฌ๋ฉด ํ๋ก๊ทธ๋จ์ด ๋ฐฐ์น๋ฉ๋๋ค. baking.py ์ ๊ฒฝ๋ก์ ์ถ๊ฐํ๊ณ ๋ค๋ฅธ ํ๋ก๊ทธ๋จ์ด ์์ ์ด ์์ฑํ ์คํ ํ์ผ๊ณผ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฐพ์ ์ ์๋๋ก ํ์ฉํฉ๋๋ค. ๊ตฝโโ๋ค. ์ผ๋ถ ์ฌ์ฉ ์ฌ๋ก์์๋ ๊ตฝโโ๋ค, ์์์ ์ค๋ช ํ PATH ๋ฐ PYTHONPATH ์ค์ ์ ํ์ํ์ง ์์ง๋ง ์ผ๋ฐ์ ์ผ๋ก ns-3-allinone(์ถ๊ฐ ํจํค์ง ํฌํจ)์ ์ ์ฒด ๋น๋์๋ ํ์ํฉ๋๋ค.
์์ ๋๋ ํฐ๋ฆฌ๋ก ์ด๋ํ์ฌ ์ฝ์์ ๋ค์์ ์ ๋ ฅํฉ๋๋ค.
$ ./bake.py configure -e ns-3.29
๋ค์์ผ๋ก ๋ฌผ์ด๋ณด๊ฒ ์ต๋๋ค. ๋นต ๊ตฝ๊ธฐ ๋ค์ํ ๊ตฌ์ฑ ์์๋ฅผ ๋ก๋ํ ์ ์๋ ์ถฉ๋ถํ ๋๊ตฌ๊ฐ ์๋์ง ํ์ธํ์ธ์. ๋ค์ด์ผ:
$ ./bake.py check
๋ค์๊ณผ ๊ฐ์ ๋ด์ฉ์ด ํ์๋ฉ๋๋ค.
> Python - OK
> GNU C++ compiler - OK
> Mercurial - OK
> Git - OK
> Tar tool - OK
> Unzip tool - OK
> Make - OK
> cMake - OK
> patch tool - OK
> Path searched for tools: /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin ...
ํนํ Mercurial, CVS, Git ๋ฐ Bazaar์ ๊ฐ์ ์ ๋ก๋ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ๋ฉด ์ฝ๋๋ฅผ ์ป์ ์ ์์ผ๋ฏ๋ก ์ด ๋จ๊ณ์์ ํ์์ ์ ๋๋ค. ์ด ๋จ๊ณ์์๋ ์์คํ ์ ์ผ๋ฐ์ ์ธ ๋ฐฉ๋ฒ์ผ๋ก ๋๋ฝ๋ ๋๊ตฌ๋ฅผ ์ค์นํ๊ฑฐ๋(๋ฐฉ๋ฒ์ ์๊ณ ์๋ ๊ฒฝ์ฐ) ์์คํ ๊ด๋ฆฌ์์๊ฒ ๋์์ ์์ฒญํ์ญ์์ค.
๋ค์์ผ๋ก ์ํํธ์จ์ด๋ฅผ ๋ค์ด๋ก๋ํด ๋ณด์ธ์.
$ ./bake.py download
๊ฒฐ๊ณผ๋ ๋ค์๊ณผ ๊ฐ์์ผ ํฉ๋๋ค.
>> Searching for system dependency setuptools - OK
>> Searching for system dependency libgoocanvas2 - OK
>> Searching for system dependency gi-cairo - OK
>> Searching for system dependency pygobject - OK
>> Searching for system dependency pygraphviz - OK
>> Searching for system dependency python-dev - OK
>> Searching for system dependency qt - OK
>> Searching for system dependency g++ - OK
>> Downloading pybindgen-0.19.0.post4+ng823d8b2 (target directory:pybindgen) - OK
>> Downloading netanim-3.108 - OK
>> Downloading ns-3.29 - OK
์ด๋ ์ธ ๊ฐ์ ์์ค๊ฐ ๋ค์ด๋ก๋๋์์์ ์๋ฏธํฉ๋๋ค. ์ด์ ์์ค ๋๋ ํฐ๋ฆฌ๋ก ์ด๋ํ์ฌ ls๋ฅผ ์ ๋ ฅํฉ๋๋ค. ๋ ๋ด์ผ ํด:
$ cd source
$ ls
netanim-3.108 ns-3.29 pybindgen
์ด์ ns-3 ๋ฐฐํฌํ์ ๊ตฌ์ถํ ์ค๋น๊ฐ ๋์์ต๋๋ค.
3.4 ns-3 ์กฐ๋ฆฝ
ns-3์ ๋ค์ด๋ก๋ํ ๋์ ๋ง์ฐฌ๊ฐ์ง๋ก ns-3์ ๋น๋ํ๋ ๋ฐฉ๋ฒ์๋ ์ฌ๋ฌ ๊ฐ์ง๊ฐ ์์ต๋๋ค. ์ฐ๋ฆฌ๊ฐ ๊ฐ์กฐํ๊ณ ์ถ์ ๊ฐ์ฅ ์ค์ํ ์ ์ ns-3์ด ๋ค์์ด๋ผ๋ ๋น๋ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ์ฌ ๊ตฌ์ถ๋๋ค๋ ๊ฒ์ ๋๋ค. ์ํ์๋์์ ๋ฌ์ฌ ๋์ด์ง. ๋๋ถ๋ถ์ ์ฌ์ฉ์๋ ์ํํ์ง๋ง ๋ ๋ณต์กํ ๋น๋๋ฅผ ์์ํ๊ฑฐ๋ ๊ตฌ์ฑํ๋ ๋ฐ ๋์์ด ๋๋ ๋ช ๊ฐ์ง ํธ๋ฆฌํ ์คํฌ๋ฆฝํธ๊ฐ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ์ด ๋ด์ฉ์ ์ฝ๊ธฐ ์ ์ ์ํ, ๋ณด์ธ์ build.py ๊ทธ๋ฆฌ๊ณ ์กฐ๋ฆฝ ๊ตฝโโ๋ค.
3.4.1 build.py๋ก ๋น๋ํ๊ธฐ
๊ฒฝ๊ณ ! ์ด ๋น๋ ๋จ๊ณ๋ ์์์ ์ค๋ช ํ ๋๋ก ์ป์ ์์ค ์์นด์ด๋ธ ๋ฒ์ ์์๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค. git์ด๋ baking์ ํตํด ๋ค์ด๋ก๋๋์ง ์์์ต๋๋ค.
๋ฆด๋ฆฌ์ค ์์นด์ด๋ธ๋ก ์์ ํ ๋ ํ๋ฅด๋ณผ์ ns-3-์๋ฆฌ๋ ผ ๊ตฌ์ฑ ์์๋ฅผ ๋ ์ฝ๊ฒ ์กฐ๋ฆฝํ ์ ์๋ ํธ๋ฆฌํ ์คํฌ๋ฆฝํธ๊ฐ ์์ต๋๋ค. build.py๋ผ๊ณ ํฉ๋๋ค. ์ด ํ๋ก๊ทธ๋จ์ ๊ฐ์ฅ ์ ์ฉํ ๋ฐฉ์์ผ๋ก ํ๋ก์ ํธ๋ฅผ ์ค์ ํฉ๋๋ค. ๊ทธ๋ฌ๋ ns-3์ ์ฌ์ฉํ ๊ณ ๊ธ ์ค์ ๋ฐ ์์ ์๋ ์ผ๋ฐ์ ์ผ๋ก ์ด ํํ ๋ฆฌ์ผ์ ๋ท๋ถ๋ถ์์ ์๊ฐํ ns-3์ ์์ฒด ๋น๋ ์์คํ ์ธ Waf๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ํฌํจ๋ฉ๋๋ค.
๋ค์์ ์ฌ์ฉํ์ฌ ๋ค์ด๋ก๋ํ ๊ฒฝ์ฐ ํ๋ฅด๋ณผ, ๊ทธ๋ฐ ๋ค์ ๋๋ ํฐ๋ฆฌ์ ~/์์ ๊ณต๊ฐ ๋ค์๊ณผ ๊ฐ์ ์ด๋ฆ์ ๊ฐ์ง ๋๋ ํ ๋ฆฌ ns-์๋ฆฌ๋ ผ-3.29. ๋ค์์ ์ ๋ ฅ:
$ ./build.py --enable-examples --enable-tests
์ ํํ ๋ build.py ์ด ํํ ๋ฆฌ์ผ์์ ์ฌ์ฉ๋ ์์ ์ ํ ์คํธ๋ฅผ ๋น๋ํ๊ธฐ ์ํด ๋ช ๋ น์ค ์ธ์๋ฅผ ์ฌ์ฉํ๋๋ฐ, ์ด๋ ns-3์์๋ ๊ธฐ๋ณธ์ ์ผ๋ก ๋น๋๋์ง ์์ต๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ํ๋ก๊ทธ๋จ์ ์ฌ์ฉ ๊ฐ๋ฅํ ๋ชจ๋ ๋ชจ๋๋ ๋น๋ํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ์ํ๋ค๋ฉด ์์ ๋ ํ ์คํธ ์์ด ns-3์ ๊ตฌ์ถํ๊ฑฐ๋ ์์ ์ ํ์ํ์ง ์์ ๋ชจ๋์ ์ ์ธํ ์ ์์ต๋๋ค.
๋ก๋ํ ๋ค์ํ ๋ถ๋ถ์ ๋น๋ํ ๋ ์คํฌ๋ฆฝํธ์ ์ํด ํ์๋๋ ๋ง์ ์ปดํ์ผ๋ฌ ์ถ๋ ฅ ๋ฉ์์ง๋ฅผ ๋ณผ ์ ์์ต๋๋ค. ๋จผ์ ์คํฌ๋ฆฝํธ๋ ์ ๋๋ฉ์ดํฐ๋ฅผ ๊ตฌ์ถํ๋ ค๊ณ ์๋ํฉ๋๋ค. ๋คํ๋, ๋ฐ์ธ๋ฉ ์์ฑ๊ธฐ ํผ๋น์ ๋ง์ง๋ง์ผ๋ก ns-3์ ๋๋ค. ํ๋ก์ธ์ค๊ฐ ์๋ฃ๋๋ฉด ๋ค์์ด ํ์๋ฉ๋๋ค.
Waf: Leaving directory '/path/to/workspace/ns-allinone-3.29/ns-3.29/build'
'build' finished successfully (6m25.032s)
Modules built:
antenna aodv applications
bridge buildings config-store
core csma csma-layout
dsdv dsr energy
fd-net-device flow-monitor internet
internet-apps lr-wpan lte
mesh mobility mpi
netanim (no Python) network nix-vector-routing
olsr point-to-point point-to-point-layout
propagation sixlowpan spectrum
stats tap-bridge test (no Python)
topology-read traffic-control uan
virtual-net-device visualizer wave
wifi wimax
Modules not built (see ns-3 tutorial for explanation):
brite click openflow
Leaving directory ./ns-3.29
๋ชฉ๋ก์ ๋ง์ง๋ง ์ธ ์ค์๋ ๋น๋๋์ง ์์ ๋ชจ๋์ ๋ํ ๋ฉ์์ง๊ฐ ํ์๋ฉ๋๋ค.
Modules not built (see ns-3 tutorial for explanation):
brite click
์ด๋ ๋จ์ํ ์ธ๋ถ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์์กดํ๋ ์ผ๋ถ ns-3 ๋ชจ๋์ด ๊ตฌ์ถ๋์ง ์์๊ฑฐ๋ ์ด ๊ตฌ์ฑ์ ์ํด ๊ตฌ์ถํ ํ์๊ฐ ์์์ ์๋ฏธํฉ๋๋ค. ์ด๋ ์๋ฎฌ๋ ์ดํฐ๊ฐ ์กฐ๋ฆฝ๋์ง ์์๊ฑฐ๋ ์กฐ๋ฆฝ๋ ๋ชจ๋์ด ์ฌ๋ฐ๋ฅด๊ฒ ์๋ํ์ง ์๋๋ค๋ ์๋ฏธ๋ ์๋๋๋ค.
3.4.2 ๋ฒ ์ดํฌ๋ก ๋ง๋ค๊ธฐ
์์์ ๋ฒ ์ดํน์ ์ฌ์ฉํ์ฌ ํ๋ก์ ํธ ์ ์ฅ์์์ ์์ค ์ฝ๋๋ฅผ ๊ฐ์ ธ์จ ๊ฒฝ์ฐ ์ด๋ฅผ ๊ณ์ ์ฌ์ฉํ์ฌ ns-3์ ๋น๋ํ ์ ์์ต๋๋ค. ๋ค์ด์ผ:
$ ./bake.py build
๊ทธ๋ฌ๋ฉด ๋ค์๊ณผ ๊ฐ์ ๋ด์ฉ์ด ํ์๋ฉ๋๋ค.
>> Building pybindgen-0.19.0.post4+ng823d8b2 - OK
>> Building netanim-3.108 - OK
>> Building ns-3.29 - OK
ํดํ: "bake.py ๋ฐฐํฌ"๋ฅผ ํธ์ถํ์ฌ ๋ค์ด๋ก๋์ ๋น๋ ๋จ๊ณ๋ฅผ ๋์์ ์ํํ ์๋ ์์ต๋๋ค.
๋ชจ๋ ๊ตฌ์ฑ ์์๋ฅผ ์กฐ๋ฆฝํ๋ ๋ฐ ์คํจํ ์ ์์ง๋ง ๊ตฌ์ฑ ์์๊ฐ ํ์ํ์ง ์์ผ๋ฉด ์กฐ๋ฆฝ์ด ๊ณ์๋ฉ๋๋ค. ์๋ฅผ ๋ค์ด, ์ต๊ทผ ์ด์์ฑ ๋ฌธ์ ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. ์บ์คํธxml ๋๊ตฌ๋ก ์กฐ๋ฆฝ ๊ฐ๋ฅ ๊ตฝโโ๋ค ๋ชจ๋ ํ๋ซํผ์ ์๋ ๊ฒ์ ์๋๋๋ค. ์ด ๊ฒฝ์ฐ ๋ค์๊ณผ ๊ฐ์ ๋ฉ์์ง๊ฐ ๋ํ๋ฉ๋๋ค.
>> Building castxml - Problem
> Problem: Optional dependency, module "castxml" failed
This may reduce the functionality of the final build.
However, bake will continue since "castxml" is not an essential dependency.
For more information call bake with -v or -vvv, for full verbose mode.
ํ์ง๋ง ์บ์คํธxml ์ ๋ฐ์ดํธ๋ Python ๋ฐ์ธ๋ฉ์ ์์ฑํ๋ ค๋ ๊ฒฝ์ฐ์๋ง ํ์ํฉ๋๋ค. ๋๋ถ๋ถ์ ์ฌ์ฉ์์๊ฒ๋ ์ด ์์ ์ด ํ์ํ์ง ์์ผ๋ฏ๋ก(์ ์ด๋ ns-3์ ๋ณ๊ฒฝํ ๋๊น์ง๋) ํ์ฌ๋ก์๋ ๊ทธ๋ฌํ ๊ฒฝ๊ณ ๋ฅผ ๋ฌด์ํด๋ ๋ฉ๋๋ค.
์คํจํ ๊ฒฝ์ฐ ๋ค์ ๋ช ๋ น์ ๋๋ฝ๋ ์ข ์์ฑ์ ๋ํ ํํธ๋ฅผ ์ ๊ณตํฉ๋๋ค.
$ ./bake.py show
๋น๋ํ๋ ค๋ ํจํค์ง์ ๋ค์ํ ์ข ์์ฑ์ด ๋์ด๋ฉ๋๋ค.
3.4.3 Waf๋ก ๊ตฌ์ถ
์ง๊ธ๊น์ง ns-3 ๊ตฌ์ถ์ ์์ํ๊ธฐ ์ํด ์ฐ๋ฆฌ๋ ๋ค์ ์ค ํ๋์ ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํ์ต๋๋ค. build.py, ๋๋ ๋๊ตฌ ๊ตฝโโ๋ค. ์ด๋ฌํ ๋๊ตฌ๋ ns-3์ ๊ตฌ์ถํ๊ณ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ ์งํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค. ์ค์ ๋ก ๋น๋ํ๊ธฐ ์ํด ๋น๋ ๋๊ตฌ๋ฅผ ์คํํฉ๋๋ค. ์ํ ns-3 ๋๋ ํ ๋ฆฌ์์. ์ํ ns-3 ์์ค ์ฝ๋์ ํจ๊ป ์ค์น๋ฉ๋๋ค. ๋๋ถ๋ถ์ ์ฌ์ฉ์๋ nsโ3๋ฅผ ๊ตฌ์ฑํ๊ณ ์กฐ๋ฆฝํ๋ ๋ฐ ๋น ๋ฅด๊ฒ ์ง์ ์ฌ์ฉํ๊ฒ ๋ฉ๋๋ค. ์ํ. ๊ณ์ํ๋ ค๋ฉด ์๋ ์์ฑํ ns-3 ๋๋ ํฐ๋ฆฌ๋ก ์ด๋ํ์ธ์.
ํ์ฌ๋ก์๋ ์ด๊ฒ์ด ๊ผญ ํ์ํ ๊ฒ์ ์๋์ง๋ง, ์กฐ๊ธ ๋๋์๊ฐ์ ํ๋ก์ ํธ ๊ตฌ์ฑ์ ๋ณ๊ฒฝํ๋ ๋ฐฉ๋ฒ์ ์์๋ณด๋ ๊ฒ์ด ์ ์ฉํ ๊ฒ์ ๋๋ค. ์๋ง๋ ๊ฐ์ฅ ์ ์ฉํ ๊ตฌ์ฑ ๋ณ๊ฒฝ์ ์ฝ๋์ ์ต์ ํ๋ ๋ฒ์ ์ ๋ง๋๋ ๊ฒ์ผ ๊ฒ์ ๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ๋๋ฒ๊ทธ ๋ฒ์ ์ ๋น๋ํ๋๋ก ํ๋ก์ ํธ๋ฅผ ๊ตฌ์ฑํ์ต๋๋ค. ์ต์ ํ๋ ๋น๋๋ฅผ ์์ฑํ๊ธฐ ์ํ ํ๋ก์ ํธ๋ฅผ ์ดํด๋ณด๊ฒ ์ต๋๋ค. ์์ ์ ํ ์คํธ๋ฅผ ํฌํจํ๋ ์ต์ ํ๋ ๋น๋๋ฅผ ๋ง๋ค์ด์ผ ํจ์ Waf์ ์ค๋ช ํ๋ ค๋ฉด ๋ค์ ๋ช ๋ น์ ์คํํด์ผ ํฉ๋๋ค.
$ ./waf clean
$ ./waf configure --build-profile=optimized --enable-examples --enable-tests
์์๋ฉ๋๋ค ์ํ (๊ทํ์ ํธ์๋ฅผ ์ํด) ๋ก์ปฌ ๋๋ ํ ๋ฆฌ ์ธ๋ถ์ ์์ต๋๋ค. ์ฒซ ๋ฒ์งธ ๋ช ๋ น์ ์ด์ ๋น๋์์ ์ ๋ฆฌํฉ๋๋ค. ์ด๋ ์ผ๋ฐ์ ์ผ๋ก ๊ผญ ํ์ํ ๊ฒ์ ์๋์ง๋ง ์ข์ ์ต๊ด์ ๋๋ค(์๋ ๋น๋ ํ๋กํ๋ ์ฐธ์กฐ). ์ด๋ ๊ฒ ํ๋ฉด ์ด์ ์ ์์ฑ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๋๋ ํฐ๋ฆฌ์ ์๋ ๊ฐ์ฒด ํ์ผ์ด ์ญ์ ๋ฉ๋๋ค. ์ง๋ค/. ํ๋ก์ ํธ๊ฐ ์ฌ๊ตฌ์ฑ๋๊ณ ๋น๋ ์์คํ ์ด ๋ค์ํ ์ข ์์ฑ์ ํ์ธํ๋ฉด ๋ค์๊ณผ ์ ์ฌํ ์ถ๋ ฅ์ด ํ์๋ฉ๋๋ค.
Setting top to : /home/ns3user/workspace/bake/source/ns-3-dev
Setting out to : /home/ns3user/workspace/bake/source/ns-3-dev/build
Checking for 'gcc' (C compiler) : /usr/bin/gcc
Checking for cc version : 7.3.0
Checking for 'g++' (C++ compiler) : /usr/bin/g++
Checking for compilation flag -march=native support : ok
Checking for compilation flag -Wl,--soname=foo support : ok
Checking for compilation flag -std=c++11 support : ok
Checking boost includes : headers not found, please ,!provide a --boost-includes argument (see help)
Checking boost includes : headers not found, please ,!provide a --boost-includes argument (see help)
Checking for program 'python' : /usr/bin/python
Checking for python version >= 2.3 : 2.7.15 python-config : /usr/bin/python-config
Asking python-config for pyembed '--cflags --libs --ldflags' flags : yes
Testing pyembed configuration : yes
Asking python-config for pyext '--cflags --libs --ldflags' flags : yes
Testing pyext configuration : yes
Checking for compilation flag -fvisibility=hidden support : ok
Checking for compilation flag -Wno-array-bounds support : ok
Checking for pybindgen location : ../pybindgen ,!(guessed)
Checking for python module 'pybindgen' : 0.19.0. ,!post4+g823d8b2
Checking for pybindgen version : 0.19.0. ,!post4+g823d8b2
Checking for code snippet : yes
Checking for types uint64_t and unsigned long equivalence : no
Checking for code snippet : no
Checking for types uint64_t and unsigned long long equivalence : yes
Checking for the apidefs that can be used for Python bindings : gcc-LP64
Checking for internal GCC cxxabi : complete
Checking for python module 'pygccxml' : not found
Checking for click location : not found
Checking for program 'pkg-config' : /usr/bin/pkg- ,!config
Checking for 'gtk+-3.0' : not found
Checking for 'libxml-2.0' : yes
checking for uint128_t : not found
checking for __uint128_t : yes
Checking high precision implementation : 128-bit integer ,!(default)
Checking for header stdint.h : yes
Checking for header inttypes.h : yes
Checking for header sys/inttypes.h : not found
Checking for header sys/types.h : yes
Checking for header sys/stat.h : yes
Checking for header dirent.h : yes
Checking for header stdlib.h : yes
Checking for header signal.h : yes
Checking for header pthread.h : yes
Checking for header stdint.h : yes
Checking for header inttypes.h : yes
Checking for header sys/inttypes.h : not found
Checking for library rt : yes
Checking for header sys/ioctl.h : yes
Checking for header net/if.h : yes
Checking for header net/ethernet.h : yes
Checking for header linux/if_tun.h : yes
Checking for header netpacket/packet.h : yes
Checking for NSC location : not found
Checking for 'sqlite3' : not found
Checking for header linux/if_tun.h : yes
Checking for python module 'gi' : 3.26.1
Checking for python module 'gi.repository.GObject' : ok
Checking for python module 'cairo' : ok
Checking for python module 'pygraphviz' : 1.4rc1
Checking for python module 'gi.repository.Gtk' : ok
Checking for python module 'gi.repository.Gdk' : ok
Checking for python module 'gi.repository.Pango' : ok
Checking for python module 'gi.repository.GooCanvas' : ok
Checking for program 'sudo' : /usr/bin/sudo
Checking for program 'valgrind' : not found
Checking for 'gsl' : not found python-config : not found
Checking for compilation flag -fstrict-aliasing support : ok
Checking for compilation flag -fstrict-aliasing support : ok
Checking for compilation flag -Wstrict-aliasing support : ok
Checking for compilation flag -Wstrict-aliasing support : ok
Checking for program 'doxygen' : /usr/bin/doxygen
---- Summary of optional ns-3 features:
Build profile : optimized
Build directory :
BRITE Integration : not enabled (BRITE not enabled (see option --with- ,!brite))
DES Metrics event collection : not enabled (defaults to disabled)
Emulation FdNetDevice : enabled
Examples : enabled
File descriptor NetDevice : enabled
GNU Scientific Library (GSL) : not enabled (GSL not found)
Gcrypt library : not enabled
(libgcrypt not found: you can use ,!libgcrypt-config to find its location.) GtkConfigStore : not enabled (library 'gtk+-3.0 >= 3.0' not fou nd)
MPI Support : not enabled (option --enable-mpi not selected)
ns-3 Click Integration : not enabled (nsclick not enabled (see option --with- ,!nsclick))
ns-3 OpenFlow Integration : not enabled (Required boost libraries not found)
Network Simulation Cradle : not enabled (NSC not found (see option --with-nsc))
PlanetLab FdNetDevice : not enabled (PlanetLab operating system not detected ,!(see option --force-planetlab)) PyViz visualizer : enabled
Python API Scanning Support : not enabled (Missing 'pygccxml' Python module)
Python Bindings : enabled
Real Time Simulator : enabled
SQlite stats data output : not enabled (library 'sqlite3' not found)
Tap Bridge : enabled
Tap FdNetDevice : enabled
Tests : enabled
Threading Primitives : enabled
Use sudo to set suid bit : not enabled (option --enable-sudo not selected)
XmlIo : enabled
'configure' finished successfully (6.387s)
์ ๋ชฉ๋ก์ ๋ง์ง๋ง ๋ถ๋ถ์ ์ฐธ๊ณ ํ์ธ์. ์ผ๋ถ ns-3 ์ต์
์ ๊ธฐ๋ณธ์ ์ผ๋ก ํ์ฑํ๋์ด ์์ง ์๊ฑฐ๋ ์ ๋๋ก ์๋ํ๋ ค๋ฉด ์์คํ
์ง์์ด ํ์ํฉ๋๋ค. ์๋ฅผ ๋ค์ด XmlTo๋ฅผ ํ์ฑํํ๋ ค๋ฉด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์์คํ
์ ์์ด์ผ ํฉ๋๋ค. libxml-2.0. ์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฐพ์ ์ ์๊ณ ํด๋น ns-3 ๊ธฐ๋ฅ์ด ํ์ฑํ๋์ง ์์ ๊ฒฝ์ฐ ๋ฉ์์ง๊ฐ ํ์๋ฉ๋๋ค. ๋ํ ๋ช
๋ น์ ์ฌ์ฉํ ์ ์์ต๋๋ค. sudo๋ ํน์ ํ๋ก๊ทธ๋จ์ ๋ํด suid ๋นํธ "๋ฐํ์์ ๊ทธ๋ฃน ID ์ค์ "์ ์ค์ ํฉ๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ํ์ฑํ๋์ด ์์ง ์์ผ๋ฏ๋ก ์ด ๊ธฐ๋ฅ์ "ํ์ฑํ๋์ง ์์"์ผ๋ก ํ์๋ฉ๋๋ค. ๋ง์ง๋ง์ผ๋ก ํ์ฑํ๋ ์ต์
๋ชฉ๋ก์ ์ป์ผ๋ ค๋ฉด ๋ค์์ ์ฌ์ฉํ์ธ์. ์ํ ๋งค๊ฐ๋ณ์ ํฌํจ --check-config
.
์ด์ ์์ ์ ํ ์คํธ๊ฐ ํฌํจ๋ ๋๋ฒ๊ทธ ๋น๋๋ก ๋ค์ ์ ํํด ๋ณด๊ฒ ์ต๋๋ค.
$ ./waf clean
$ ./waf configure --build-profile=debug --enable-examples --enable-tests
์ด์ ๋น๋ ์์คํ ์ด ์ค์ ๋์์ผ๋ฉฐ ๋ค์์ ์ ๋ ฅํ๊ธฐ๋ง ํ๋ฉด ns-3 ํ๋ก๊ทธ๋จ์ ๋๋ฒ๊ทธ ๋ฒ์ ์ ๋น๋ํ ์ ์์ต๋๋ค.
$ ./waf
์์ ๋จ๊ณ๋ก ์ธํด ns-3 ์์คํ ์ ์ผ๋ถ๋ฅผ ๋ ๋ฒ ๋น๋ํด์ผ ํ์ ์๋ ์์ง๋ง ์ด์ ๊ตฌ์ฑ์ ๋ณ๊ฒฝํ๊ณ ์ต์ ํ๋ ์ฝ๋๋ฅผ ๋น๋ํ๋ ๋ฐฉ๋ฒ์ ์๊ฒ ๋์์ต๋๋ค.
ํน์ ํ๋ก์ ํธ ๊ตฌ์ฑ์ ๋ํด ์ด๋ค ํ๋กํ์ด ํ์ฑํ๋์ด ์๋์ง ํ์ธํ๋ ค๋ฉด ๋ค์ ๋ช ๋ น์ด ์์ต๋๋ค.
$ ./waf --check-profile
Waf: Entering directory `/path/to/ns-3-allinone/ns-3.29/build'
Build profile: debug
์์ ์๋๋ฆฌ์ค build.py ์ธ์๋ ์ง์ํฉ๋๋ค --enable-examples
ะธ --enable-tests
, ๊ทธ๋ฌ๋ ๋ค๋ฅธ ์ต์
์ํ ์ง์ ์ ์ผ๋ก ์ง์ํ์ง๋ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด ๋ค์์ ์๋ํ์ง ์์ต๋๋ค.
$ ./build.py --disable-python
๋ฐ์์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
build.py: error: no such option: --disable-python
๊ทธ๋ฌ๋ ํน์ ์ฐ์ฐ์ - -๋ฅผ ์ฌ์ฉํ๋ฉด ๋ค์์ ํตํด ์ถ๊ฐ ๋งค๊ฐ๋ณ์๋ฅผ ์ ๋ฌํ ์ ์์ต๋๋ค. waf๋ฐ๋ผ์ ์์ ๋ช ๋ น ๋์ ๋ค์ ๋ช ๋ น์ด ์๋ํฉ๋๋ค.
$ ./build.py -- --disable-python
๊ธฐ๋ณธ ๋ช ๋ น์ ์์ฑํ๊ธฐ ๋๋ฌธ์ ./waf ๊ตฌ์ฑ --disable-python. ์ฌ๊ธฐ์ ๋ํ ๋ช ๊ฐ์ง ์ถ๊ฐ ์๊ฐ ํ์ด ์์ต๋๋ค. ์ํ.
๋น๋ ์ค๋ฅ ์ฒ๋ฆฌ
ns-3 ๋ฆด๋ฆฌ์ค๋ ์ผ๋ฐ์ ์ธ Linux ๋ฐ MacOS ๋ฐฐํฌํ์์ ๋ฆด๋ฆฌ์ค ๋น์ ์ฌ์ฉ ๊ฐ๋ฅํ ์ต์ C++ ์ปดํ์ผ๋ฌ์์ ํ ์คํธ๋์์ต๋๋ค. ๊ทธ๋ฌ๋ ์๊ฐ์ด ์ง๋จ์ ๋ฐ๋ผ ์๋ก์ด ์ปดํ์ผ๋ฌ์ ํจ๊ป ์๋ก์ด ๋ฐฐํฌํ์ด ์ถ์๋๋ฉฐ ์ด๋ฌํ ์ต์ ์ปดํ์ผ๋ฌ๋ ๊ฒฝ๊ณ ์ ๋ํด ๋์ฑ ํํ์ ์ธ ๊ฒฝํฅ์ด ์์ต๋๋ค. ns-3์ ๋ชจ๋ ๊ฒฝ๊ณ ๋ฅผ ์ค๋ฅ๋ก ์ฒ๋ฆฌํ๋๋ก ๋น๋๋ฅผ ๊ตฌ์ฑํ๋ฏ๋ก ๋๋ก๋ ์ต์ ์์คํ ์์ ์ด์ ๋ฒ์ ์ ์คํํ๋ ๊ฒฝ์ฐ ์ปดํ์ผ๋ฌ ๊ฒฝ๊ณ ๋ก ์ธํด ๋น๋๊ฐ ์ค์ง๋ ์ ์์ต๋๋ค.
์๋ฅผ ๋ค์ด, ์ด์ ์ ์๋ก์ด ์ฃผ์ ๋ฒ์ ์ด ํฌํจ๋ Fedora 3.28์ฉ nsโ28 ๋ฆด๋ฆฌ์ค๊ฐ ์์์ต๋๋ค. GCC (gcc-8). Gtk3.28+๊ฐ ์ค์น๋ Fedora 28์์ ๋ฆด๋ฆฌ์ค ns-2 ๋๋ ์ด์ ๋ฒ์ ์ ๋น๋ํ๋ฉด ๋ค์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
/usr/include/gtk-2.0/gtk/gtkfilechooserbutton.h:59:8: error: unnecessary parentheses ,!in declaration of โ__gtk_reserved1โ [-Werror=parentheses] void (*__gtk_reserved1);
nsโ3.28.1๋ถํฐ ์์ํ๋ ๋ฆด๋ฆฌ์ค์์๋ ์ํ ์ด๋ฌํ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํ ์ต์ ์ด ์์ต๋๋ค. g++ ๋ฐ clang++์์ "-Werror" ํ๋๊ทธ ์ค์ ์ ๋นํ์ฑํํฉ๋๋ค. ์ด๋ "--disable-werror" ์ต์ ์ด๋ฉฐ ๊ตฌ์ฑ ์ค์ ์ ์ฉํด์ผ ํฉ๋๋ค.
$ ./waf configure --disable-werror --enable-examples --enable-tests
๊ตฌ์ฑ ๋๋ ์กฐ๋ฆฝ
์ผ๋ถ ๋ช ๋ น ์ํ ๊ตฌ์ฑ ๋จ๊ณ์์๋ง ์๋ฏธ๊ฐ ์์ผ๋ฉฐ ์ผ๋ถ๋ ๋น๋ ๋จ๊ณ์์๋ง ์ ํจํฉ๋๋ค. ์๋ฅผ ๋ค์ด, ns-3 ์๋ฎฌ๋ ์ด์ ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ ค๋ฉด ๋นํธ ์ค์ ์ ํ์ฑํํ๋ฉด ๋ฉ๋๋ค. SUID ์ฌ์ฉ sudo๋, ์์์ ์ค๋ช ํ๋๋ก. ์ด๋ ๊ตฌ์ฑ ๋จ๊ณ ๋ช ๋ น์ ์ฌ์ ์ํ๋ฏ๋ก ์์ ์ ํ ์คํธ๋ ํฌํจ๋ ๋ค์ ๋ช ๋ น์ ์ฌ์ฉํ์ฌ ๊ตฌ์ฑ์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค.
$ ./waf configure --enable-sudo --enable-examples --enable-tests
์ด๋ ๊ฒ ํ๋ฉด ์ํ ์์ํ ๊ฒ์ด๋ค sudo๋๊ถํ์ผ๋ก ์คํ๋๋๋ก ์๋ฎฌ๋ ์ด์ ์ฝ๋ ์์ผ ์์ฑ ํ๋ก๊ทธ๋จ์ ๋ณ๊ฒฝํ๋ ค๋ฉด ๋ฟ๋ฆฌ. ์ ์ํ ๊ตฌ์ฑ ๋ฐ ๋น๋ ๋จ๊ณ์ ์ฌ์ฉํ ์ ์๋ ๋ค๋ฅธ ์ต์ ์ด ๋ง์ด ์์ต๋๋ค. ์ต์ ์ ์ดํด๋ณด๋ ค๋ฉด ๋ค์์ ์ ๋ ฅํ์ธ์.
$ ./waf --help
๋ค์ ์น์ ์์๋ ๋ช ๊ฐ์ง ํ ์คํธ ๊ด๋ จ ์ต์ ์ ์ฌ์ฉํ๊ฒ ์ต๋๋ค.
์ด์ ๋ธ๋ฆฌ ํ๋กํ์ผ
์ฐ๋ฆฌ๋ ์ด๋ฏธ ๊ตฌ์ฑ ๋ฐฉ๋ฒ์ ์ดํด๋ณด์์ต๋๋ค. ์ํ ์ด์ ๋ธ๋ฆฌ์ฉ ๋๋ฒ๊ทธ ะธ ์ต์ ํ:
$ ./waf --build-profile=debug
์ค๊ฐ ์กฐ๋ฆฝ ํ๋กํ์ผ๋ ์๊ณ , ๊ณต๊ฐ. ์ต์
-d
์ ๋์์ด์
๋๋ค --build-profile
. ๋น๋ ํ๋กํ์ ๋ก๊น
, ์ด์ค์
๋ฐ ์ปดํ์ผ๋ฌ ์ต์ ํ ์ค์์น์ ์ฌ์ฉ์ ์ ์ดํฉ๋๋ค.
๋ณด์๋ค์ํผ ๋ก๊น ๋ฐ ์ด์ค์ ์ ๋๋ฒ๊ทธ ๋น๋์์๋ง ์ฌ์ฉํ ์ ์์ต๋๋ค. ๊ถ์ฅ๋๋ ๋ฐฉ๋ฒ์ ๋๋ฒ๊ทธ ๋ชจ๋์์ ์คํฌ๋ฆฝํธ๋ฅผ ๊ฐ๋ฐํ ๋ค์ ์ต์ ํ๋ ๋น๋ ํ๋กํ์์ ๋ฐ๋ณต ์คํ(ํต๊ณ ๋๋ ๋งค๊ฐ๋ณ์ ๋ณ๊ฒฝ์ ์ํด)์ ์ํํ๋ ๊ฒ์ ๋๋ค.
ํน์ ๋น๋ ํ๋กํ์์๋ง ์คํํด์ผ ํ๋ ์ฝ๋๊ฐ ์๋ ๊ฒฝ์ฐ ์ฝ๋ ๋ํผ ๋งคํฌ๋ก๋ฅผ ์ฌ์ฉํ์ธ์.
NS_BUILD_DEBUG (std::cout << "Part of an output line..." << std::flush; timer.Start ,!()); DoLongInvolvedComputation ();
NS_BUILD_DEBUG (timer.Stop (); std::cout << "Done: " << timer << std::endl;)
๊ธฐ๋ณธ, ์ํ ๋น๋ ๋๋ ํ ๋ฆฌ์ ๋น๋ ์ํฐํฉํธ๋ฅผ ๋ฐฐ์นํฉ๋๋ค. ์ต์
์ ์ฌ์ฉํ์ฌ ๋ค๋ฅธ ์ถ๋ ฅ ๋๋ ํฐ๋ฆฌ๋ฅผ ์ง์ ํ ์ ์์ต๋๋ค. -โฏ-out
์ :
$ ./waf configure --out=my-build-dir
์ด๋ฅผ ๋น๋ ํ๋กํ๊ณผ ๊ฒฐํฉํ๋ฉด ๋ค์ํ ์ปดํ์ผ ์ต์ ๊ฐ์ ์ฝ๊ฒ ์ ํํ ์ ์์ต๋๋ค.
$ ./waf configure --build-profile=debug --out=build/debug
$ ./waf build
...
$ ./waf configure --build-profile=optimized --out=build/optimized
$ ./waf build
...
์ด๋ฅผ ํตํด ๋งค๋ฒ ์ต์ ์ด์ ๋ธ๋ฆฌ๋ฅผ ๋ค์ ์์ฑํ ํ์ ์์ด ์ฌ๋ฌ ์ด์ ๋ธ๋ฆฌ๋ก ์์ ํ ์ ์์ต๋๋ค. ๋ค๋ฅธ ํ๋กํ๋ก ์ ํํ๋ฉด ์ํ ๋ชจ๋ ๊ฒ์ ์์ ํ ๋ค์ ์ปดํ์ผํ์ง ์๊ณ ๊ทธ๊ฒ๋ง ์ปดํ์ผํฉ๋๋ค.
์ด๋ฌํ ๋ฐฉ์์ผ๋ก ๋น๋ ํ๋กํ์ ์ ํํ๋ ๊ฒฝ์ฐ ๋งค๋ฒ ๋์ผํ ๊ตฌ์ฑ ์ต์ ์ ์ ๊ณตํ๋๋ก ์ฃผ์ํด์ผ ํฉ๋๋ค. ์ฌ๋ฌ ํ๊ฒฝ ๋ณ์๋ฅผ ์ ์ํ๋ฉด ์ค์๋ฅผ ๋ฐฉ์งํ๋ ๋ฐ ๋์์ด ๋ฉ๋๋ค.
$ export NS3CONFIG="--enable-examples --enable-tests"
$ export NS3DEBUG="--build-profile=debug --out=build/debug"
$ export NS3OPT=="--build-profile=optimized --out=build/optimized"
$ ./waf configure $NS3CONFIG $NS3DEBUG
$ ./waf build
...
$ ./waf configure $NS3CONFIG $NS3OPT
$ ./waf build
์ปดํ์ผ๋ฌ ๋ฐ ํ๋๊ทธ
์์ ์์์๋ ์ํ ns-3์ ๋น๋ํ๋ ค๋ฉด GCC์ C++ ์ปดํ์ผ๋ฌ๋ฅผ ์ฌ์ฉํฉ๋๋ค( g ++). ๊ทธ๋ฌ๋ ์ฌ์ฉํ๋ ๊ฒ์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค ์ํ C++ ์ปดํ์ผ๋ฌ(CXX ํ๊ฒฝ ๋ณ์ ์ ์) ์๋ฅผ ๋ค์ด C++ ์ปดํ์ผ๋ฌ Clang, clang++,
$ CXX="clang++" ./waf configure
$ ./waf build
๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ๊ตฌ์ฑํ ์ ์์ต๋๋ค. ์ํ ๋ค์์ ์ฌ์ฉํ์ฌ ๋ถ์ฐ ์ปดํ์ผ์ ์ฌ์ฉํ๋ ค๋ฉด distcc:
$ CXX="distcc g++" ./waf configure
$ ./waf build
distcc ๋ฐ ๋ถ์ฐ ์ปดํ์ผ์ ๋ํ ์์ธํ ๋ด์ฉ์ ๋ฌธ์ ์น์ ์ ํ๋ก์ ํธ ํ์ด์ง์์ ํ์ธํ ์ ์์ต๋๋ค. ns-3์ ๊ตฌ์ฑํ ๋ ์ปดํ์ผ๋ฌ ํ๋๊ทธ๋ฅผ ์ถ๊ฐํ๋ ค๋ฉด CXXFLAGS_EXTRA ํ๊ฒฝ ๋ณ์๋ฅผ ์ฌ์ฉํ์ญ์์ค.
์ค์น
์ํ ์์คํ ์ ๋ค๋ฅธ ์์น์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ค์นํ๋ ๋ฐ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ์ปดํ์ผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์คํ ํ์ผ์ ๋๋ ํฐ๋ฆฌ์ ์์ต๋๋ค. ๋น๋, Waf๋ ์ด๋ฌํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์คํ ํ์ผ์ ์์น๋ฅผ โโ์๊ณ ์์ผ๋ฏ๋ก ๋ค๋ฅธ ๊ณณ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ค์นํ ํ์๊ฐ ์์ต๋๋ค.
์ฌ์ฉ์๊ฐ ๋น๋ ๋๋ ํฐ๋ฆฌ ์ธ๋ถ์ ์ค์นํ๋ ค๋ ๊ฒฝ์ฐ ๋ค์ ๋ช
๋ น์ ์คํํ ์ ์์ต๋๋ค. ./waf ์ค์น. ์ค์น๋ฅผ ์ํ ๊ธฐ๋ณธ ์ ๋์ฌ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. / usr / local๊ทธ๋์ ./waf ์ค์น ํ๋ก๊ทธ๋จ์ ์ค์นํ ๊ฒ์
๋๋ค / usr / local / bin, ๋์๊ด / usr / local / lib ๋ฐ ํค๋ ํ์ผ /usr/๋ก์ปฌ/ํฌํจ. ์ํผ์ ์ ๊ถํ์ ์ผ๋ฐ์ ์ผ๋ก ๊ธฐ๋ณธ ์ ๋์ฌ๋ฅผ ์ฌ์ฉํ์ฌ ์ค์ ํด์ผ ํ๋ฏ๋ก ์ผ๋ฐ์ ์ธ ๋ช
๋ น์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. sudo ./waf ์ค์น. Waf๋ ์์๋๋ฉด ๋จผ์ ๋น๋ ๋๋ ํฐ๋ฆฌ์ ๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋๋ก ์ ํํ ๋ค์ ๋ก์ปฌ ํ๊ฒฝ์ ๊ตฌ์ฑ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๊ฒฝ๋ก๋ฅผ ๋ฐ๋ผ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฐพ์ต๋๋ค. ๋ฐ๋ผ์ ์์คํ
์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ค์นํ ๋ ์ฌ๋ฐ๋ฅธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ์ฌ์ฉ๋๊ณ ์๋์ง ํ์ธํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ฌ์ฉ์๋ ๊ตฌ์ฑ ์ค์ ์ต์
์ ์ ๋ฌํ์ฌ ๋ค๋ฅธ ์ ๋์ฌ๋ก ์ค์นํ๋๋ก ์ ํํ ์ ์์ต๋๋ค. --prefix
์ :
./waf configure --prefix=/opt/local
๋์ค์ ๋น๋ ํ ์ฌ์ฉ์๊ฐ ์ค์น ๋ช
๋ น์ ์
๋ ฅํ๋ ๊ฒฝ์ฐ ./waf
, ์ ๋์ฌ๊ฐ ์ฌ์ฉ๋ฉ๋๋ค /์ ํ/๋ก์ปฌ.
ํ ./waf clean
์ค์น์์ ์ฌ์ฉํ ๊ฒฝ์ฐ ํ๋ก์ ํธ๋ฅผ ์ฌ๊ตฌ์ฑํ๊ธฐ ์ ์ ์ฌ์ฉํด์ผ ํฉ๋๋ค. ์ํ ๋ค๋ฅธ ์ ๋์ฌ๋ก.
๋ฐ๋ผ์ ns-3์ ์ฌ์ฉํ๊ธฐ ์ํด ํธ์ถํ ํ์๊ฐ ์์ต๋๋ค. ./waf install
. ๋๋ถ๋ถ์ ์ฌ์ฉ์์๊ฒ๋ ์ด ๋ช
๋ น์ด ํ์ํ์ง ์์ต๋๋ค. ์ํ ๋ ๋น๋ ๋๋ ํ ๋ฆฌ์์ ํ์ฌ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ ํํ์ง๋ง ์ผ๋ถ ์ฌ์ฉ์๋ ํ๋์ด ns-3 ๋๋ ํ ๋ฆฌ ์ธ๋ถ์ ํ๋ก๊ทธ๋จ ์์
๊ณผ ๊ด๋ จ๋ ๊ฒฝ์ฐ ์ด ๊ธฐ๋ฅ์ด ์ ์ฉํ ์ ์์ต๋๋ค.
์ํ ์ฑ๊ธ
ns-3 ์์ค ํธ๋ฆฌ์ ์ต์์ ์์ค์๋ Waf ์คํฌ๋ฆฝํธ๊ฐ ํ๋๋ง ์์ต๋๋ค. ์ผ๋จ ์์
์ ์์ํ๋ฉด ๋๋ ํ ๋ฆฌ์์ ๋ง์ ์๊ฐ์ ๋ณด๋ด๊ฒ ๋ฉ๋๋ค. scratch/
์๋๋ฉด ๋ ๊น๊ฒsrc/...
๋์์ ๋ฌ๋ ค์ผ ํ๋ค ์ํ. ์์ ์ด ์ด๋์ ์๋์ง ๊ธฐ์ตํ๊ณ ๋ฌ๋ ค๊ฐ๋ฉด ๋ฉ๋๋ค. ์ํ ๋ค์๊ณผ ๊ฐ์ด
$ ../../../waf ...
ํ์ง๋ง ์ด๋ ์ง๋ฃจํ๊ณ ์ค๋ฅ๊ฐ ๋ฐ์ํ๊ธฐ ์ฌ์ฐ๋ฏ๋ก ๋ ๋์ ์๋ฃจ์ ์ด ์์ต๋๋ค. ์ผ๋ฐ์ ์ธ ๋ฐฉ๋ฒ ์ค ํ๋๋ ๋ค์๊ณผ ๊ฐ์ ํ ์คํธ ํธ์ง๊ธฐ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค. ์ด๋งฅ์ค ๋๋ ์ ๋ ฅ, ๋ ๊ฐ์ ํฐ๋ฏธ๋ ์ธ์ ์ด ์ด๋ ค ์๋๋ฐ, ํ๋๋ ns-3์ ๋น๋ํ๋ ๋ฐ ์ฌ์ฉ๋๊ณ ๋ ๋ฒ์งธ๋ ์์ค ์ฝ๋๋ฅผ ํธ์งํ๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ๋น์ ์ด ๊ฐ์ง๊ณ ์๋ค๋ฉด ํ๋ฅด๋ณผ, ํ๊ฒฝ ๋ณ์๊ฐ ๋์์ด ๋ ์ ์์ต๋๋ค.
$ export NS3DIR="$PWD"
$ function waff { cd $NS3DIR && ./waf $* ; }
$ cd scratch
$ waff build
๋ชจ๋ ๋๋ ํ ๋ฆฌ์ ๋ค์๊ณผ ๊ฐ์ ๊ฐ๋จํ waf ์คํฌ๋ฆฝํธ๋ฅผ ์ถ๊ฐํ๊ณ ์ถ์ ์๋ ์์ต๋๋ค. exec ../../waf
. ํ์ง ๋ง์ธ์. ์ด๋ ์ด๋ณด์์๊ฒ๋ ํผ๋์ค๋ฝ๊ณ ์ ๋๋ก ์ํ๋์ง ์์ผ๋ฉด ๊ฐ์งํ๊ธฐ ์ด๋ ค์ด ๋น๋ ์ค๋ฅ๋ก ์ด์ด์ง๋๋ค. ์์ ํ์๋ ์๋ฃจ์
์ ์ฌ์ฉํด์ผ ํ๋ ๊ฒฝ๋ก์
๋๋ค.
3.5 ns-3 ํ ์คํธ
์คํฌ๋ฆฝํธ๋ฅผ ์คํํ์ฌ ns-3 ๋ฐฐํฌํ์ ๋จ์ ํ ์คํธ๋ฅผ ์คํํ ์ ์์ต๋๋ค. ./test.py:
$ ./test.py
์ด๋ฌํ ํ ์คํธ๋ ๋ค์๊ณผ ๋์์ ์คํ๋ฉ๋๋ค. ์ํ. ๊ฒฐ๊ตญ ๋ค์๊ณผ ๊ฐ์ ๋ฉ์์ง๊ฐ ํ์๋ฉ๋๋ค.
92 of 92 tests passed (92 passed, 0 failed, 0 crashed, 0 valgrind errors)
์ด๋ valgrind ์ถฉ๋, ์ถฉ๋ ๋๋ ์ค๋ฅ๋ฅผ ์๋ณํ๊ณ ์ฝ๋ ๋ฌธ์ ๋๋ ๋๊ตฌ์ ์ฝ๋ ๊ฐ์ ๋นํธํ์ฑ์ ๋ํ๋ด๋ ์ค์ํ ๋ฉ์์ง์ ๋๋ค.
๋ํ ๋ค์์ ์ต์ข ์ถ๋ ฅ๋ ๋ณผ ์ ์์ต๋๋ค. ์ํ ๊ฐ ํ ์คํธ๋ฅผ ์คํํ๋ ํ ์คํฐ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
Waf: Entering directory `/path/to/workspace/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/path/to/workspace/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (1.799s)
Modules built:
aodv applications bridge
click config-store core
csma csma-layout dsdv
emu energy flow-monitor
internet lte mesh
mobility mpi netanim
network nix-vector-routing ns3tcp
ns3wifi olsr openflow
point-to-point point-to-point-layout propagation
spectrum stats tap-bridge
template test tools
topology-read uan virtual-net-device
visualizer wifi wimax
PASS: TestSuite ns3-wifi-interference
PASS: TestSuite histogram
...
PASS: TestSuite object
PASS: TestSuite random-number-generators
92 of 92 tests passed (92 passed, 0 failed, 0 crashed, 0 valgrind errors)
์ด ๋ช ๋ น์ ์ผ๋ฐ์ ์ผ๋ก ์ฌ์ฉ์๊ฐ ns-3 ๋ฐฐํฌํ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๋น๋๋์๋์ง ์ ์ํ๊ฒ ํ์ธํ๊ธฐ ์ํด ์คํ๋ฉ๋๋ค. ("PASS: ..." ์ค์ ์์๋ ๋ค๋ฅผ ์ ์์ง๋ง ์ด๋ ์ ์์ ๋๋ค. ์ค์ํ ๊ฒ์ ๋ณด๊ณ ์ ๋์ ์์ฝ ์ค์ ๋ชจ๋ ํ ์คํธ๊ฐ ํต๊ณผํ์์ ํ์ํ๋ค๋ ๊ฒ์ ๋๋ค. ์ด๋ค ํ ์คํธ๋ ์คํจํ๊ฑฐ๋ ์ถฉ๋ํ์ง ์์์ต๋๋ค.) ๊ทธ๋ฆฌ๊ณ ์ํ๊ณผ test.py ์์คํ ์ ์ฌ์ฉ ๊ฐ๋ฅํ ํ๋ก์ธ์ ์ฝ์ด ์ ์ฒด์์ ์์ ์ ๋ณ๋ ฌํํฉ๋๋ค.
3.6 ์คํฌ๋ฆฝํธ ์คํ
์ฐ๋ฆฌ๋ ์ผ๋ฐ์ ์ผ๋ก ํต์ ํ์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํฉ๋๋ค. ์ํ. ์ด๋ฅผ ํตํด ๋น๋ ์์คํ
์ ๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ฒฝ๋ก๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ์ค์ ๋์๋์ง, ๋ฐํ์ ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ ์ ์๋์ง ํ์ธํ ์ ์์ต๋๋ค. ํ๋ก๊ทธ๋จ์ ์คํํ๋ ค๋ฉด ๋ค์์ ์ฌ์ฉํ์ญ์์ค. ์ํ ๋งค๊ฐ๋ณ์ ํฌํจ -โฏ-run
. ์ ๋น์ฟผํฐ์ค ํ๋ก๊ทธ๋จ์ ํด๋นํ๋ ns-3์ ์คํํด ๋ณด๊ฒ ์ต๋๋ค. ์๋
ํ์ธ์๋ค์์ ์
๋ ฅํ์ฌ:
$ ./waf --run hello-simulator
Waf๋ ๋จผ์ ํ๋ก๊ทธ๋จ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๋น๋๋์๋์ง ํ์ธํ๊ณ ํ์ํ ๊ฒฝ์ฐ ๋น๋ํฉ๋๋ค. ๊ทธ ๋ค์์ ์ํ ๋ค์ ์ถ๋ ฅ์ ์์ฑํ๋ ํ๋ก๊ทธ๋จ์ ์คํํฉ๋๋ค.
Hello Simulator
์ถํํด์! ์ด์ ns-3 ์ฌ์ฉ์๊ฐ ๋์ จ์ต๋๋ค!
๊ฒฐ๊ณผ๊ฐ ๋ณด์ด์ง ์์ผ๋ฉด ์ด๋ป๊ฒ ํด์ผ ํฉ๋๊น?
๋ฉ์์ง๊ฐ ํ์๋๋ ๊ฒฝ์ฐ ์ํ๋น๋๊ฐ ์ฑ๊ณต์ ์ผ๋ก ์๋ฃ๋์์์ ๋ํ๋ด์ง๋ง ์ถ๋ ฅ์ด ํ์๋์ง ์์ต๋๋ค. "์๋ ์๋ฎฌ๋ ์ดํฐ", [Build-with-Waf] ์น์ ์์ ๋น๋ ๋ชจ๋๋ฅผ ๋ค์์ผ๋ก ์ ํํ์ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค. ์ต์ ํ, ๊ทธ๋ฌ๋ ๋ชจ๋๋ก ๋ค์ ์ ํํ๋ ๊ฒ์ ๋์ณค์ต๋๋ค. ๋๋ฒ๊ทธ. ์ด ์์ต์์ ์ฌ์ฉ๋ ๋ชจ๋ ์ฝ์ ์ถ๋ ฅ์ ๋ก๊น ์ ์ํํ๊ณ ์ฌ์ฉ์ ์ง์ ๋ฉ์์ง๋ฅผ ์ฝ์์ ์ธ์ํ๋ ๋ฐ ์ฌ์ฉ๋๋ ํน์ ns-3 ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํฉ๋๋ค. ์ต์ ํ๋ ์ฝ๋๊ฐ ์ปดํ์ผ๋๋ฉด ์ด ๊ตฌ์ฑ ์์์ ์ถ๋ ฅ์ด ์๋์ผ๋ก ๋นํ์ฑํ๋ฉ๋๋ค. ์ฆ, "์ต์ ํ"๋ฉ๋๋ค. "Hello Simulator" ์ถ๋ ฅ์ด ํ์๋์ง ์์ผ๋ฉด ๋ค์์ ์ ๋ ฅํฉ๋๋ค.
$ ./waf configure --build-profile=debug --enable-examples --enable-tests
๊ตฌ์ฑํ๋ค ์ํ ์์ ์ ํ ์คํธ๊ฐ ํฌํจ๋ ns-3 ํ๋ก๊ทธ๋จ์ ๋๋ฒ๊ทธ ๋ฒ์ ์ ๊ตฌ์ถํฉ๋๋ค. ๊ทธ๋ฐ ๋ค์ ๋ค์์ ์ ๋ ฅํ์ฌ ์ฝ๋์ ํ์ฌ ๋๋ฒ๊ทธ ๋ฒ์ ์ ๋ค์ ๋น๋ํด์ผ ํฉ๋๋ค.
$ ./waf
์ด์ ํ๋ก๊ทธ๋จ์ ์คํํ๋ฉด ์๋ ํ์ธ์ ์๋ฎฌ๋ ์ดํฐ, ์์๋ ๊ฒฐ๊ณผ๊ฐ ํ์๋์ด์ผ ํฉ๋๋ค.
3.6.1 ๋ช ๋ น์ค ์ธ์
ns-3 ํ๋ก๊ทธ๋จ์ ๋ช ๋ น์ค ์ธ์๋ฅผ ์ ๋ฌํ๋ ค๋ฉด ๋ค์ ํจํด์ ์ฌ์ฉํฉ๋๋ค.
$ ./waf --run <ns3-program> --command-template="%s <args>"
๋ฐ๊พธ๋ค ํ๋ก๊ทธ๋จ ์ด๋ฆ๊ณผ ์ธ์์. ๋
ผ์ -โฏ-command-template
์ ์ํ ๋ณธ์ง์ ์ผ๋ก ์ค์ ๋ช
๋ น์ค์ ์์ฑํ๊ธฐ ์ํ ๋ ์ํผ์
๋๋ค. ์ํ ํ๋ก๊ทธ๋จ์ ์คํํ๋๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. Waf๋ ๋น๋๊ฐ ์๋ฃ๋์๋์ง ํ์ธํ๊ณ ๊ณต์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๊ฒฝ๋ก๋ฅผ ์ค์ ํ ๋ค์ ์ ๊ณต๋ ๋ช
๋ น์ค ํ
ํ๋ฆฟ์ ์ฌ์ฉํ๊ณ %s ์๋ฆฌ ํ์์๋ฅผ ํ๋ก๊ทธ๋จ ์ด๋ฆ์ผ๋ก ๋์ฒดํ์ฌ ์คํ ํ์ผ์ ํธ์ถํฉ๋๋ค. ์ด ๊ตฌ๋ฌธ์ด ๋ณต์กํ๋ค๊ณ ์๊ฐ๋๋ฉด ns-3 ํ๋ก๊ทธ๋จ๊ณผ ์์๋ฐ์ดํ๋ก ๋ฌถ์ธ ์ธ์๋ฅผ ํฌํจํ๋ ๋ ๊ฐ๋จํ ๋ฒ์ ์ด ์์ต๋๋ค.
$ ./waf --run '<ns3-program> --arg1=value1 --arg2=value2 ...'
ํนํ ์ ์ฉํ ๋ ๋ค๋ฅธ ์๋ ํ ์คํธ ์ค์ํธ๋ฅผ ์ ํ์ ์ผ๋ก ์คํํ๋ ๊ฒ์ ๋๋ค. mytest๋ผ๋ ํ ์คํธ ์ค์ํธ๊ฐ ์๋ค๊ณ ๊ฐ์ ํด ๋ด ์๋ค(์ค์ ๋ก๋ ์์ต๋๋ค). ์์์๋ ./test.py ์คํฌ๋ฆฝํธ๋ฅผ ์ฌ์ฉํ์ฌ ํ ์คํธ ํ๋ก๊ทธ๋จ์ ๋ฐ๋ณต์ ์ผ๋ก ํธ์ถํ๋ ์ฌ๋ฌ ํ ์คํธ๋ฅผ ๋ณ๋ ฌ๋ก ์คํํ์ต๋๋ค. ํ ์คํธ ๋ฌ๋. ๋ถ๋ฅด๋ค ํ ์คํธ ๋ฌ๋ ํ๋์ ํ ์คํธ๋ฅผ ์ง์ ์คํํ๋ ค๋ฉด ๋ค์์ ์ํํ์ธ์.
$ ./waf --run test-runner --command-template="%s --suite=mytest --verbose"
์ธ์๋ ํ๋ก๊ทธ๋จ์ ์ ๋ฌ๋ฉ๋๋ค. ํ ์คํธ ๋ฌ๋. mytest๊ฐ ์กด์ฌํ์ง ์์ผ๋ฏ๋ก ์ค๋ฅ ๋ฉ์์ง๊ฐ ์์ฑ๋ฉ๋๋ค. ์ฌ์ฉ ๊ฐ๋ฅํ ํ ์คํธ ์คํ๊ธฐ ์ต์ ์ ์ธ์ํ๋ ค๋ฉด ๋ค์์ ์ ๋ ฅํ์ญ์์ค.
$ ./waf --run test-runner --command-template="%s --help"
3.6.2 ๋๋ฒ๊น
๋๋ฒ๊ฑฐ์ ๊ฐ์ ๋ค๋ฅธ ์ ํธ๋ฆฌํฐ์์ ns-3 ํ๋ก๊ทธ๋จ์ ์คํํ๋ ค๋ฉด(์: gdb) ๋๋ ๋ฉ๋ชจ๋ฆฌ ํ
์คํธ ๋๊ตฌ(์: Valgrind), ์ ์ฌํ ํ์์ ์ฌ์ฉํ์ญ์์ค. -โฏ-command-template = "โฆ"
. ์๋ฅผ ๋ค์ด ๋๋ฒ๊ฑฐ์์ ์คํํ๋ ค๋ฉด gdb ์ธ์๊ฐ ํฌํจ๋ hello-simulator ns-3 ํ๋ก๊ทธ๋จ:
$ ./waf --run=hello-simulator --command-template="gdb %s --args <args>"
ns-3 ํ๋ก๊ทธ๋จ ์ด๋ฆ์ ์ธ์์ ํจ๊ป ์ ๊ณต๋ฉ๋๋ค. -โฏ-run
๋ฐ ๊ด๋ฆฌ ์ ํธ๋ฆฌํฐ(์ฌ๊ธฐ gdb)๋ ์ธ์์ ์ฒซ ๋ฒ์งธ ํ ํฐ์
๋๋ค. -โฏ-command-template
. ์ต์
-โฏ-args
๋ณด๊ณ ์ gdb๋๋จธ์ง ๋ช
๋ น์ค์ "ํ์" ํ๋ก๊ทธ๋จ์ ์ํฉ๋๋ค. (์ผ๋ถ ๋ฒ์ gdb ์ต์
์ ์ดํดํ์ง ๋ชปํจ -โฏ-args
. ์ด ๊ฒฝ์ฐ ํ๋ก๊ทธ๋จ ์ธ์๋ฅผ ์ ๊ฑฐํ์ญ์์ค. -โฏ-command-template
๋ช
๋ น ์ธํธ๋ฅผ ์ฌ์ฉํ์ญ์์ค gdb ์ธ์.) ์ด ๋ ์ํผ์ ์ด์ ๋ ์ํผ๋ฅผ ๊ฒฐํฉํ์ฌ ๋๋ฒ๊ฑฐ์์ ํ
์คํธ๋ฅผ ์คํํ ์ ์์ต๋๋ค.
$ ./waf --run test-runner --command-template="gdb %s --args --suite=mytest --verbose"
3.6.3 ์์ ๋๋ ํ ๋ฆฌ
Waf๋ ns-3 ํธ๋ฆฌ ์๋จ์ ์๋ ์์น์์ ์์๋์ด์ผ ํฉ๋๋ค. ์ด ํด๋๋ ์ถ๋ ฅ ํ์ผ์ด ๊ธฐ๋ก๋๋ ์์
๋๋ ํฐ๋ฆฌ๊ฐ ๋ฉ๋๋ค. ํ์ง๋ง ์ด๋ฌํ ํ์ผ์ ns-3 ์์ค ํธ๋ฆฌ ์ธ๋ถ์ ๋ณด๊ดํ๋ ค๋ฉด ์ด๋ป๊ฒ ํด์ผ ํ ๊น์? ์ธ์ ์ฌ์ฉ -โฏ-cwd
:
$ ./waf --cwd=...
์์ ๋๋ ํฐ๋ฆฌ์ ์ถ๋ ฅ ํ์ผ์ ๊ฐ์ ธ์ค๋ ๊ฒ์ด ๋ ํธ๋ฆฌํ ์ ์์ต๋๋ค. ์ด ๊ฒฝ์ฐ ๋ค์๊ณผ ๊ฐ์ ๊ฐ์ ์ ์ธ ์กฐ์น๊ฐ ๋์์ด ๋ ์ ์์ต๋๋ค.
$ function waff {
CWD="$PWD"
cd $NS3DIR >/dev/null
./waf --cwd="$CWD" $*
cd - >/dev/null
}
์ด์ ๋ฒ์ ์ ๋ช
๋ น ์ฅ์์ ํ์ฌ ์์
๋๋ ํฐ๋ฆฌ๋ฅผ ์ ์งํ๊ณ ๋ค์ ๋๋ ํฐ๋ฆฌ๋ก ์ด๋ํฉ๋๋ค. ์ํ๊ทธ๋ฆฌ๊ณ ๋ ์ง์ํ๋ค ์ํ ํ๋ก๊ทธ๋จ์ ์์ํ๊ธฐ ์ ์ ์ ์ฅ๋ ํ์ฌ ์์
๋๋ ํ ๋ฆฌ๋ก ์์
๋๋ ํ ๋ฆฌ๋ฅผ ๋ค์ ๋ณ๊ฒฝํฉ๋๋ค. ์ฐ๋ฆฌ๋ ํ์ ์ธ๊ธํฉ๋๋ค -โฏ-cwd
์์ ์ฑ์ ์ํด ๋๋ถ๋ถ์ ์ฌ์ฉ์๋ ๋จ์ํ ์ต์์ ๋๋ ํฐ๋ฆฌ์์ Waf๋ฅผ ์คํํ๊ณ ๊ฑฐ๊ธฐ์์ ์ถ๋ ฅ ํ์ผ์ ์์ฑํฉ๋๋ค.
์ถ์ฒ : habr.com