5๊ฐ์ง ์ค์
5.1 ๋ก๊น
๋ชจ๋ ์ฌ์ฉ
5.1.1 ๋ก๊น
๊ฐ์
5.1.2 ๋ก๊น
ํ์ฑํ
5.1.3 ์ฝ๋์ ๋ก๊น
์ถ๊ฐ
5.2 ๋ช
๋ น์ค ์ธ์ ์ฌ์ฉ
5.2.1 ๊ธฐ๋ณธ ์์ฑ ๊ฐ ์ฌ์ ์
5.2.2 ์์ ๋ง์ ๋ช
๋ น ์บก์ฒ
5.3 ์ถ์ ์์คํ
์ฌ์ฉ
5.3.1 ASCII ์ถ์
ASCII ์ถ์ ๊ตฌ๋ฌธ ๋ถ์
5.3.2 PCAP ์ถ์
์ฅ 5
์กฐ์
5.1 ๋ก๊น ๋ชจ๋ ์ฌ์ฉ
์ฐ๋ฆฌ๋ ์ด๋ฏธ ์คํฌ๋ฆฝํธ๋ฅผ ๋ณด๋ฉด์ ns-3 ๋ก๊น ๋ชจ๋์ ๊ฐ๋ตํ๊ฒ ์ดํด๋ณด์์ต๋๋ค. ์ฒซ ๋ฒ์งธ.cc. ์ด๋ฒ ์ฅ์์๋ ๋ก๊น ํ์ ์์คํ ์ ๊ฐ๋ฅํ ์ฉ๋๋ฅผ ์์ธํ ์ดํด๋ณด๊ฒ ์ต๋๋ค.
5.1.1 ๋ก๊น ๊ฐ์
๋ง์ ๋๊ท๋ชจ ์์คํ ์ ์ผ์ข ์ ๋ฉ์์ง ๋ก๊น ๊ธฐ๋ฅ์ ์ง์ํ๋ฉฐ ns-3๋ ์์ธ๋ ์๋๋๋ค. ๊ฒฝ์ฐ์ ๋ฐ๋ผ "์ด์์ ์ฝ์"(์ผ๋ฐ์ ์ผ๋ก Unix ๊ธฐ๋ฐ ์์คํ ์์๋ stderr)์ ์ค๋ฅ ๋ฉ์์ง๋ง ๊ธฐ๋ก๋ฉ๋๋ค. ๋ค๋ฅธ ์์คํ ์์๋ ๋ ์์ธํ ์ ๋ณด์ ํจ๊ป ๊ฒฝ๊ณ ๋ฉ์์ง๊ฐ ํ์๋ ์ ์์ต๋๋ค. ์ด๋ค ๊ฒฝ์ฐ์๋ ์ถ๋ ฅ์ ๋น ๋ฅด๊ฒ ํ๋ฆฌ๊ฒ ํ ์ ์๋ ๋๋ฒ๊ทธ ๋ฉ์์ง๋ฅผ ์ถ๋ ฅํ๋ ๋ฐ ๋ก๊น ๋๊ตฌ๊ฐ ์ฌ์ฉ๋ฉ๋๋ค.
ns-3์์ ์ฌ์ฉ๋๋ subHRD๋ ์ด๋ฌํ ๋ชจ๋ ์์ค์ ์ ๋ณด ์ฝํ ์ธ ๊ฐ ์ ์ฉํ๋ค๊ณ ๊ฐ์ ํ๊ณ ๋ฉ์์ง ๋ก๊น ์ ๋ํ ์ ํ์ ์ด๊ณ ๊ณ์ธตํ๋ ์ ๊ทผ ๋ฐฉ์์ ์ ๊ณตํฉ๋๋ค. ๋ก๊น ์ ์์ ํ ๋นํ์ฑํํ๊ฑฐ๋, ๊ตฌ์ฑ ์์๋ณ๋ก ๋๋ ์ ์ฒด์ ์ผ๋ก ํ์ฑํํ ์ ์์ต๋๋ค. ์ด๋ฅผ ์ํด ์กฐ์ ๊ฐ๋ฅํ ์์ค์ ์ ๋ณด ์ฝํ ์ธ ๊ฐ ์ฌ์ฉ๋ฉ๋๋ค. ns-3 ๋ก๊น ๋ชจ๋์ ์๋ฎฌ๋ ์ด์ ์์ ์ ์ฉํ ์ ๋ณด๋ฅผ ์ป๋ ๋น๊ต์ ๊ฐ๋จํ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค.
๋ชจ๋ธ์์ ๋ฐ์ดํฐ๋ฅผ ์ถ์ถํ๊ธฐ ์ํ ๋ฒ์ฉ ๋ฉ์ปค๋์ฆ์ธ ์ถ์ ์ ์ ๊ณตํ๋ค๋ ์ ์ ์ดํดํด์ผ ํฉ๋๋ค. ์ด๋ ์๋ฎฌ๋ ์ด์ ์ ์ํ ๊ธฐ๋ณธ ์ถ๋ ฅ์ด ๋์ด์ผ ํฉ๋๋ค(์ถ์ ์์คํ ์ ๋ํ ์์ธํ ๋ด์ฉ์ ํํ ๋ฆฌ์ผ ์น์ 5.3์ ์ฐธ์กฐํ์ธ์). ๋ก๊น ์ ๋๋ฒ๊น ์ ๋ณด, ๊ฒฝ๊ณ , ์ค๋ฅ ๋ฉ์์ง๋ฅผ ์ป๊ฑฐ๋ ์ธ์ ๋ ์ง ์คํฌ๋ฆฝํธ๋ ๋ชจ๋ธ์์ ๋ฉ์์ง๋ฅผ ์ ์ํ๊ฒ ์ถ๋ ฅํ๊ธฐ ์ํด ์ ํธ๋๋ ๋ฐฉ๋ฒ์ ๋๋ค.
ํ์ฌ ์์คํ ์ ์ ๋ณด ๋ด์ฉ์ด ์ฆ๊ฐํ๋ ์์๋๋ก ๋ก๊ทธ ๋ฉ์์ง์ XNUMX๊ฐ์ง ์์ค(์ ํ)์ ์ ์ํฉ๋๋ค.
- LOG_ERROR - ์ค๋ฅ ๋ฉ์์ง ๋ก๊น (๊ด๋ จ ๋งคํฌ๋ก: NS_LOG_ERROR);
- LOG_WARN - ๊ฒฝ๊ณ ๋ฉ์์ง ๊ธฐ๋ก(๊ด๋ จ ๋งคํฌ๋ก: NS_LOG_WARN);
- LOG_DEBUG - ์๋์ ์ผ๋ก ๋๋ฌธ ํน์ ๋๋ฒ๊ทธ ๋ฉ์์ง๋ฅผ ๊ธฐ๋กํฉ๋๋ค(๊ด๋ จ ๋งคํฌ๋ก: NS_LOG_DEBUG).
- LOG_INFO - ํ๋ก๊ทธ๋จ ์งํ์ ๊ดํ ์ ๋ณด ๋ฉ์์ง ๋ฑ๋ก(๊ด๋ จ ๋งคํฌ๋ก: NS_LOG_INFO)
- LOG_FUNCTION - ํธ์ถ๋ ๊ฐ ํจ์(๋ ๊ฐ์ ๊ด๋ จ ๋งคํฌ๋ก: ๋ฉค๋ฒ ํจ์์ ์ฌ์ฉ๋๋ NS_LOG_FUNCTION ๋ฐ ์ ์ ํจ์์ ์ฌ์ฉ๋๋ NS_LOG_FUNCTION_NOARGS)๋ฅผ ์ค๋ช ํ๋ ๋ฉ์์ง๋ฅผ ๊ธฐ๋กํฉ๋๋ค.
- LOG_LOGIC - ํจ์ ๋ด์ ๋ ผ๋ฆฌ์ ํ๋ฆ์ ์ค๋ช ํ๋ ๋ก๊น ๋ฉ์์ง(๊ด๋ จ ๋งคํฌ๋ก: NS_LOG_LOGIC)
- LOG_ALL - ์์ ์ธ๊ธ๋ ๋ชจ๋ ๋ด์ฉ์ ๊ธฐ๋กํฉ๋๋ค(๊ด๋ จ ๋งคํฌ๋ก ์์).
๊ฐ ์ ํ(LOG_TYPE)์๋ LOG_LEVEL_TYPE๋ ์์ผ๋ฉฐ, ์ด๋ฅผ ์ฌ์ฉํ๋ฉด ์์ฒด ์์ค ์ธ์๋ ๊ทธ ์์ ๋ชจ๋ ์์ค์ ๊ธฐ๋กํ ์ ์์ต๋๋ค. (๊ฒฐ๊ณผ์ ์ผ๋ก LOG_ERROR์ LOG_LEVEL_ERROR, LOG_ALL๊ณผ LOG_LEVEL_ALL์ ๊ธฐ๋ฅ์ ์ผ๋ก ๋์ผํฉ๋๋ค.) ์๋ฅผ ๋ค์ด LOG_INFO๋ฅผ ํ์ฑํํ๋ฉด NS_LOG_INFO ๋งคํฌ๋ก์์ ์ ๊ณตํ๋ ๋ฉ์์ง๋ง ํ์ฉํ๋ ๋ฐ๋ฉด, LOG_LEVEL_INFO๋ฅผ ํ์ฑํํ๋ฉด NS_LOG_DEBUG, NS_LOG_WARN ๋ฐ NS_LOG_ERROR ๋งคํฌ๋ก์์ ์ ๊ณตํ๋ ๋ฉ์์ง๋ ํฌํจ๋ฉ๋๋ค.
๋ํ ๋ก๊น ์์ค์ด๋ ์ ํ ๊ตฌ์ฑ ์์์ ๊ด๊ณ์์ด ํญ์ ํ์๋๋ ๋ฌด์กฐ๊ฑด ๋ก๊น ๋งคํฌ๋ก๋ฅผ ์ ๊ณตํฉ๋๋ค.
- NS_LOG_UNCOND - ๊ด๋ จ ๋ฉ์์ง์ ๋ฌด์กฐ๊ฑด ๋ก๊น (๊ด๋ จ ๋ก๊น ์์ค ์์)
๊ฐ ์์ค์ ๊ฐ๋ณ์ ์ผ๋ก ๋๋ ๋์ ์ ์ผ๋ก ์ฟผ๋ฆฌํ ์ ์์ต๋๋ค. ๋ก๊น ์ sh ํ๊ฒฝ ๋ณ์ NS_LOG๋ฅผ ์ฌ์ฉํ๊ฑฐ๋ ์์คํ ํจ์ ํธ์ถ์ ๋ก๊น ํ์ฌ ๊ตฌ์ฑํ ์ ์์ต๋๋ค. ์์ ์ดํด๋ณธ ๊ฒ์ฒ๋ผ ๋ก๊น ์์คํ ์๋ Doxygen ๋ฌธ์๊ฐ ์์ผ๋ฉฐ ์์ง ๊ฒํ ํ์ง ์์๋ค๋ฉด ์ง๊ธ ๊ฒํ ํด ๋ณผ ์ ์๋ ์ข์ ์๊ฐ์ ๋๋ค.
์ด์ ๋ฌธ์๋ฅผ ๋งค์ฐ ์์ธํ ์ฝ์์ผ๋ฏ๋ก ํด๋น ์ง์์ ํ์ฉํ์ฌ ์์ ์คํฌ๋ฆฝํธ์์ ํฅ๋ฏธ๋ก์ด ์ ๋ณด๋ฅผ ์ป์ด ๋ณด๊ฒ ์ต๋๋ค. ์คํฌ๋์น/myfirst.cc์ด๋ฏธ ์ปดํ์ผํ ๊ฒ์ ๋๋ค.
5.1.2 ๋ก๊น ํ์ฑํ
NS_LOG ํ๊ฒฝ ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ๋ ๋ง์ ๋ก๊ทธ๋ฅผ ์คํํด ๋ณด๊ฒ ์ต๋๋ค. ๋จผ์ ๋ฐฉํฅ์ ํ์ ํ๊ธฐ ์ํด ์ด์ ์ ํ๋ ๊ฒ์ฒ๋ผ ๋ง์ง๋ง ์คํฌ๋ฆฝํธ๋ฅผ ์คํํฉ๋๋ค.
$ ./waf --run scratch/myfirst
์ฒซ ๋ฒ์งธ ns-3 ์์ ํ๋ก๊ทธ๋จ์ ์น์ํ ์ถ๋ ฅ์ด ํ์๋ฉ๋๋ค.
$ Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build' 'build'
finished successfully (0.413s)
Sent 1024 bytes to 10.1.1.2
Received 1024 bytes from 10.1.1.1
Received 1024 bytes from 10.1.1.2
์์ ํ์๋ "์ ์ก" ๋ฐ "์์ " ๋ฉ์์ง๋ ์ค์ ๋ก๋ ๋ค์์์ ๊ธฐ๋ก๋ ๋ฉ์์ง์ ๋๋ค. UdpEchoClient์์ฉ ํ๋ก๊ทธ๋จ ะธ UdpEchoServer์์ฉ ํ๋ก๊ทธ๋จ. ์๋ฅผ ๋ค์ด, NS_LOG ํ๊ฒฝ ๋ณ์๋ฅผ ํตํด ๋ก๊น ์์ค์ ์ค์ ํ์ฌ ํด๋ผ์ด์ธํธ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ถ๊ฐ ์ ๋ณด๋ฅผ ์ธ์ํ๋๋ก ์์ฒญํ ์ ์์ต๋๋ค.
์ด์ ๋ถํฐ๋ "VARIABLE=value" ๊ตฌ๋ฌธ์ ์ฌ์ฉํ๋ sh์ ๊ฐ์ ์์ ์ฌ์ฉํ๊ณ ์๋ค๊ณ ๊ฐ์ ํ๊ฒ ์ต๋๋ค. csh์ ์ ์ฌํ ์ ธ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ์์ ๋ฅผ ํด๋น ์ ธ์์ ์๊ตฌํ๋ "setenv ๋ณ์ ๊ฐ" ๊ตฌ๋ฌธ์ผ๋ก ๋ณํํด์ผ ํฉ๋๋ค.
ํ์ฌ UDP ์์ฝ ํด๋ผ์ด์ธํธ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ค์ ์ฝ๋ ์ค์ ์๋ตํฉ๋๋ค. ์คํฌ๋์น/myfirst.cc,
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
๋ก๊น ์์ค LOG_LEVEL_INFO๋ฅผ ํ์ฑํํฉ๋๋ค. ๋ก๊น ์์ค ํ๋๊ทธ๋ฅผ ์ ๋ฌํ๋ฉด ์ค์ ๋ก ํด๋น ์์ค๊ณผ ๋ชจ๋ ํ์ ์์ค์ด ํ์ฑํ๋ฉ๋๋ค. ์ด ๊ฒฝ์ฐ NS_LOG_INFO, NS_LOG_DEBUG, NS_LOG_WARN ๋ฐ NS_LOG_ERROR๋ฅผ ํ์ฑํํ์ต๋๋ค. NS_LOG ํ๊ฒฝ ๋ณ์๋ฅผ ๋ค์๊ณผ ๊ฐ์ด ์ค์ ํ๋ฉด ์คํฌ๋ฆฝํธ ๋ณ๊ฒฝ์ด๋ ์ฌ์ปดํ์ผ ์์ด ๋ก๊น ์์ค์ ๋์ด๊ณ ๋ ๋ง์ ์ ๋ณด๋ฅผ ์ป์ ์ ์์ต๋๋ค.
$ export NS_LOG=UdpEchoClientApplication=level_all
๋ฐ๋ผ์ sh ์ ๋ณ์ NS_LOG๋ฅผ ๋ค์ ๊ฐ์ผ๋ก ์ค์ ํฉ๋๋ค.
UdpEchoClientApplication=level_all
ํ ๋น์ ์ผ์ชฝ์ ๊ตฌ์ฑํ๋ ค๋ ๊ธฐ๋ก๋ ๊ตฌ์ฑ ์์์ ์ด๋ฆ์ด๊ณ ์ค๋ฅธ์ชฝ์ ์ ์ฉํ ํ๋๊ทธ์ ๋๋ค. ์ด ๊ฒฝ์ฐ ์ ํ๋ฆฌ์ผ์ด์ ์์ ๋ชจ๋ ์์ค์ ๋๋ฒ๊น ์ ํ์ฑํํ๊ฒ ์ต๋๋ค. NS_LOG๋ฅผ ์ด๋ฐ ๋ฐฉ์์ผ๋ก ์ค์ ํ์ฌ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋ฉด ns-3 ๋ก๊น ์์คํ ์ด ๋ณ๊ฒฝ ์ฌํญ์ ์๋ฝํ๊ณ ๋ค์ ์ถ๋ ฅ์ด ํ์๋ฉ๋๋ค.
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.404s)
UdpEchoClientApplication:UdpEchoClient()
UdpEchoClientApplication:SetDataSize(1024)
UdpEchoClientApplication:StartApplication()
UdpEchoClientApplication:ScheduleTransmit()
UdpEchoClientApplication:Send()
Sent 1024 bytes to 10.1.1.2
Received 1024 bytes from 10.1.1.1
UdpEchoClientApplication:HandleRead(0x6241e0, 0x624a20)
Received 1024 bytes from 10.1.1.2
UdpEchoClientApplication:StopApplication()
UdpEchoClientApplication:DoDispose()
UdpEchoClientApplication:~UdpEchoClient()
์ ํ๋ฆฌ์ผ์ด์
์์ ์ ๊ณตํ๋ ์ถ๊ฐ ๋๋ฒ๊น
์ ๋ณด๋ ์ด์ NS_LOG_FUNCTION ์์ค์ ์์ต๋๋ค. ์คํฌ๋ฆฝํธ ์คํ ์ค ํจ์ ํธ์ถ์ ๋ชจ๋ ์ธ์คํด์ค๋ฅผ ํ์ํฉ๋๋ค. ์ผ๋ฐ์ ์ผ๋ก ๋ฉ์๋ ํจ์์์๋ (์ต์ํ) ์ฌ์ฉํ๋ ๊ฒ์ด ๋ฐ๋์งํฉ๋๋ค.NS_LOG_FUNCTION (this)
... ์ฌ์ฉ NS_LOG_FUNCTION_NOARGS ()
์ ์ ํจ์์์๋ง ๊ฐ๋ฅํฉ๋๋ค. ๊ทธ๋ฌ๋ ns-3 ์์คํ
์ ๋ก๊น
๊ธฐ๋ฅ์ ์ง์ํ ํ์๊ฐ ์์ต๋๋ค. ์ผ๋ง๋ ๋ง์ ์ ๋ณด๊ฐ ๊ธฐ๋ก๋๋์ง์ ๋ํ ๊ฒฐ์ ์ ๊ฐ๋ณ ๋ชจ๋ธ ๊ฐ๋ฐ์์๊ฒ ๋ฌ๋ ค ์์ต๋๋ค. echo ์ ํ๋ฆฌ์ผ์ด์
์ ๊ฒฝ์ฐ ๋๋์ ๋ก๊น
์ถ๋ ฅ์ด ๊ฐ๋ฅํฉ๋๋ค.
์ด์ ์ ํ๋ฆฌ์ผ์ด์ ์์ ์ํ๋ ํจ์ ํธ์ถ ๋ก๊ทธ๋ฅผ ๋ณผ ์ ์์ต๋๋ค. ์์ธํ ๋ณด๋ฉด ์ค ์ฌ์ด์ ์ฝ๋ก ์ด ์๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค. UdpEchoClient์์ฉ ํ๋ก๊ทธ๋จ ๊ทธ๋ฆฌ๊ณ C++ ๋ฒ์ ์ฐ์ฐ์(: :)๋ฅผ ๋ณผ ์ ์๋ ๋ฉ์๋์ ์ด๋ฆ์ ๋๋ค. ์ด๋ ์๋์ ์ธ ๊ฒ์ ๋๋ค.
์ด๋ ์ค์ ๋ก ํด๋์ค ์ด๋ฆ์ด ์๋๋ผ ๋ก๊น ๊ตฌ์ฑ ์์์ ์ด๋ฆ์ ๋๋ค. ์์ค ํ์ผ๊ณผ ํด๋์ค๊ฐ ์ผ์นํ๋ ๊ฒฝ์ฐ ์ผ๋ฐ์ ์ผ๋ก ํด๋์ค ์ด๋ฆ์ด์ง๋ง ์ค์ ๋ก๋ ํด๋์ค ์ด๋ฆ์ด ์๋๋ฉฐ ์ด์ค ์ฝ๋ก ๋์ ๋จ์ผ ์ฝ๋ก ์ด ์๋ค๋ ์ ์ ์์์ผ ํฉ๋๋ค. ์ด๋ ์๋์ ์ผ๋ก ๋ฏธ๋ฌํ ๋ฐฉ๋ฒ์ผ๋ก ํด๋์ค ์ด๋ฆ์์ ๋ก๊น Bean ์ด๋ฆ์ ๊ฐ๋ ์ ์ผ๋ก ๋ถ๋ฆฌํ๋ ๋ฐ ๋์์ด ๋๋ ๋ฐฉ๋ฒ์ ๋๋ค.
๊ทธ๋ฌ๋ ๊ฒฝ์ฐ์ ๋ฐ๋ผ ์ค์ ๋ก ๋ก๊ทธ ๋ฉ์์ง๋ฅผ ์์ฑํ๋ ๋ฐฉ๋ฒ์ ํ์ธํ๋ ๊ฒ์ด ์ด๋ ค์ธ ์ ์์ต๋๋ค. ์์ ํ
์คํธ๋ฅผ ๋ณด์๋ฉด "๋ผ๋ ์ค์ด ์ด๋์ ์๋์ง ๊ถ๊ธํ์ค ๊ฒ์
๋๋ค.Received 1024 bytes from 10.1.1.2
" ๋ ๋ฒจ์ ์ค์ ํ๋ฉด ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค. ์ ๋์ฌ_ํํฌ NS_LOG ํ๊ฒฝ ๋ณ์์. ๋ค์์ ์๋ํด ๋ณด์ธ์:
$ export 'NS_LOG=UdpEchoClientApplication=level_all|prefix_func'
OR ์ฐ์ฐ์ ๋ํ๋ด๋ ๋ฐ ์ฌ์ฉํ๋ ์ธ๋ก ๋ง๋๋ Unix ํ์ดํ ์ปค๋ฅํฐ์ด๊ธฐ ๋๋ฌธ์ ๋ฐ์ดํ๊ฐ ํ์ํฉ๋๋ค. ์ด์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋ฉด ๋ก๊น ์์คํ ์ด ํน์ ๋ก๊ทธ์ ๋ชจ๋ ๋ฉ์์ง ์์ ๊ตฌ์ฑ ์์ ์ด๋ฆ์ด ๋ถ๋ ๊ฒ์ ํ์ธํ๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค.
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.417s)
UdpEchoClientApplication:UdpEchoClient()
UdpEchoClientApplication:SetDataSize(1024)
UdpEchoClientApplication:StartApplication()
UdpEchoClientApplication:ScheduleTransmit()
UdpEchoClientApplication:Send()
UdpEchoClientApplication:Send(): Sent 1024 bytes to 10.1.1.2
Received 1024 bytes from 10.1.1.1
UdpEchoClientApplication:HandleRead(0x6241e0, 0x624a20)
UdpEchoClientApplication:HandleRead(): Received 1024 bytes from 10.1.1.2
UdpEchoClientApplication:StopApplication()
UdpEchoClientApplication:DoDispose()
UdpEchoClientApplication:~UdpEchoClient()
์ด์ UDP ์์ฝ ํด๋ผ์ด์ธํธ ์ ํ๋ฆฌ์ผ์ด์
์์ ์ค๋ ๋ชจ๋ ๋ฉ์์ง๊ฐ ์ด์ ๊ฐ์ด ์๋ณ๋๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค. ๋ฉ์์ง "Received 1024 bytes from 10.1.1.2
"๋ ์ด์ ์์ฝ ํด๋ผ์ด์ธํธ ์ ํ๋ฆฌ์ผ์ด์
์์ ์ค๋ ๊ฒ์ผ๋ก ๋ช
ํํ๊ฒ ์๋ณ๋ฉ๋๋ค. ๋๋จธ์ง ๋ฉ์์ง๋ UDP ์์ฝ ์๋ฒ ์ ํ๋ฆฌ์ผ์ด์
์์ ์์ผ ํฉ๋๋ค. NS_LOG ํ๊ฒฝ ๋ณ์์ ์ฝ๋ก ์ผ๋ก ๊ตฌ๋ถ๋ ๊ตฌ์ฑ ์์ ๋ชฉ๋ก์ ์
๋ ฅํ์ฌ ์ด ๊ตฌ์ฑ ์์๋ฅผ ํ์ฑํํ ์ ์์ต๋๋ค.
$ export 'NS_LOG=UdpEchoClientApplication=level_all|prefix_func:
UdpEchoServerApplication=level_all|prefix_func'
๊ฒฝ๊ณ : ์์ ์์ ํ ์คํธ์์ ๋ฌธ์ ํ์์ ์ง์ ํ๋ ๋ฐ ์ฌ์ฉ๋๋ ์ฝ๋ก (:) ๋ค์ ๊ฐํ ๋ฌธ์๋ฅผ ์ ๊ฑฐํด์ผ ํฉ๋๋ค. ์ด์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋ฉด ํด๋ผ์ด์ธํธ ๋ฐ ์๋ฒ ์์ฝ ์ ํ๋ฆฌ์ผ์ด์ ์ ๋ชจ๋ ๋ก๊ทธ ๋ฉ์์ง๊ฐ ํ์๋ฉ๋๋ค. ๋๋ฒ๊น ํ ๋ ์ด๊ฒ์ด ๋งค์ฐ ์ ์ฉํ ์ ์๋ค๋ ๊ฒ์ ์ ์ ์์ต๋๋ค.
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.406s)
UdpEchoServerApplication:UdpEchoServer()
UdpEchoClientApplication:UdpEchoClient()
UdpEchoClientApplication:SetDataSize(1024)
UdpEchoServerApplication:StartApplication()
UdpEchoClientApplication:StartApplication()
UdpEchoClientApplication:ScheduleTransmit()
UdpEchoClientApplication:Send()
UdpEchoClientApplication:Send(): Sent 1024 bytes to 10.1.1.2
UdpEchoServerApplication:HandleRead(): Received 1024 bytes from 10.1.1.1
UdpEchoServerApplication:HandleRead(): Echoing packet
UdpEchoClientApplication:HandleRead(0x624920, 0x625160)
UdpEchoClientApplication:HandleRead(): Received 1024 bytes from 10.1.1.2
UdpEchoServerApplication:StopApplication()
UdpEchoClientApplication:StopApplication()
UdpEchoClientApplication:DoDispose()
UdpEchoServerApplication:DoDispose()
UdpEchoClientApplication:~UdpEchoClient()
UdpEchoServerApplication:~UdpEchoServer()
๋ก๊ทธ ๋ฉ์์ง๊ฐ ์์ฑ๋ ์๋ฎฌ๋ ์ด์ ์๊ฐ์ ๋ณผ ์ ์์ผ๋ฉด ์ ์ฉํ ๋๋ ์์ต๋๋ค. OR ๋นํธ๋ฅผ ์ถ๊ฐํ๋ฉด ๋ฉ๋๋ค. ์ ๋์ฌ_์๊ฐ:
$ export 'NS_LOG=UdpEchoClientApplication=level_all|prefix_func|prefix_time: UdpEchoServerApplication=level_all|prefix_func|prefix_time'
์ด๋ฒ์๋ ์์ ๊ฐํ ๋ฌธ์๋ฅผ ์ ๊ฑฐํด์ผ ํฉ๋๋ค. ์ด์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋ฉด ๋ค์ ์ถ๋ ฅ์ด ํ์๋ฉ๋๋ค.
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.418s)
0s UdpEchoServerApplication:UdpEchoServer()
0s UdpEchoClientApplication:UdpEchoClient()
0s UdpEchoClientApplication:SetDataSize(1024)
1s UdpEchoServerApplication:StartApplication()
2s UdpEchoClientApplication:StartApplication()
2s UdpEchoClientApplication:ScheduleTransmit()
2s UdpEchoClientApplication:Send()
2s UdpEchoClientApplication:Send(): Sent 1024 bytes to 10.1.1.2
2.00369s UdpEchoServerApplication:HandleRead(): Received 1024 bytes from 10.1.1.1
2.00369s UdpEchoServerApplication:HandleRead(): Echoing packet
2.00737s UdpEchoClientApplication:HandleRead(0x624290, 0x624ad0)
2.00737s UdpEchoClientApplication:HandleRead(): Received 1024 bytes from 10.1.1.2
10s UdpEchoServerApplication:StopApplication()
10s UdpEchoClientApplication:StopApplication()
UdpEchoClientApplication:DoDispose()
UdpEchoServerApplication:DoDispose()
UdpEchoClientApplication:~UdpEchoClient()
UdpEchoServerApplication:~UdpEchoServer()
์์ฑ์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. UDPEcho์๋ฒ ์๋ฎฌ๋ ์ด์ ์ค์ 0์ด ๋์ ํธ์ถ๋์์ต๋๋ค. ์ด๋ ์ค์ ๋ก ์๋ฎฌ๋ ์ด์ ์ด ์์๋๊ธฐ ์ ์ ๋ฐ์ํ์ง๋ง ์๊ฐ์ XNUMX์ด๋ก ํ์๋ฉ๋๋ค. ์์ฑ์ ๋ฉ์์ง๋ ๋ง์ฐฌ๊ฐ์ง์ ๋๋ค. UDPEchoํด๋ผ์ด์ธํธ.
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.418s)
0s UdpEchoServerApplication:UdpEchoServer()
0s UdpEchoClientApplication:UdpEchoClient()
0s UdpEchoClientApplication:SetDataSize(1024)
1s UdpEchoServerApplication:StartApplication()
2s UdpEchoClientApplication:StartApplication()
2s UdpEchoClientApplication:ScheduleTransmit()
2s UdpEchoClientApplication:Send()
2s UdpEchoClientApplication:Send(): Sent 1024 bytes to 10.1.1.2
2.00369s UdpEchoServerApplication:HandleRead(): Received 1024 bytes from 10.1.1.1
2.00369s UdpEchoServerApplication:HandleRead(): Echoing packet
2.00737s UdpEchoClientApplication:HandleRead(0x624290, 0x624ad0)
2.00737s UdpEchoClientApplication:HandleRead(): Received 1024 bytes from 10.1.1.2
10s UdpEchoServerApplication:StopApplication()
10s UdpEchoClientApplication:StopApplication()
UdpEchoClientApplication:DoDispose()
UdpEchoServerApplication:DoDispose()
UdpEchoClientApplication:~UdpEchoClient()
UdpEchoServerApplication:~UdpEchoServer()
์คํฌ๋ฆฝํธ๋ฅผ ๊ธฐ์ตํ์ธ์. ์คํฌ๋์น/first.cc ์๋ฎฌ๋ ์ด์ ์์ XNUMX์ด ์ ์ ์์ฝ ์๋ฒ ์ ํ๋ฆฌ์ผ์ด์ ์ ์์ํ์ต๋๋ค. ์ด์ ๊ทธ ๋ฐฉ๋ฒ์ ๋ณผ ์ ์์ต๋๋ค ์์ฉ ํ๋ก๊ทธ๋จ ์์ ์๋ฒ๋ ์ค์ ๋ก ์ฒซ ๋ฒ์งธ ์๊ฐ์ ํธ์ถ๋ฉ๋๋ค. ์คํฌ๋ฆฝํธ์์ ์์ฒญํ ๋๋ก ์๋ฎฌ๋ ์ด์ ์ ๋ ๋ฒ์งธ ์ด์ ์์ฝ ํด๋ผ์ด์ธํธ๊ฐ ์์๋๋ ๊ฒ์ ๋ณผ ์๋ ์์ต๋๋ค.
์ด์ ํตํ ์ ์๋ฎฌ๋ ์ด์ ์งํ ์ํฉ์ ํ์ธํ ์ ์์ต๋๋ค. ์ผ์ ์ ์ก HandleRead ์ฝ๋ฐฑ์ ํธ์ถํ๋ ํด๋ผ์ด์ธํธ์์ ์์ฝ ์๋ฒ ์ ํ๋ฆฌ์ผ์ด์ ์ผ๋ก ๋ณด๋ ๋๋ค. ์ง์ ๊ฐ ๋งํฌ๋ฅผ ํตํด ํจํท์ ๋ณด๋ด๋ ๋ฐ ๊ฒฝ๊ณผ๋ ์๊ฐ์ 3,69๋ฐ๋ฆฌ์ด์ ๋๋ค. ์์ฝ ์๋ฒ๊ฐ ํจํท์ ์๋ตํ๋ค๋ ๋ฉ์์ง๋ฅผ ๊ธฐ๋กํ ๋ค์, ์ฑ๋ ์ง์ฐ ํ ์์ฝ ํด๋ผ์ด์ธํธ๊ฐ HandleRead ๋ฉ์๋์์ ์์ฝ ํจํท์ ์์ ํ๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค.
์ด ์๋ฎฌ๋ ์ด์ ์์๋ ์ฌ๋ฌ๋ถ๋ ๋ชจ๋ฅด๋ ์ฌ์ด์ ๋ง์ ์ผ์ด ์ผ์ด๋ฉ๋๋ค. ๊ทธ๋ฌ๋ ์์คํ ์ ๋ชจ๋ ๋ก๊น ๊ตฌ์ฑ ์์๋ฅผ ํ์ฑํํ๋ฉด ์ ์ฒด ํ๋ก์ธ์ค๋ฅผ ๋งค์ฐ ์ฝ๊ฒ ์ถ์ ํ ์ ์์ต๋๋ค. NS_LOG ๋ณ์๋ฅผ ๋ค์ ๊ฐ์ผ๋ก ์ค์ ํด๋ณด์ธ์.
$ export 'NS_LOG=*=level_all|prefix_func|prefix_time'
์์ ๋ณํ๋ ๋ก๊น ๊ตฌ์ฑ ์์์ ์์ผ๋์นด๋ ๋ฌธ์์ ๋๋ค. ์ฌ๊ธฐ์๋ ์๋ฎฌ๋ ์ด์ ์ ์ฌ์ฉ๋ ๋ชจ๋ ๊ตฌ์ฑ ์์์ ๋ชจ๋ ํญ๋ชฉ์ด ํฌํจ๋ฉ๋๋ค. ์ฌ๊ธฐ์ ์ถ๋ ฅ์ ์ฌํํ์ง๋ ์๊ฒ ์ง๋ง(์์ฑ ๋น์์๋ ๋จ์ผ ์์ฝ ํจํท์ ๋ํด 1265์ค์ ์ถ๋ ฅ์ด ์์ฑ๋จ) ์ด ์ ๋ณด๋ฅผ ํ์ผ๋ก ๋ฆฌ๋๋ ์ ํ๊ณ ์ฆ๊ฒจ ์ฌ์ฉํ๋ ํธ์ง๊ธฐ์์ ๋ณผ ์ ์์ต๋๋ค.
$ ./waf --run scratch/myfirst > log.out 2>&1
์ ๋ ๊ฐ์ธ์ ์ผ๋ก ๋ฌธ์ ๊ฐ ์๊ณ ์ด๋์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋์ง ์ ํ ์ ์ ์์ ๋ ๋งค์ฐ ์ฅํฉํ ๋ก๊น ๋ฒ์ ์ ์ฌ์ฉํฉ๋๋ค. ์ค๋จ์ ์ ์ค์ ํ๊ฑฐ๋ ๋๋ฒ๊ฑฐ์์ ์ฝ๋๋ฅผ ๋จ๊ณ๋ณ๋ก ์คํํ์ง ์๊ณ ๋ ๋งค์ฐ ์ฝ๊ฒ ์ฝ๋ ์คํ์ ๋ฐ๋ผ๊ฐ ์ ์์ต๋๋ค. ๋ด๊ฐ ๊ฐ์ฅ ์ข์ํ๋ ํธ์ง๊ธฐ์์ ์ถ๋ ฅ์ ํธ์งํ๊ณ ๋ด๊ฐ ๊ธฐ๋ํ๋ ๊ฒ์ ์ฐพ์๋ณด๊ณ ์์ํ์ง ๋ชปํ ์ผ์ด ์ผ์ด๋๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค. ๋ฌด์์ด ์๋ชป๋๊ณ ์๋์ง์ ๋ํ ์ผ๋ฐ์ ์ธ ์์ด๋์ด๋ฅผ ์ป์ ํ์๋ ๋๋ฒ๊ฑฐ๋ก ๋ฐ์ด๋ค์ด ๋ฌธ์ ๋ฅผ ์์ธํ ์กฐ์ฌํฉ๋๋ค. ์ด๋ฌํ ์ ํ์ ์ถ๋ ฅ์ ์คํฌ๋ฆฝํธ๊ฐ ์์ ํ ์์์น ๋ชปํ ์์ ์ ์ํํ ๋ ํนํ ์ ์ฉํ ์ ์์ต๋๋ค. ๋๋ฒ๊ฑฐ๋ง ์ฌ์ฉํ๋ฉด ํธ์์คํธ๋ฅผ ์์ ํ ๋์น ์ ์์ต๋๋ค. ๋ฑ๋ก์ ํ๋ฉด ๊ทธ๋ฌํ ์ ํ์ด ๋์ ๋๊ฒ ๋ฉ๋๋ค.
5.1.3 ์ฝ๋์ ๋ก๊น ์ถ๊ฐ
์ฌ๋ฌ ๋งคํฌ๋ก์์ ๋ก๊ทธ ๊ตฌ์ฑ ์์๋ฅผ ํธ์ถํ์ฌ ์๋ฎฌ๋ ์ด์ ์ ์ ํญ๋ชฉ์ ์ถ๊ฐํ ์ ์์ต๋๋ค. ์คํฌ๋ฆฝํธ๋ก ํด๋ณด์ myfirst.cc, "clean" ๋๋ ํ ๋ฆฌ์ ์์ต๋๋ค. ์ด ์๋๋ฆฌ์ค์์๋ ๋ก๊น ๊ตฌ์ฑ ์์๋ฅผ ์ ์ํ๋ค๋ ์ ์ ๊ธฐ์ตํ์ธ์.
NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
NS_LOG ํ๊ฒฝ ๋ณ์๋ฅผ ๋ค์ํ ์์ค์์ ์ค์ ํ์ฌ ์ด ๊ตฌ์ฑ ์์์ ๋ชจ๋ ๋ฉ์์ง ๋ก๊น
์ ํ์ฑํํ ์ ์๋ค๋ ๊ฒ์ ์๊ณ ๊ณ์ญ๋๋ค. ๊ณ์ํด์ ์คํฌ๋ฆฝํธ์ ๋ช ๊ฐ์ง ํญ๋ชฉ์ ์ถ๊ฐํด ๋ณด๊ฒ ์ต๋๋ค. ์ ๋ณด ์์ค ๋ฉ์์ง๋ฅผ ๋ก๊ทธ์ ์ถ๊ฐํ๋ ๋ฐ ์ฌ์ฉ๋๋ ๋งคํฌ๋ก๋ NS_LOG_INFO์
๋๋ค. ์คํฌ๋ฆฝํธ๊ฐ "ํ ํด๋ก์ง ์์ฑ" ๋จ๊ณ์ ์์์ ์๋ ค์ฃผ๋ ๋ฉ์์ง(๋
ธ๋ ์์ฑ์ ์์ํ๊ธฐ ์ง์ )๋ฅผ ์ถ๊ฐํด ๋ณด๊ฒ ์ต๋๋ค. ์ด๋ ๋ค์ ์ฝ๋ ์กฐ๊ฐ์์ ์ํ๋ฉ๋๋ค.
์ด์ด ๋ผ. ์คํฌ๋์น/myfirst.cc ์ข์ํ๋ ํธ์ง๊ธฐ์์ ๋ค์ ์ค์ ์ถ๊ฐํ์ธ์.
NS_LOG_INFO ("Creating Topology");
์ค ๋ฐ๋ก ์์,
NodeContainer nodes;
nodes.Create (2);
์ด์ ๋ค์์ ์ฌ์ฉํ์ฌ ์คํฌ๋ฆฝํธ๋ฅผ ์ปดํ์ผํ์ญ์์ค. waf, NS_LOG ๋ณ์๋ฅผ ์ง์ ์ด์ ์ ํ์ฑํํ ๋ก๊น ์คํธ๋ฆผ์ ๋นํ์ฑํํฉ๋๋ค.
$ ./waf
$ export NS_LOG=
ะขะตะฟะตัั, ะตัะปะธ ะฒั ะทะฐะฟัััะธัะต ัะบัะธะฟั,
$ ./waf --run scratch/myfirst
์ฐ๊ฒฐ๋ ๋ก๊น ๊ตฌ์ฑ ์์(FirstScriptExample)๊ฐ ํ์ฑํ๋์ง ์์๊ธฐ ๋๋ฌธ์ ์ ๋ฉ์์ง๊ฐ ํ์๋์ง ์์ต๋๋ค. ๋ฉ์์ง๋ฅผ ๋ณด๋ ค๋ฉด ๋ก๊น ๊ตฌ์ฑ ์์๋ฅผ ํ์ฑํํด์ผ ํฉ๋๋ค. FirstScript์ NS_LOG_INFO๋ณด๋ค ๋ฎ์ง ์์ ์์ค์ ๋๋ค. ์ด ํน์ ๋ก๊น ์์ค์ ๋ณด๋ ค๋ฉด ๋ค์๊ณผ ๊ฐ์ด ํ์ฑํํ๋ฉด ๋ฉ๋๋ค.
$ export NS_LOG=FirstScriptExample=info
์ง๊ธ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋ฉด "Creating Topology"๋ผ๋ ์ ๋ฉ์์ง๊ฐ ํ์๋ฉ๋๋ค.
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.404s)
Creating Topology
Sent 1024 bytes to 10.1.1.2
Received 1024 bytes from 10.1.1.1
Received 1024 bytes from 10.1.1.2
5.2 ๋ช ๋ น์ค ์ธ์ ์ฌ์ฉ
5.2.1 ๊ธฐ๋ณธ ์์ฑ ๊ฐ ์ฌ์ ์
ํธ์ง์ด๋ ๋น๋ ์์ด ns-3 ์คํฌ๋ฆฝํธ์ ๋์์ ๋ณ๊ฒฝํ๋ ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ ๋ช ๋ น์ค ์ธ์๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค. ์ฐ๋ฆฌ๋ ๋ช ๋ น์ค ์ธ์๋ฅผ ๊ตฌ๋ฌธ ๋ถ์ํ๊ณ ๊ฒฐ๊ณผ์ ๋ฐ๋ผ ๋ก์ปฌ ๋ฐ ์ ์ญ ๋ณ์๋ฅผ ์๋์ผ๋ก ์ค์ ํ๋ ๋ฉ์ปค๋์ฆ์ ์ ๊ณตํฉ๋๋ค.
๋ช ๋ น์ค ์ธ์ ์์คํ ์ ์ฌ์ฉํ๋ ์ฒซ ๋ฒ์งธ ๋จ๊ณ๋ ๋ช ๋ น์ค ๊ตฌ๋ฌธ ๋ถ์๊ธฐ๋ฅผ ์ ์ธํ๋ ๊ฒ์ ๋๋ค. ์ด๋ ๋ค์ ์ฝ๋์์์ ๊ฐ์ด (๋ฉ์ธ ํ๋ก๊ทธ๋จ์์) ๋งค์ฐ ์ฝ๊ฒ ์ํํ ์ ์์ต๋๋ค.
int
main (int argc, char *argv[])
{
...
CommandLine cmd;
cmd.Parse (argc, argv);
...
}
์ด ๊ฐ๋จํ ๋ ์ค์ง๋ฆฌ ์ฝ๋ ์กฐ๊ฐ์ ์ค์ ๋ก ๊ทธ ์์ฒด๋ก ๋งค์ฐ ์ ์ฉํฉ๋๋ค. ns-3 ์ ์ญ ๋ณ์ ๋ฐ ์์ฑ ์์คํ ์ ๋ํ ๋ฌธ์ด ์ด๋ฆฝ๋๋ค. ๊ธฐ๋ณธ ์คํฌ๋ฆฝํธ ํจ์์ ์์ ๋ถ๋ถ์ ๋ ์ค์ ์ฝ๋๋ฅผ ์ถ๊ฐํด ๋ณด๊ฒ ์ต๋๋ค. ์คํฌ๋์น/myfirst.cc. ๊ณ์ํด์ ์คํฌ๋ฆฝํธ๋ฅผ ์ปดํ์ผํ๊ณ ์คํํฉ๋๋ค. ์คํ ์ ๋ค์๊ณผ ๊ฐ์ด ๋์ ์์ฒญ์ ํฉ๋๋ค.
$ ./waf --run "scratch/myfirst --PrintHelp"
์ด ๋ช ๋ น์ ๋ฌป์ต๋๋ค. ์ํ ์คํฌ๋ฆฝํธ ์คํ ์คํฌ๋์น/myfirst ๋ช ๋ น์ค ์ธ์๋ฅผ ์ ๋ฌํฉ๋๋ค. โ์ธ์๋์๋ง. ์ธ์๊ฐ ์๋๋ ํ๋ก๊ทธ๋จ์ ๋ํ๋ด๋ ค๋ฉด ๋ฐ์ดํ๊ฐ ํ์ํฉ๋๋ค. ๋ช ๋ น์ค ํ์๊ฐ ์ธ์๋ฅผ ๊ฐ์งํฉ๋๋ค. โ์ธ์๋์๋ง ๋ต๋ณ์ด ํ์๋ฉ๋๋ค.
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.413s)
TcpL4Protocol:TcpStateMachine()
CommandLine:HandleArgument(): Handle arg name=PrintHelp value=
--PrintHelp: Print this help message.
--PrintGroups: Print the list of groups.
--PrintTypeIds: Print all TypeIds.
--PrintGroup=[group]: Print all TypeIds of group.
--PrintAttributes=[typeid]: Print all attributes of typeid.
--PrintGlobals: Print the list of globals.
์ด์ ์ต์ ์ ์ดํด๋ณด์ โ์ธ์ ์์ฑ. ์ฐ๋ฆฌ๋ first.cc ์คํฌ๋ฆฝํธ๋ฅผ ์ฐ๊ตฌํ ๋ ์ด๋ฏธ ns-3 ์์ฑ ์์คํ ์ ์ธ๊ธํ์ต๋๋ค. ์ฐ๋ฆฌ๋ ๋ค์๊ณผ ๊ฐ์ ์ฝ๋ ์ค์ ๋ณด์์ต๋๋ค.
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
๊ทธ๋ฆฌ๊ณ ๊ทธ๋ค์ ๊ทธ๋ ๊ฒ ๋งํ์ด์ ๋ฐ์ดํฐ ์๋ ์ค์ ๋ก๋ ์์ฑ์ ๋๋ค PointToPointNet์ฅ์น. ๋ช ๋ น์ค ์ธ์ ๊ตฌ๋ฌธ ๋ถ์๊ธฐ๋ฅผ ์ฌ์ฉํ์ฌ ์์ฑ์ ์ดํด๋ณด๊ฒ ์ต๋๋ค. PointToPointNet์ฅ์น. ๋์๋ง ๋ชฉ๋ก์๋ ์ฐ๋ฆฌ๊ฐ ์ ๊ณตํด์ผ ํ ์ฌํญ์ด ๋์ ์์ต๋๋ค. ์ ํ ID. ๊ด์ฌ ์๋ ์์ฑ์ด ์ํ๋ ํด๋์ค์ ์ด๋ฆ์ ๋๋ค. ์ฐ๋ฆฌ์ ๊ฒฝ์ฐ์๋ ns3::PointToPointNetDevice. ๊ณ์ ์์ผ๋ก ๋์๊ฐ์, ๋ค์ด๊ฐ์,
$ ./waf --run "scratch/myfirst --PrintAttributes=ns3::PointToPointNetDevice"
์์คํ ์ ์ด ๋คํธ์ํฌ ์ฅ์น ์ ํ์ ๋ชจ๋ ์์ฑ์ ์ธ์ํฉ๋๋ค. ๋ชฉ๋ก์ ์์ฑ ์ค ๋ค์์ด ํ์๋ฉ๋๋ค.
--ns3::PointToPointNetDevice::DataRate=[32768bps]:
The default data rate for point to point links
์ด๋ ๊ฐ์ฒด๋ฅผ ์์ฑํ ๋ ์์คํ ์์ ์ฌ์ฉ๋๋ ๊ธฐ๋ณธ๊ฐ์ ๋๋ค. PointToPointNet์ฅ์น. ๋งค๊ฐ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ์ด ๊ธฐ๋ณธ๊ฐ์ ์ฌ์ ์ํฉ๋๋ค. ์์ฑ ะฒ ํฌ์ธํธํฌํฌ์ธํธ๋์ฐ๋ฏธ ๋ ๋์. ์ง์ ๊ฐ ์ฅ์น ๋ฐ ์ฑ๋์๋ ๊ธฐ๋ณธ๊ฐ์ ์ฌ์ฉํ๊ฒ ์ต๋๋ค. ์ด๋ฅผ ์ํด ํตํ๋ฅผ ์ญ์ ํ๊ฒ ์ต๋๋ค. SetDevice์์ฑ ะธ SetChannel์์ฑ ์ผ๋ก myfirst.cc, ๊นจ๋ํ ๋๋ ํ ๋ฆฌ์ ์์ต๋๋ค.
์ด์ ์คํฌ๋ฆฝํธ๋ ๊ฐ๋จํ ์ ์ธํด์ผ ํฉ๋๋ค. ํฌ์ธํธํฌํฌ์ธํธ๋์ฐ๋ฏธ ์๋ ์์ ๊ฐ์ด ์ค์น ์์ ์ ์ํํ์ง ๋ง์ญ์์ค.
...
NodeContainer nodes;
nodes.Create (2);
PointToPointHelper pointToPoint;
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
...
๊ณ์ํด์ ๋ค์์ ์ฌ์ฉํ์ฌ ์ ์คํฌ๋ฆฝํธ๋ฅผ ์์ฑํ์ญ์์ค. ์ํ (./์ํ) ๋ค์ ๋์๊ฐ์ UDP ์์ฝ ์๋ฒ ์ ํ๋ฆฌ์ผ์ด์ ์ ์ผ๋ถ ํญ๋ชฉ์ ํฌํจํ๊ณ ์๊ฐ ์ ๋์ด๋ฅผ ํฌํจํด ๋ณด๊ฒ ์ต๋๋ค.
$ export 'NS_LOG=UdpEchoServerApplication=level_all|prefix_time'
์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๋ฉด ๋ค์ ์ถ๋ ฅ์ด ํ์๋ฉ๋๋ค.
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.405s)
0s UdpEchoServerApplication:UdpEchoServer()
1s UdpEchoServerApplication:StartApplication()
Sent 1024 bytes to 10.1.1.2
2.25732s Received 1024 bytes from 10.1.1.1
2.25732s Echoing packet
Received 1024 bytes from 10.1.1.2
10s UdpEchoServerApplication:StopApplication()
UdpEchoServerApplication:DoDispose()
UdpEchoServerApplication:~UdpEchoServer()
๋ง์ง๋ง์ผ๋ก ์๋ฎฌ๋ ์ด์ ์๊ฐ์ ์ดํด๋ดค์ ๋, ์์ฝ ์๋ฒ๊ฐ ํจํท์ ์์ ํ ์๊ฐ์ 2,00369์ด์์ต๋๋ค.
2.00369s UdpEchoServerApplication:HandleRead(): Received 1024 bytes from 10.1.1.1
์ด์ ๊ทธ๋ 2.25732์ด ์์ ํจํท์ ๋ฐ์ต๋๋ค. ์ด๋ ๋จ์ํ PointToPointNetDevice ๋ฐ์ดํฐ ์๋๋ฅผ ์ด๋น 32768๋ฉ๊ฐ๋นํธ์์ ๊ธฐ๋ณธ๊ฐ์ธ ์ด๋น XNUMX๋นํธ๋ก ์ฌ์ค์ ํ๊ธฐ ๋๋ฌธ์ ๋๋ค. ๋ช ๋ น์ค์ ์ฌ์ฉํ์ฌ ์๋ก์ด DataRate๋ฅผ ๋์ฒดํ๋ค๋ฉด ์๋ฎฌ๋ ์ด์ ์๋๋ฅผ ๋ค์ ๋์ผ ์ ์์ต๋๋ค. ๋์๋ง ์์์ ํฌํจ๋ ๊ณต์์ ๋ฐ๋ผ ๋ค์๊ณผ ๊ฐ์ด ์ด ์์ ์ ์ํํฉ๋๋ค.
$ ./waf --run "scratch/myfirst --ns3::PointToPointNetDevice::DataRate=5Mbps"
์ด๋ ๊ฒ ํ๋ฉด DataRate ์์ฑ์ด ๊ธฐ๋ณธ๊ฐ์ธ ์ด๋น XNUMX๋ฉ๊ฐ๋นํธ๋ก ๋ฐํ๋ฉ๋๋ค. ๊ฒฐ๊ณผ์ ๋๋๋์? ์คํฌ๋ฆฝํธ์ ์๋ ๋์์ ๋ฐํํ๋ ค๋ฉด ๋น์ ์๋์ ์ผ์นํ๋๋ก ์ฑ๋ ์ง์ฐ๋ ์ค์ ํด์ผ ํฉ๋๋ค. ๋คํธ์ํฌ ์ฅ์น์ ๋ํด ํ๋ ๊ฒ์ฒ๋ผ ๋ช ๋ น์ค ์์คํ ์ ์ฑ๋ ์์ฑ์ ์ธ์ํ๋๋ก ์์ฒญํ ์ ์์ต๋๋ค.
$ ./waf --run "scratch/myfirst --PrintAttributes=ns3::PointToPointChannel"
์ฑ๋ ์ง์ฐ ์์ฑ์ด ๋ค์๊ณผ ๊ฐ์ด ์ค์ ๋์ด ์์์ ์ ์ ์์ต๋๋ค.
--ns3::PointToPointChannel::Delay=[0ns]:
Transmission delay through the channel
๊ทธ๋ฐ ๋ค์ ๋ช ๋ น์ค ์์คํ ์ ํตํด ์ด๋ฌํ ๊ธฐ๋ณธ๊ฐ์ ๋ชจ๋ ์ค์ ํ ์ ์์ต๋๋ค.
$ ./waf --run "scratch/myfirst
--ns3::PointToPointNetDevice::DataRate=5Mbps
--ns3::PointToPointChannel::Delay=2ms"
์ด ๊ฒฝ์ฐ ์คํฌ๋ฆฝํธ์์ DataRate ๋ฐ Delay๋ฅผ ๋ช ์์ ์ผ๋ก ์ค์ ํ์ ๋์ ์๊ฐ์ ๋ณต์ํฉ๋๋ค.
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.417s)
0s UdpEchoServerApplication:UdpEchoServer()
1s UdpEchoServerApplication:StartApplication()
Sent 1024 bytes to 10.1.1.2
2.00369s Received 1024 bytes from 10.1.1.1
2.00369s Echoing packet
Received 1024 bytes from 10.1.1.2
10s UdpEchoServerApplication:StopApplication()
UdpEchoServerApplication:DoDispose()
UdpEchoServerApplication:~UdpEchoServer()
2,00369์ด ํ์ ์๋ฒ์์ ํจํท์ ๋ค์ ์์ ํ๋ค๋ ์ ์ ์ ์ํ์ธ์. ์ค์ ๋ก ์ด ๋ฐฉ๋ฒ์ผ๋ก ์คํฌ๋ฆฝํธ์ ์ฌ์ฉ๋ ์์ฑ์ ์ค์ ํ ์ ์์ต๋๋ค. ํนํ MaxPackets ์์ฑ์ XNUMX์ด ์๋ ๊ฐ์ผ๋ก ์ค์ ํ ์ ์์ต๋๋ค. UDPEchoํด๋ผ์ด์ธํธ.
์ด๋ป๊ฒ ์ฌ์ฉํ์๊ฒ ์ต๋๊น? ์๋ ํด๋ด. ๊ธฐ๋ณธ ์์ฑ ๊ฐ์ ์ฌ์ ์ํ๊ณ ๋ช ์์ ์ผ๋ก ์ค์ ํ ์์น๋ฅผ ์ฃผ์ ์ฒ๋ฆฌํด์ผ ํ๋ค๋ ์ ์ ๊ธฐ์ตํ์ธ์. ์ต๋ ํจํท ์คํฌ๋ฆฝํธ์์. ๊ทธ๋ฐ ๋ค์ ์คํฌ๋ฆฝํธ๋ฅผ ๋ค์ ์์ฑํด์ผ ํฉ๋๋ค. ๋ช ๋ น์ค์ ์ฌ์ฉํ์ฌ ์ ๊ธฐ๋ณธ ์์ฑ ๊ฐ ์ค์ ์ ๋ํ ๊ตฌ๋ฌธ ๋์๋ง์ ์ป์ ์๋ ์์ต๋๋ค. ์ด ๋ด์ฉ์ ์ดํดํ๊ณ ๋๋ฉด ๋ช ๋ น์ค์ ํ์๋๋ ํจํค์ง ์๋ฅผ ์ ์ดํ ์ ์์ต๋๋ค. ์ฐ๋ฆฌ๋ ๊ณต๋ถํ๋ ์ฌ๋๋ค์ด๊ธฐ ๋๋ฌธ์ ๋ช ๋ น์ค์ ๋ค์๊ณผ ๊ฐ์์ผ ํฉ๋๋ค.
$ ./waf --run "scratch/myfirst
--ns3::PointToPointNetDevice::DataRate=5Mbps
--ns3::PointToPointChannel::Delay=2ms
--ns3::UdpEchoClient::MaxPackets=2"
์ด ์์ ์์ ๋ฐ์ํ๋ ์์ฐ์ค๋ฌ์ด ์ง๋ฌธ์ ์ด๋ฌํ ๋ชจ๋ ์์ฑ์ ์กด์ฌ๋ฅผ ์ด๋ป๊ฒ ์ ์ ์๋๋๋ ๊ฒ์ ๋๋ค. ๋ค์ ๋งํ์ง๋ง, ๋ช ๋ น์ค ์์คํ ์๋ ์ด ๋ฌธ์ ์ ๋ํ ๋์๋ง ๊ธฐ๋ฅ์ด ์์ต๋๋ค. ๋ช ๋ น์ค์ ๋์์ ์์ฒญํ๋ฉด ๋ค์์ ํ์ธํด์ผ ํฉ๋๋ค.
$ ./waf --run "scratch/myfirst --PrintHelp"
myfirst [Program Arguments] [General Arguments]
General Arguments:
--PrintGlobals: Print the list of globals.
--PrintGroups: Print the list of groups.
--PrintGroup=[group]: Print all TypeIds of group.
--PrintTypeIds: Print all TypeIds.
--PrintAttributes=[typeid]: Print all attributes of typeid.
--PrintHelp: Print this help message.
"PrintGroups" ์ธ์๋ฅผ ์ ํํ๋ฉด ๋ฑ๋ก๋ ๋ชจ๋ ๊ทธ๋ฃน ๋ชฉ๋ก์ด ํ์๋ฉ๋๋ค. ์ ํ ID. ๊ทธ๋ฃน ์ด๋ฆ์ ์์ค ๋๋ ํฐ๋ฆฌ์ ์๋ ๋ชจ๋ ์ด๋ฆ๊ณผ ์ผ์นํฉ๋๋ค(๋๋ฌธ์๋ก ํ์๋จ). ๋ชจ๋ ์ ๋ณด๋ฅผ ํ ๋ฒ์ ์ธ์ํ๋ฉด ์ฉ๋์ด ๋๋ฌด ์ปค์ง๋ฏ๋ก ์ถ๊ฐ ํํฐ๋ฅผ ์ฌ์ฉํ์ฌ ๊ทธ๋ฃน๋ณ๋ก ์ ๋ณด๋ฅผ ์ธ์ํ ์ ์์ต๋๋ค. ๋ฐ๋ผ์ ๋ค์ ์ง์ ๊ฐ ๋ชจ๋์ ์ด์ ์ ๋ง์ถ๊ฒ ์ต๋๋ค.
./waf --run "scratch/myfirst --PrintGroup=PointToPoint"
TypeIds in group PointToPoint:
ns3::PointToPointChannel
ns3::PointToPointNetDevice
ns3::PointToPointRemoteChannel
ns3::PppHeader
์ฌ๊ธฐ์์ ์์ฑ ์กฐํ์ ์ฌ์ฉ ๊ฐ๋ฅํ TypeId ์ด๋ฆ์ ์ฐพ์ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด
--PrintAttributes = ns3 :: PointToPointChannel
์์ ํ์๋ ๋๋ก.
์์ฑ์ ๋ํด ๋ฐฐ์ฐ๋ ๋ ๋ค๋ฅธ ๋ฐฉ๋ฒ์ Doxygen nsโ3์ ์ด์ฉํ๋ ๊ฒ์ ๋๋ค. ์๋ฎฌ๋ ์ดํฐ์ ๋ฑ๋ก๋ ๋ชจ๋ ์์ฑ์ ๋์ดํ๋ ํ์ด์ง๊ฐ ์์ต๋๋ค.
5.2.2 ์์ ๋ง์ ๋ช ๋ น ์บก์ฒ
๋ช
๋ น์ค ์์คํ
์ ํตํด ์์ ๋ง์ ํํฌ๋ฅผ ์ถ๊ฐํ ์๋ ์์ต๋๋ค. ์ด๋ ๋ช
๋ น์ค ํ์ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ์ฌ ๋งค์ฐ ๊ฐ๋จํ๊ฒ ์ํ๋ฉ๋๋ค. ๊ฐ์ ์ถ๊ฐ.
์ด ๊ธฐ๋ฅ์ ์ฌ์ฉํ์ฌ ์์ ํ ๋ค๋ฅธ ๋ฐฉ์์ผ๋ก ํ์ํ ํจํค์ง ์๋ฅผ ์ง์ ํด ๋ณด๊ฒ ์ต๋๋ค. ๋ผ๋ ์ง์ญ ๋ณ์๋ฅผ ์ถ๊ฐํด ๋ณด๊ฒ ์ต๋๋ค. nํจํท ํจ์๋ก ๋ณธ๊ด. ์ด์ ๊ธฐ๋ณธ ๋์๊ณผ ์ผ์นํ๋๋ก XNUMX๋ก ์ค์ ํ๊ฒ ์ต๋๋ค. ๋ช
๋ น์ค ํ์๊ฐ ์ด ๊ฐ์ ๋ณ๊ฒฝํ ์ ์๋๋ก ํ๋ ค๋ฉด ํ์์์ ์ด ๊ฐ์ ์บก์ฒํด์ผ ํฉ๋๋ค. ํธ์ถ์ ์ถ๊ฐํ๋ฉด ๋ฉ๋๋ค. ๊ฐ์ ์ถ๊ฐ. ๊ฐ์ ์คํฌ๋ฆฝํธ๋ฅผ ๋ฐ๊ฟ๋ณด์ธ์ ์คํฌ๋์น/myfirst.cc ๋ฐ๋ผ์ ๋ค์ ์ฝ๋๋ถํฐ ์์ํ๋ ค๋ฉด
int
main (int argc, char *argv[])
{
uint32_t nPackets = 1;
CommandLine cmd;
cmd.AddValue("nPackets", "Number of packets to echo", nPackets);
cmd.Parse (argc, argv);
...
MaxPackets ์์ฑ์ ์ค์ ํ๋ ์คํฌ๋ฆฝํธ ์ง์ ๊น์ง ์๋๋ก ์คํฌ๋กคํ๊ณ ์๋์ ๊ฐ์ด ์์ 1 ๋์ nPackets ๋ณ์๋ก ์ค์ ๋๋๋ก ๋ณ๊ฒฝํฉ๋๋ค.
echoClient.SetAttribute ("MaxPackets", UintegerValue (nPackets));
์ด์ ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ๊ณ -PrintHelp ์ธ์๋ฅผ ์ ๊ณตํ๋ฉด ์ ์ฌ์ฉ์ ์ธ์๊ฐ ํ์๋ฉ๋๋ค. ๋์๋ง ํ์์ ๋์ด๋ฉ๋๋ค. ์ ๋ ฅํ๋ค,
$ ./waf --run "scratch/myfirst --PrintHelp"
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.403s)
--PrintHelp: Print this help message.
--PrintGroups: Print the list of groups.
--PrintTypeIds: Print all TypeIds.
--PrintGroup=[group]: Print all TypeIds of group.
--PrintAttributes=[typeid]: Print all attributes of typeid.
--PrintGlobals: Print the list of globals.
User Arguments:
--nPackets: Number of packets to echo
์ ์ก๋๋ ํจํท ์๋ฅผ ๋ณ๊ฒฝํ๋ ค๋ฉด ๋ช ๋ น์ค ์ธ์ -nPackets๋ฅผ ์ค์ ํ๋ฉด ๋ฉ๋๋ค.
$ ./waf --run "scratch/myfirst --nPackets=2"
์ด์ ์ด์ ๋ณด์์ผ ํฉ๋๋ค.
Waf: Entering directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/craigdo/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (0.404s)
0s UdpEchoServerApplication:UdpEchoServer()
1s UdpEchoServerApplication:StartApplication()
Sent 1024 bytes to 10.1.1.2
2.25732s Received 1024 bytes from 10.1.1.1
2.25732s Echoing packet
Received 1024 bytes from 10.1.1.2
Sent 1024 bytes to 10.1.1.2
3.25732s Received 1024 bytes from 10.1.1.1
3.25732s Echoing packet
Received 1024 bytes from 10.1.1.2
10s UdpEchoServerApplication:StopApplication()
UdpEchoServerApplication:DoDispose()
UdpEchoServerApplication:~UdpEchoServer()
์ด์ ๋ ๊ฐ์ ํจํค์ง๋ฅผ ๋ณด๋์ต๋๋ค. ๊ฝค ๊ฐ๋จํ์ง ์๋์?
ns-3 ์ฌ์ฉ์๋ก์ ๋ช
๋ น์ค ์ธ์ ์์คํ
์ ์ฌ์ฉํ์ฌ ์ ์ญ ๊ฐ๊ณผ ์์ฑ์ ์กฐ์ํ ์ ์์์ ์ ์ ์์ต๋๋ค. ๋ชจ๋ธ ์์ฑ์์ธ ๊ฒฝ์ฐ ๊ฐ์ฒด์ ์ ํน์ฑ์ ์ถ๊ฐํ ์ ์์ผ๋ฉฐ ๋ช
๋ น์ค ์์คํ
์ ํตํด ์ฌ์ฉ์๊ฐ ํด๋น ํน์ฑ์ ์๋์ผ๋ก ๊ตฌ์ฑํ ์ ์์ต๋๋ค. ์คํฌ๋ฆฝํธ ์์ฑ์๋ผ๋ฉด ์คํฌ๋ฆฝํธ์ ์ ๋ณ์๋ฅผ ์ถ๊ฐํ๊ณ ์ด๋ฅผ ๋ช
๋ น์ค ์์คํ
์ ์ํํ๊ฒ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค.
5.3 ์ถ์ ์์คํ ์ฌ์ฉ
๋ชจ๋ธ๋ง์ ์ ์ฒด ์์ ์ ์ถ๊ฐ ์ฐ๊ตฌ๋ฅผ ์ํ ์ถ๋ ฅ์ ์์ฑํ๋ ๊ฒ์ด๋ฉฐ, ns-3 ์ถ์ ์์คํ ์ ์ด๋ฅผ ์ํ ์ฃผ์ ๋ฉ์ปค๋์ฆ์ ๋๋ค. ns-3์ C++ ํ๋ก๊ทธ๋จ์ด๋ฏ๋ก C++ ํ๋ก๊ทธ๋จ์์ ์ถ๋ ฅ์ ์์ฑํ๋ ํ์ค ๋ฐฉ๋ฒ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
#include <iostream>
...
int main ()
{
...
std::cout << "The value of x is " << x << std::endl;
...
}
๋ก๊น ๋ชจ๋์ ์ฌ์ฉํ์ฌ ์๋ฃจ์ ์ ์ฝ๊ฐ์ ๊ตฌ์กฐ๋ฅผ ์ถ๊ฐํ ์๋ ์์ต๋๋ค. ์ด ์ ๊ทผ ๋ฐฉ์์ผ๋ก ์ธํด ๋ฐ์ํ๋ ์๋ ค์ง ๋ฌธ์ ๊ฐ ๋ง์ด ์์ผ๋ฏ๋ก ์ด๋ฌํ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ์ผ๋ฐ ์ด๋ฒคํธ ์ถ์ ํ์ ์์คํ ์ ์ ๊ณตํ์ต๋๋ค.
ns-3 ์ถ์ ์์คํ ์ ์ฃผ์ ๋ชฉํ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
-
๊ธฐ๋ณธ ์์ ์ ๊ฒฝ์ฐ ์ถ์ ์์คํ ์ ํตํด ์ฌ์ฉ์๋ ์ธ๊ธฐ ์๋ ์์ค์ ๋ํ ํ์ค ์ถ์ ์ ์์ฑํ๊ณ ์ถ์ ์ ์์ฑํ๋ ๊ฐ์ฒด๋ฅผ ์ ํํ ์ ์์ต๋๋ค.
-
์ค๊ธ ์ฌ์ฉ์๋ ์๋ฎฌ๋ ์ดํฐ ์ฝ์ด๋ฅผ ์์ ํ์ง ์๊ณ ๋ ์ถ์ ์์คํ ์ ํ์ฅํ์ฌ ์์ฑ๋ ์ถ๋ ฅ ํ์์ ๋ณ๊ฒฝํ๊ฑฐ๋ ์๋ก์ด ์ถ์ ์์ค๋ฅผ ์ฝ์ ํ ์ ์์ด์ผ ํฉ๋๋ค.
-
๊ณ ๊ธ ์ฌ์ฉ์๋ ์๋ฎฌ๋ ์ดํฐ ์ฝ์ด๋ฅผ ์์ ํ์ฌ ์๋ก์ด ์ถ์ ์์ค์ ์ฑํฌ๋ฅผ ์ถ๊ฐํ ์ ์์ต๋๋ค. ns-3 ์ถ์ ์์คํ ์ ๋ ๋ฆฝ์ ์ธ ์ถ์ ์์ค ๋ฐ ์์ ๊ธฐ์ ์์น๊ณผ ์์ค๋ฅผ ์๋น์์ ์ฐ๊ฒฐํ๊ธฐ ์ํ ํตํฉ ๋ฉ์ปค๋์ฆ์ ๊ธฐ๋ฐ์ผ๋ก ๊ตฌ์ถ๋์์ต๋๋ค.
ns-3 ์ถ์ ์์คํ ์ ๋ ๋ฆฝ์ ์ธ ์ถ์ ์์ค ๋ฐ ์์ ๊ธฐ์ ์์น๊ณผ ์์ค๋ฅผ ์์ ๊ธฐ์ ์ฐ๊ฒฐํ๊ธฐ ์ํ ํตํฉ ๋ฉ์ปค๋์ฆ์ ๊ธฐ๋ฐ์ผ๋ก ๊ตฌ์ถ๋์์ต๋๋ค. ์ถ์ ์์ค๋ ์๋ฎฌ๋ ์ด์ ์์ ๋ฐ์ํ๋ ์ด๋ฒคํธ์ ์ ํธ๋ฅผ ๋ณด๋ด๊ณ ๊ด์ฌ ์๋ ๊ธฐ๋ณธ ๋ฐ์ดํฐ์ ๋ํ ์ก์ธ์ค๋ฅผ ์ ๊ณตํ ์ ์๋ ๊ฐ์ฒด์ ๋๋ค. ์๋ฅผ ๋ค์ด ์ถ์ ์์ค๋ ๋คํธ์ํฌ ์ฅ์น๊ฐ ํจํท์ ์์ ํ ์๊ธฐ๋ฅผ ํ์ํ๊ณ ๊ด์ฌ ์๋ ์ถ์ ์์ ๊ธฐ๊ฐ ํจํท์ ์ฝํ ์ธ ๋ฅผ ์ฌ์ฉํ ์ ์๋๋ก ํ ์ ์์ต๋๋ค.
์ฑํฌ๊ฐ ์ ๊ณตํ๋ ์ ๋ณด๋ฅผ ์ฌ์ฉํ์ฌ ์ค์ ๋ก ์ ์ฉํ ์์ ์ ์ํํ๋ ์ฝ๋์ ๋ค๋ฅธ ๋ถ๋ถ๊ณผ "๊ฒฐํฉ"๋์ง ์๋ ํ ์ถ์ ์์ค ์์ฒด๋ ์ธ๋ชจ๊ฐ ์์ต๋๋ค. ์ถ์ ํ๋ก๊ทธ๋จ์ ์ถ์ ์์ค์์ ์ ๊ณตํ๋ ์ด๋ฒคํธ ๋ฐ ๋ฐ์ดํฐ์ ์๋น์์ ๋๋ค. ์๋ฅผ ๋ค์ด, ์ด์ ์์ ์ถ์ ์์ค์ ์ฐ๊ฒฐ๋ ๊ฒฝ์ฐ ์์ ๋ ํจํท์์ ๊ด์ฌ ์๋ ๋ถ๋ถ์ ์ธ์ํ๋ ์ถ์ ์ฑํฌ๋ฅผ ๋ง๋ค ์ ์์ต๋๋ค.
์ด๋ ๊ฒ ๋ช ์์ ์ผ๋ก ๋ถ๋ฆฌํ๋ ์ด์ ๋ ์ฌ์ฉ์๊ฐ ์๋ฎฌ๋ ์ดํฐ ์ฝ์ด๋ฅผ ํธ์งํ๊ณ ๋ค์ ์ปดํ์ผํ ํ์ ์์ด ์๋ก์ด ์ฑํฌ ์ ํ์ ๊ธฐ์กด ์ถ์ ์์ค์ ์ฐ๊ฒฐํ ์ ์๋๋ก ํ๊ธฐ ์ํ ๊ฒ์ ๋๋ค. ๋ฐ๋ผ์ ์์ ์์์ ์ฌ์ฉ์๋ ์คํฌ๋ฆฝํธ์์ ์ ์ถ์ ํ๋ก๊ทธ๋จ์ ์ ์ํ๊ณ ์ฌ์ฉ์ ์คํฌ๋ฆฝํธ๋ฅผ ํธ์งํ๋ ๊ฒ๋ง์ผ๋ก ์๋ฎฌ๋ ์ด์ ์ฝ์ด์ ์ ์๋ ๊ธฐ์กด ์ถ์ ์์ค์ ์ฐ๊ฒฐํ ์ ์์ต๋๋ค.
์ด ํํ ๋ฆฌ์ผ์์๋ ์ฌ์ ์ ์๋ ์์ค ๋ฐ ์ฑํฌ ์ค ์ผ๋ถ๋ฅผ ์ดํด๋ณด๊ณ ์ฌ์ฉ์ ์ธก์์ ์ต์ํ์ ๋ ธ๋ ฅ์ผ๋ก ๊ตฌ์ฑํ ์ ์๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค. ์ถ์ ๋ค์์คํ์ด์ค ํ์ฅ ๋ฐ ์ ์ถ์ ์์ค ์์ฑ์ ํฌํจํ ๊ณ ๊ธ ์ถ์ ๊ตฌ์ฑ์ ๋ํ ์์ธํ ๋ด์ฉ์ ns-3 ๋งค๋ด์ผ ๋๋ ๋ฐฉ๋ฒ ์น์ ์ ์ฐธ์กฐํ์ธ์.
5.3.1 ASCII ์ถ์
ns-3์ ๊ฐ๋จํ ํจํท ์ถ์ ์ ์ค์ ํ ๋ ์ธ๋ถ ์ ๋ณด๋ฅผ ์ ๊ณตํ๋ ๋ฐ ๋์์ด ๋๋ ๋ฎ์ ์์ค์ ์ถ์ ์์คํ ์ ์ ๊ณตํ๋ ๋์ฐ๋ฏธ ๊ธฐ๋ฅ์ ์ ๊ณตํฉ๋๋ค. ์ด ๊ธฐ๋ฅ์ ํ์ฑํํ๋ฉด ASCII ํ์ผ๋ก ์ถ๋ ฅ์ด ํ์๋ฉ๋๋ค. ns-2 ์ถ๋ ฅ์ ์ต์ํ ์ฌ๋๋ค์๊ฒ ์ด๋ฌํ ์ ํ์ ์ถ์ ์ ๋ค์๊ณผ ์ ์ฌํฉ๋๋ค. out.tr, ์ด๋ ๋ง์ ์คํฌ๋ฆฝํธ์ ์ํด ์์ฑ๋ฉ๋๋ค.
๋ณธ๋ก ์ผ๋ก ๋์๊ฐ์ ์คํฌ๋์น/myfirst.cc ์คํฌ๋ฆฝํธ์ ์ผ๋ถ ASCII ์ถ์ ๊ฒฐ๊ณผ๋ฅผ ์ถ๊ฐํด ๋ณด๊ฒ ์ต๋๋ค. ํตํ ์ง์ Simulator :: Run ()
, ๋ค์ ์ฝ๋ ์ค์ ์ถ๊ฐํฉ๋๋ค.
AsciiTraceHelper ascii;
pointToPoint.EnableAsciiAll (ascii.CreateFileStream ("myfirst.tr"));
๋ค๋ฅธ ๋ง์ ns-3 ๊ด์ฉ๊ตฌ์ ๋ง์ฐฌ๊ฐ์ง๋ก ์ด ์ฝ๋๋ ๋์ฐ๋ฏธ ๊ฐ์ฒด๋ฅผ ์ฌ์ฉํ์ฌ ASCII ์ถ์ ์ ์์ฑํฉ๋๋ค. ๋ ๋ฒ์งธ ์ค์๋ ๋ ๊ฐ์ ์ค์ฒฉ๋ ๋ฉ์๋ ํธ์ถ์ด ํฌํจ๋์ด ์์ต๋๋ค. "๋ด๋ถ" ๋ฐฉ๋ฒ ์์ฑํ์ผ์คํธ๋ฆผ() ์ต๋ช ๊ฐ์ฒด ๊ด์ฉ๊ตฌ๋ฅผ ์ฌ์ฉํ์ฌ ์คํ์ ๊ฐ์ฒด ์ด๋ฆ ์์ด ํ์ผ ์คํธ๋ฆผ ๊ฐ์ฒด๋ฅผ ์์ฑํ๊ณ ์ด๋ฅผ ํธ์ถ๋ ๋ฉ์๋์ ์ ๋ฌํฉ๋๋ค. ์์ผ๋ก ์ด์ ๋ํด ๋ ์์ธํ ์ค๋ช ํ๊ฒ ์ง๋ง, ์ด ์์ ์์ ์์์ผ ํ ๊ฒ์ ๋ค์๊ณผ ๊ฐ์ ํ์ผ์ ๋ํ๋ด๋ ๊ฐ์ฒด๋ฅผ ์์ฑํ๋ค๋ ๊ฒ์ ๋๋ค. myfirst.tr ns-3์ผ๋ก ์ ์กํฉ๋๋ค. ์ฐ๋ฆฌ๋ ์์ฑ๋ ๊ฐ์ฒด๋ฅผ ์ ์ฒด ์๋ช ๋์ ๊ด๋ฆฌํ๋๋ก ns-3์ ๋งก๊น๋๋ค. ๊ทธ ๋์ C++ ์คํธ๋ฆผ ๊ฐ์ฒด ๋ณต์ฌ ์์ฑ์์ ๊ด๋ จ๋ ๊ฑฐ์ ์๋ ค์ง์ง ์์(์๋์ ์ธ) ์ ํ์ผ๋ก ์ธํด ๋ฐ์ํ๋ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๋ค.
์ธ๋ถ ํตํ AsciiAll ํ์ฑํ() ๋ชจ๋ ์ง์ ๊ฐ ์ฅ์น ์ฐ๊ฒฐ์ ๋ํ ์๋ฎฌ๋ ์ด์ ์ ASCII ์ถ์ ์ ํฌํจํ๊ณ (์ง์ ๋) ์ถ์ ์์ ๊ธฐ๊ฐ ํจํท ์ด๋ ์ ๋ณด๋ฅผ ASCII ํ์์ผ๋ก ๊ธฐ๋กํ๋๋ก ๋ณด์กฐ์์๊ฒ ์๋ฆฝ๋๋ค.
ns-2์ ์ต์ํ ์ฌ๋๋ค์๊ฒ ์ถ์ ๋ ์ด๋ฒคํธ๋ ์ด๋ฒคํธ "+", "-", "d" ๋ฐ "r"์ ๊ธฐ๋กํ๋ ์๋ ค์ง ์ถ์ ์ ๊ณผ ๋์ผํฉ๋๋ค.
์ด์ ์คํฌ๋ฆฝํธ๋ฅผ ๋น๋ํ๊ณ ๋ช
๋ น์ค์์ ์คํํ ์ ์์ต๋๋ค.
$ ./waf --run scratch/myfirst
์ด์ ๊ณผ ๋ง์ฐฌ๊ฐ์ง๋ก Waf์์ ์ฌ๋ฌ ๋ฉ์์ง๊ฐ ํ์๋๊ณ ์คํ ์ค์ธ ํ๋ก๊ทธ๋จ์ ์ผ๋ถ ๋ฉ์์ง์ ํจ๊ป "'๋น๋'๊ฐ ์ฑ๊ณต์ ์ผ๋ก ์๋ฃ๋์์ต๋๋ค"๋ผ๋ ๋ฉ์์ง๊ฐ ํ์๋ฉ๋๋ค.
์คํ ์ ํ๋ก๊ทธ๋จ์ ๋ค์๊ณผ ๊ฐ์ ํ์ผ์ ์์ฑํฉ๋๋ค. myfirst.tr. ์ํ์ ํน์ฑ์ ์ํ, ๊ธฐ๋ณธ์ ์ผ๋ก ํ์ผ์ ๋ก์ปฌ ๋๋ ํฐ๋ฆฌ๊ฐ ์๋ ์ ์ฅ์์ ์ต์์ ๋๋ ํฐ๋ฆฌ์ ์์ฑ๋ฉ๋๋ค. ์ถ์ ์ด ์ ์ฅ๋๋ ๊ฒฝ๋ก๋ฅผ ๋ณ๊ฒฝํ๋ ค๋ฉด Waf ๋งค๊ฐ๋ณ์๋ฅผ ์ฌ์ฉํ์ฌ ์ง์ ํ ์ ์์ต๋๋ค. --cwd
. ์์ง ์ด ์์
์ ์ํํ์ง ์์์ผ๋ฏ๋ก ์ฆ๊ฒจ ์ฌ์ฉํ๋ ํธ์ง๊ธฐ์์ ASCII ์ถ์ ํ์ผ myfirst.tr์ ๋ณด๋ ค๋ฉด ์ ์ฅ์์ ์ต์์ ๋๋ ํฐ๋ฆฌ๋ก ์ด๋ํด์ผ ํฉ๋๋ค.
ASCII ์ถ์ ๊ตฌ๋ฌธ ๋ถ์
์๋นํ ์กฐ๋ฐํ ํํ๋ก ๋ง์ ์ ๋ณด๊ฐ ์์ง๋ง ๊ฐ์ฅ ๋จผ์ ์ฃผ๋ชฉํด์ผ ํ ๊ฒ์ ํ์ผ์ด ๊ฐ๋ณ ์ค๋ก ๊ตฌ์ฑ๋์ด ์๋ค๋ ๊ฒ์ ๋๋ค. ์ด๋ ๋ณด๊ธฐ ์ฐฝ์ ๋ ๋๊ฒ ํ์ฅํ๋ฉด ๋ช ํํ๊ฒ ํ์๋ฉ๋๋ค.
ํ์ผ์ ๊ฐ ์ค์ ์ถ์ ์ด๋ฒคํธ์ ํด๋นํฉ๋๋ค. ์ด ๊ฒฝ์ฐ ์๋ฎฌ๋ ์ด์ ์ ๊ฐ ์ง์ ๊ฐ ๋คํธ์ํฌ ์ฅ์น์ ์๋ ์ ์ก ๋๊ธฐ์ด์ ์ด๋ฒคํธ๋ฅผ ์ถ์ ํฉ๋๋ค. ์ ์ก ํ๋ ์ง์ ๊ฐ ๋งํฌ๋ฅผ ์ํด ๊ฐ ํจํท์ด ํต๊ณผํด์ผ ํ๋ ํ์ ๋๋ค. ์ถ์ ํ์ผ์ ๊ฐ ์ค์ ๋จ์ผ ๋ฌธ์๋ก ์์ํ๊ณ ๊ทธ ๋ค์ ๊ณต๋ฐฑ์ด ์์ต๋๋ค. ์ด ๊ธฐํธ์ ์๋ฏธ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
+: ์ฅ์น ๋๊ธฐ์ด์์ ๋๊ธฐ์ด ์์
์ด ๋ฐ์ํ์ต๋๋ค.
-: ์ฅ์น ํ์์ ์์ ๊ฒ์ ์์
์ด ๋ฐ์ํ์ต๋๋ค.
d: ์ผ๋ฐ์ ์ผ๋ก ๋๊ธฐ์ด์ด ๊ฐ๋ ์ฐจ์ ํจํท์ด ์ญ์ ๋์์ต๋๋ค.
r: ํจํท์ด ๋คํธ์ํฌ ์ฅ์น์ ์ํด ์์ ๋์์ต๋๋ค.
์ถ์ ํ์ผ์ ์ฒซ ๋ฒ์งธ ์ค์ ์์ธํ ์ดํด๋ณด๊ฒ ์ต๋๋ค. ๋ช ํ์ฑ์ ์ํด ๋ค์ฌ์ฐ๊ธฐ๋ฅผ ์ฌ์ฉํ์ฌ ์ฌ๋ฌ ๋ถ๋ถ์ผ๋ก ๋๋๊ณ ์ผ์ชฝ์ ์ค ๋ฒํธ๋ฅผ ํ์ํ๊ฒ ์ต๋๋ค.
0 +
1 2
2 /NodeList/0/DeviceList/0/$ns3::PointToPointNetDevice/TxQueue/Enqueue
3 ns3::PppHeader (
4 Point-to-Point Protocol: IP (0x0021))
6 ns3::Ipv4Header (
7 tos 0x0 ttl 64 id 0 protocol 17 offset 0 flags [none]
8 length: 1052 10.1.1.1 > 10.1.1.2)
9 ns3::UdpHeader (
10 length: 1032 49153 > 9)
11 Payload (size=1024)
์ด ํ์ฅ ์ถ์ ์ด๋ฒคํธ์ ์ฒซ ๋ฒ์งธ ์น์ (๋ผ์ธ 0)์ ์์ ์ ๋๋ค. ์ฌ๊ธฐ์ + ๊ธฐํธ๊ฐ ์๋๋ฐ ์ด๋ ์ ์ก์ ์ํ ๋๊ธฐ์ด ์์ ์ ํด๋นํฉ๋๋ค. ๋ ๋ฒ์งธ ์น์ (๋ผ์ธ 1)์ ์ด ๋จ์๋ก ํํ๋๋ ์๋ฎฌ๋ ์ด์ ์๊ฐ์ ๋๋ค. ์ฐ๋ฆฌ๊ฐ ์์ฒญํ ๋ด์ฉ์ ๊ธฐ์ตํ์ค ๊ฒ์ ๋๋ค. UdpEchoClient์์ฉ ํ๋ก๊ทธ๋จ XNUMX์ด ์์ ํจํท ์ ์ก์ ์์ํฉ๋๋ค. ์ฌ๊ธฐ์ ์ฐ๋ฆฌ๋ ์ด๊ฒ์ด ์ค์ ๋ก ์ผ์ด๋๊ณ ์๋ค๋ ํ์ธ์ ๋ด ๋๋ค.
์ถ์ ์์ ์ ๋ค์ ์น์ (2ํ)์์๋ ์ด ์ด๋ฒคํธ(๋ค์์คํ์ด์ค ์ถ์ ์ ๋ํ๋)๋ฅผ ์์ฑํ ์ถ์ ์์ค๋ฅผ ๋ณด์ฌ์ค๋๋ค. ์ถ์ ๋ค์์คํ์ด์ค๋ ํ์ผ ์์คํ ๋ค์์คํ์ด์ค์ ๋น์ทํ๊ฒ ์๊ฐํ ์ ์์ต๋๋ค. ๋ค์์คํ์ด์ค์ ๋ฃจํธ๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. ๋ ธ๋ ๋ชฉ๋ก. ์ด๋ ๊ธฐ๋ณธ ns-3 ์ฝ๋์์ ๊ด๋ฆฌํ๋ ์ปจํ ์ด๋์ ํด๋นํฉ๋๋ค. ์ฌ๊ธฐ์๋ ์คํฌ๋ฆฝํธ์์ ์์ฑ๋ ๋ชจ๋ ๋ ธ๋๊ฐ ํฌํจ๋ฉ๋๋ค. ํ์ผ ์์คํ ์ ๋ฃจํธ์ ๋๋ ํฐ๋ฆฌ๊ฐ ์์ ์ ์๋ ๊ฒ์ฒ๋ผ ๋ ธ๋ ๋ชฉ๋ก ์ฐ๋ฆฌ๋ ๋ง์ ๋ ธ๋๋ฅผ ๊ฐ์ง ์ ์์ต๋๋ค. ๋ฐ๋ผ์ /NodeList/0 ํ์ ์ผ๋ฐ์ ์ผ๋ก "๋ ธ๋ 0"์ผ๋ก ์๊ฐ๋๋ NodeList์ null ๋ ธ๋๋ฅผ ๋ํ๋ ๋๋ค. ๊ฐ ๋ ธ๋์๋ ์ค์น๋ ์ฅ์น ๋ชฉ๋ก์ด ์์ต๋๋ค. ์ด ๋ชฉ๋ก์ ๋ค์์คํ์ด์ค ์์ ์์นํฉ๋๋ค. ์ด ์ถ์ ์ด๋ฒคํธ๊ฐ ๋ค์์์ ๋น๋กฏ๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค. ์ฅ์น ๋ชฉ๋ก/0, ์ด๋ ๋ ธ๋์ ์ค์น๋ null ์ฅ์น์ ๋๋ค.
๋ค์ ํ์ ๋ฌธ์์ด, $ ns3 :: PointToPointNetDevice
, ์ด๋ค ์ฅ์น๊ฐ ์์น 0์ ์๋์ง ์๋ ค์ค๋๋ค. ์ฆ, ๋
ธ๋ XNUMX์ ์ฅ์น ๋ชฉ๋ก์
๋๋ค. XNUMXํ์ ์๋ + ์ฐ์ฐ์ ์ฅ์น์ ์ ์ก ๋๊ธฐ์ด์ ์์๊ฐ ์ถ๊ฐ๋์์์ ์๋ฏธํฉ๋๋ค. ์ด๋ "ํธ๋ ๊ฒฝ๋ก"์ ๋ง์ง๋ง ์ธ๊ทธ๋จผํธ์ ๋ฐ์๋ฉ๋๋ค. TxQueue/์ธํ.
์ถ์ ์ ๋๋จธ์ง ์น์
์ ์๋นํ ์ง๊ด์ ์ด์ด์ผ ํฉ๋๋ค. 3-4ํ์ ํจํท์ด ์ง์ ๊ฐ ํ๋กํ ์ฝ๋ก ์บก์ํ๋์์์ ๋ํ๋
๋๋ค. 5-7ํ์ ํจํท์ IP4 ๋ฒ์ ํค๋๊ฐ ์๊ณ IP ์ฃผ์์์ ์์๋์์์ ๋ณด์ฌ์ค๋๋ค. 10.1.1.1
~์์ํ ๊ฒ์
๋๋ค. 10.1.1.2
. ๋ผ์ธ 8-9๋ ์ด ํจํท์ UDP ํค๋๊ฐ ์์์ ๋ณด์ฌ์ฃผ๊ณ ๋ง์ง๋ง์ผ๋ก ๋ผ์ธ 10์ ํ์ด๋ก๋๊ฐ ์์๋๋ 1024๋ฐ์ดํธ์์ ๋ณด์ฌ์ค๋๋ค.
์ถ์ ํ์ผ์ ๋ค์ ์ค์ ๋์ผํ ํจํท์ด ๋์ผํ ๋ ธ๋์ ์ ์ก ํ์์ ๋น๊ฒจ์ก์์ ๋ณด์ฌ์ค๋๋ค.
์ถ์ ํ์ผ์ ์ธ ๋ฒ์งธ ์ค์ ํจํท์ด ์์ฝ ์๋ฒ ํธ์คํธ์ ๋คํธ์ํฌ ์ฅ์น์์ ์์ ๋์์์ ๋ณด์ฌ์ค๋๋ค. ์๋์ ๊ทธ ์ฌ๊ฑด์ ์ฌํํด ๋์์ต๋๋ค.
0 r
1 2.25732
2 /NodeList/1/DeviceList/0/$ns3::PointToPointNetDevice/MacRx
3 ns3::Ipv4Header (
4 tos 0x0 ttl 64 id 0 protocol 17 offset 0 flags [none]
5 length: 1052 10.1.1.1 > 10.1.1.2)
6 ns3::UdpHeader (
7 length: 1032 49153 > 9)
8 Payload (size=1024)
์ด์ ์ถ์ ์์ ์ r์ด๊ณ ์๋ฎฌ๋ ์ด์ ์๊ฐ์ 2,25732์ด๋ก ๋์ด๋ฌ์ต๋๋ค. ์์ต์๋ฅผ ์ฃผ์ ๊น๊ฒ ๋ฐ๋๋ค๋ฉด ์ด๋ ๋คํธ์ํฌ ์ฅ์น์ DataRate ๋ฐ Link Delay๋ฅผ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ๋์์์ ์๋ฏธํฉ๋๋ค. ์ด ์์ ๋ ์ด์ ์น์ ์์ ๋ณด์๋ฏ์ด ์ต์ํ ๊ฒ์ ๋๋ค.
์ถ์ ์์ค ๋ค์์คํ์ด์ค ํญ๋ชฉ(๋ผ์ธ 2)์ ์ด ์ด๋ฒคํธ๊ฐ ๋ ธ๋ 1(/๋ ธ๋ ๋ชฉ๋ก/1) ํจํท์ ์ถ์ ์์ค(/)์ ์ํด ์์ ๋ฉ๋๋ค.๋งฅ์์์ค). ํ์ผ์ ๋จ์ ์๋ ์ถ์ ์ ๋ณด๋ฉด ํ ํด๋ก์ง ์ ์ฒด์์ ํจํท์ ์ด๋์ ์ถ์ ํ๋ ๊ฒ์ด ์๋นํ ์ฌ์ธ ๊ฒ์ ๋๋ค.
5.3.2 PCAP ์ถ์
ns-3 ์ฅ์น ๋์ฐ๋ฏธ๋ฅผ ์ฌ์ฉํ์ฌ .pcap ํ์์ ์ถ์ ํ์ผ์ ์์ฑํ ์๋ ์์ต๋๋ค. ๋๋ฌธ์์ด pcap (๋ณดํต ์๋ฌธ์๋ก ์์ฑ๋จ)์ ํจํท ์บก์ฒ๋ฅผ ๋ํ๋ด๋ฉฐ ์ค์ ๋ก๋ .pcap ํ์ผ ํ์ ์ ์๋ฅผ ํฌํจํ๋ API์ ๋๋ค. ์ด ํ์์ ์ฝ๊ณ ํ์ํ ์ ์๋ ๊ฐ์ฅ ๋๋ฆฌ ์ฌ์ฉ๋๋ ํ๋ก๊ทธ๋จ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. ์์ด์ด ์คํฌ (์ด์ ์ ๋ถ๋ ๋ ๋ฏธ๋ฌํ). ๊ทธ๋ฌ๋ ์ด ํจํท ํ์์ ์ฌ์ฉํ๋ ํธ๋ํฝ ์ถ์ ๋ถ์๊ธฐ๊ฐ ๋ง์ด ์์ต๋๋ค. ์ฐ๋ฆฌ๋ ์ฌ์ฉ์๊ฐ pcap ์ถ์ ์ ๋ถ์ํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ ๋ค์ํ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ๋๋ก ๊ถ์ฅํฉ๋๋ค. ์ด ํํ ๋ฆฌ์ผ์์๋ ๋ค์์ ์ฌ์ฉํ์ฌ pcap ์ถ์ ์ ๋ณด๋ ๋ฐ ์ค์ ์ ๋ ๊ฒ์ ๋๋ค. TCP ๋คํ.
pcap ์ถ์ ํ์ฑํ๋ ํ ์ค์ ์ฝ๋๋ก ์ํ๋ฉ๋๋ค.
pointToPoint.EnablePcapAll ("myfirst");
๋ฐฉ๊ธ ์ถ๊ฐํ ASCII ์ถ์ ์ฝ๋ ๋ค์ ์ด ์ฝ๋ ์ค์ ๋ถ์ฌ๋ฃ์ผ์ธ์. ์คํฌ๋์น/myfirst.cc. "myfirst.pcap"์ด๋ ์ด์ ์ ์ฌํ ๋ฌธ์์ด์ ์ ๋ฌํ์ง ์๊ณ "myfirst" ๋ฌธ์์ด๋ง ์ ๋ฌํ์ต๋๋ค. ์ด๋ ๋งค๊ฐ๋ณ์๊ฐ ์ ์ฒด ํ์ผ ์ด๋ฆ์ด ์๋ ์ ๋์ฌ์ด๊ธฐ ๋๋ฌธ์ ๋๋ค. ์๋ฎฌ๋ ์ด์ ์ค์ ๋ณด์กฐ์๋ ์ค์ ๋ก ๊ฐ ์ง์ ๊ฐ ์ฅ์น์ ๋ํ ์ถ์ ํ์ผ์ ์์ฑํฉ๋๋ค. ํ์ผ ์ด๋ฆ์ ์ ๋์ฌ, ๋ ธ๋ ๋ฒํธ, ์ฅ์น ๋ฒํธ ๋ฐ ์ ๋ฏธ์ฌ "๋ฅผ ์ฌ์ฉํ์ฌ ๊ตฌ์ฑ๋ฉ๋๋ค.pcap".
์์ ์คํฌ๋ฆฝํธ์ ๊ฒฝ์ฐ "myfirst-0-0.pcap"๊ทธ๋ฆฌ๊ณ "myfirst-1-0.pcap"๋ ๊ฐ๊ฐ ๋ ธ๋ 0-์ฅ์น 0 ๋ฐ ๋ ธ๋ 1-์ฅ์น 0์ ๋ํ pcap ์ถ์ ์ ๋๋ค. pcap ์ถ์ ์ ํ์ฑํํ๋ ์ฝ๋ ์ค์ ์ถ๊ฐํ ํ์๋ ์ผ๋ฐ์ ์ธ ๋ฐฉ๋ฒ์ผ๋ก ์คํฌ๋ฆฝํธ๋ฅผ ์คํํ ์ ์์ต๋๋ค.
$ ./waf --run scratch/myfirst
๋ฐฐํฌํ์ ์ต์์ ๋๋ ํฐ๋ฆฌ๋ฅผ ๋ณด๋ฉด ์ธ ๊ฐ์ ํ์ผ์ด ๋ณด์ผ ๊ฒ์ ๋๋ค: ASCII ์ถ์ ํ์ผ myfirst.tr, ์ด์ ์ ์ฐ๊ตฌํ ํ์ผ myfirst-0-0.pcap ะธ myfirst-1-0.pcap - ๋ฐฉ๊ธ ์์ฑํ ์ pcap ํ์ผ์ ๋๋ค.
tcpdump๋ฅผ ์ฌ์ฉํ์ฌ ์ถ๋ ฅ ์ฝ๊ธฐ
ํ์ฌ pcap ํ์ผ์ ๋ณด๋ ๊ฐ์ฅ ์ฌ์ด ๋ฐฉ๋ฒ์ tcpdump๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋๋ค.
$ tcpdump -nn -tt -r myfirst-0-0.pcap
reading from file myfirst-0-0.pcap, link-type PPP (PPP)
2.000000 IP 10.1.1.1.49153 > 10.1.1.2.9: UDP, length 1024
2.514648 IP 10.1.1.2.9 > 10.1.1.1.49153: UDP, length 1024
tcpdump -nn -tt -r myfirst-1-0.pcap
reading from file myfirst-1-0.pcap, link-type PPP (PPP)
2.257324 IP 10.1.1.1.49153 > 10.1.1.2.9: UDP, length 1024
2.257324 IP 10.1.1.2.9 > 10.1.1.1.49153: UDP, length 1024
๋คํ์์ myfirst-0-0.pcap (ํด๋ผ์ด์ธํธ ์ฅ์น) ์๋ฎฌ๋ ์ด์ 2์ด ํ์ ์์ฝ ํจํท์ด ์ ์ก๋๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค. ๋ ๋ฒ์งธ ๋คํ๋ฅผ ๋ณด๋ฉด (myfirst-1-0.pcap), 2,257324์ด์ ํจํท์ด ์์ ๋๋ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค. ๋ ๋ฒ์งธ ๋คํ์์๋ ํจํท์ด 2.257324์ด์ ๋ฐํ๋๊ณ ๋ง์ง๋ง์ผ๋ก ์ฒซ ๋ฒ์งธ ๋คํ์์ 2.514648์ด์ ํด๋ผ์ด์ธํธ๊ฐ ํจํท์ ๋ค์ ์์ ํ ๊ฒ์ ๋ณผ ์ ์์ต๋๋ค.
Wireshark๋ก ์ถ๋ ฅ ์ฝ๊ธฐ
์ต์ํ์ง ์์ ๊ฒฝ์ฐ ์์ด์ด ์คํฌ, ํ๋ก๊ทธ๋จ๊ณผ ๋ฌธ์๋ฅผ ๋ค์ด๋ก๋ํ ์ ์๋ ์น์ฌ์ดํธ๊ฐ ์์ต๋๋ค:
์ถ์ฒ : habr.com