...

Yes, we can ns-3-simu! - Internet Research Lab.

by user

on
Category: Documents
18

views

Report

Comments

Transcript

Yes, we can ns-3-simu! - Internet Research Lab.
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
.
.
Yes, we can ns-3-simu!
(できる ns-3-simu)
Hajime Tazaki
[email protected]
StarBED / Nebula Developers Workshop 2010 Summer
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
1 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Objective of this tutorial
• Simulator の特徴を知る
• Network Simulator の基本操作
• ns-3-simu の操作を知る
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
2 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
What’s simulator?
• Modeling
=#32>432#)
5#2+80
"#$%&'()
*+,-./$+&0
1#2$3#4
5#6.&7,#0$
(MATLAB)
Linux
• (Network)
Simulation
(ns-{2,3}, opnet,
omnet++)
Concept
OMNeT++
Tossim
• Testbed
(WIDE/Internet2,
Planetlab/ORBIT/StarBED)
• Deployment
Hajime Tazaki (Keio University)
NS-2
=#>?,6.#,#0$
PlanetLab
Network
FlexLab
Cradle
EmuLab
Model- Mesh
Net Testbed
EmStar
Windows
Linux
Windows
Mobile
Embedded
Linux
WSN
Testbed
TinyOS
9/'+#$7)&: )1/'8#$)*72$#,2
ネットワーク研究の
ワークフロー
RTOS
9/'+#$7)&: );</.-/$+&0)1&&.2
!"#$%&'()*+&,-./&0 1&,2$3(45&.5436#$7&6#$&8"39#$:&/;<"$27")3432#)
!
Network Research Work flowa
a
Olaf Landsiedel, et. al. A virtual platform for network
experimentation. VISA ’09. ACM.
ns-3 or die
SNDW, 27th July, 2010
3 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
What’s simulator? (cont.)
Real-time execution
Control level
Condition range
Result realism
Experimentation cost
Ease of use
Simulation
NO?
HIGH
LARGE
LOW?
LOW
HIGH
Real world
YES
LOW
SMALL
HIGH
HIGH
LOW
Emulation
USUALLY
HIGH
LARGE
MEDIUM
MEDIUM
MEDIUM
Table: Comparison of Experiment Techniques 1 *
1
R. Beuran, L.T. Nguyen, T. Miyachi, J. Nakata, K. Chinen, Y. Tan, and Y. Shinoda. QOMB: A wireless network
emulation testbed. In Proceedings of the 28th IEEE conference on Global telecommunications, pp. 2642–2647. IEEE
Press, 2009.
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
4 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
What’s simulator? (cont.)
シミュレータのできる事
• Reproduce-able
同一の実験を「いつも」再現できる
• Control-able
ネットワーク全体の制御が可能
空間状態の操作が用意 (モビリティモデルの実装)
• Debug-able
全ての機能を,同一プロセスで実行
プロトコルデザインツールとして.
• Scale-able 必要機能のみの仮想化により,ネットワーク規模の確
保が可能
• 想像力だけの世界に入り込む
未知の実装世界 (bittorrent on quantam network)
実行が容易でない機能 (UAN: Under-Water Acoustic Network)
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
5 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Recent history (1995-2005)
(from Ns-3 tutorial2 )
• ns-2 became the main choice for research usage. Search of
ACM Digital Library papers citing simulation, 2001-04:
≥ layer 4
= layer 3
≤ layer 2
ns-2
123 (75%)
186 (70%)
114 (43%)
OPNET
30 (18%)
48 (18%)
96 (36%)
QualNet/Glomosim
11 (7%)
31 (12%)
55 (21%)
• Funding for ns-2 development dropped in the early 2000’s
2
Slide from http://typo3.trilogy-project.eu/fileadmin/publications/Other/Lacage-NS3.pdf
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
6 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Recent history(cont.)
What is wrong about ns-2 ?
• Split object model (OTcl and C++) and use of Tcl:
• Doesn’t scale well
• Makes it difficult for students
• Large amount of abstraction at the network layer and below
leads to big discontinuities when transitioning from simulation to
experiment
• Accretion of unmaintained and incompatible models
• Lack of support for creating methodologically sound simulations
• Lack of, and outdated, documentation
• In ns-2, validation really means regression: no documented
validation of the models, outside of TCP
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
7 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Recent history(cont.)
A recurring misconception
• Using ns-2 is actively harmful
3
Slide from http://typo3.trilogy-project.eu/fileadmin/publications/Other/Lacage-NS3.pdf
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
8 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Recent history(cont.)
A recurring misconception
• Using ns-2 is actively harmful
• Simulation is ns-2
3
Slide from http://typo3.trilogy-project.eu/fileadmin/publications/Other/Lacage-NS3.pdf
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
8 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Recent history(cont.)
A recurring misconception
• Using ns-2 is actively harmful
• Simulation is ns-2
Thus, simulation is actively harmful
3
3
Slide from http://typo3.trilogy-project.eu/fileadmin/publications/Other/Lacage-NS3.pdf
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
8 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Where simulator goes?
シミュレータ (NS) の失われた信用の回復
• 車輪の再発明の防止 ⇒ バグ混入防止
• 動作実績のあるコードを積極的に利用
ns-3 にまつわる噂
• ちゃんと使っている人みた事ない (まだ使えない)
• 研究成果の覇権争い
• 所詮ツール作りでしょ?みんな ns-3 じゃなくても何かしら持って
るよ.
• 所詮 ns (-2) でしょ?論文生成ツール?
まぁまぁ…
(Reference: S. Kurkowski, T. Camp, and M. Colagrosso. Manet simulation studies: the incredibles. ACM SIGMOBILE
Mobile Computing and Communications Review, 2005.)
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
9 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Internal of ns-3, and ns-3-simu
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
10 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
What’s ns-3?
複数言語でデバッグする必要なし (Tcl/C++, C++/NED, etc.)
• ns-3 の実体は C++ で書かれたライブラリ
• シミュレーション実行バイナリは C++
• Python による簡易スクリプト記述が可能だが,C++ でも記述可
能 (Python は補助的な目的でのみ利用)
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
11 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
What’s ns-3-simu?
ns-3-simu: Application Binary Emulator
• アプリケーションの
• ポーティング
• ソースコードパッチング
なしで,ns-3 上で実行が可能
• 2010/7/27 現在の実行確認アプリケーション
•
•
•
•
•
•
•
•
•
ping
traceroute
iperf (TCP のみ)
iproute2
zebra (v4/v6, netlink)
ospfd
bgpd
olsr6d (by SFC okada-san)
zebra mndpd (by me)
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
12 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
What’s ns-3-simu? (cont.)
主要パーツ
• Elf Binary Loader
位置非依存バイナリ
(-fPIC, -fPIE) を
dlmopen 風にロード
し,main シンボルを
実行
Instance per
(simulated) node
Application
(e.g. zebra w/ PIE file)
• Function Redirection
socket, open, write
等のシンボルを,
kernel へ届けず ns-3
内処理へリダイレ
クト
Hajime Tazaki (Keio University)
malloc(), sendmsg()
(usual) libc
dlopen ()
+ dlsym("main")
n1
Emulation
malloc(), sendmsg()
n2
override with
weak_alias ()
n10
Simulator
Operating System
Physical Machine
ns-3 or die
SNDW, 27th July, 2010
13 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
What’s ns-3-simu? (cont.)
ほら,これでオレオレワールドへ,アプリケーション (zebra) が実在
.
Zebra Client と TCP 通信の例
..
(gdb) bt
#0 ns3::TcpSocketImpl::RecvFrom ()
#1 0x00007ffff76f6262 in ns3::UnixStreamSocketFd::Recvmsg ()
#2 0x00007ffff76ef018 in ns3::UnixSocketFd::Read ()
#3 0x00007ffff76fda60 in simu_read ()
#4 0x00007ffff5fec8fc in read ()
#5 0x00007ffff64b13a9 in readn ()
#6 0x00007ffff64af5b1 in stream_read ()
#7 0x00007ffff64811f8 in zebra_client_read ()
#8 0x00007ffff64a7c68 in thread_call ()
#9 0x00007ffff648256d in main ()
#10 0x00007ffff772dd6d in ns3::ElfLoaderSmart::LoadAndStartMain ()
#11 0x00007ffff76d2766 in ns3::ProcessManager::StartProcess ()
#12 0x00007ffff76d5984 in ns3::ProcessManager::DoCreateThread ()
#13 0x0000003c73a43750 in ?? () from /lib64/libc.so.6
#14 0x0000000000000000 in ?? ()
-------------ns-3 part (TCP)
-------------(redirected syscall)
(overrided symbol)
-------------zebra
main
-------------ns-3 part
--------------
.
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
14 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Kernel emulation on user-land
さらに…Network Simulation Cradle4
• TCP の再実装はバグの元
• 既存 OS のソースをライブラリ化して,Simulator で使う
Instance per
(simulated) node
Global Symbol Virtualization
Link to shared lib
lib-linux-2.6.26.so
linux-2.6.26
Call as internal func.
e.g. ip6_output()
IP stack in Simulator
(L3)->ForwardUp()
linux-2.6.18
FreeBSD 5.x
OpenBSD 3.x
Kernel Source Code
n1
n2
n10
Simulator
Operating System
Physical Machine
4
Sam Jansen and Anthony McGregor. Simulation with real world network stacks. In WSC ’05: Proceedings of the
37th conference on Winter simulation, pp. 2454–2463. Winter Simulation Conference, 2005.
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
15 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Kernel emulation (cont.)
ns-3-linux (by Mathieu Lacage): Linux net-next カーネルを lib 化.
.
(gdb) bt
#0 tcp_recvmsg ()
#1 0x00007ffff5f2095e
#2 0x00007ffff5da0dd7
#3 __sock_recvmsg ()
#4 sock_recvmsg ()
#5 0x00007ffff5d87817
#6 0x00007ffff5d845e5
#7 0x00007ffff75ccdc2
#8 0x00007ffff75d2e00
#9 0x00007ffff75d2dae
#10 0x00007ffff7565846
#11 0x00007ffff547f9ec
#12 0x00007ffff50513a9
#13 0x00007ffff504f5b1
#14 0x00007ffff50211f8
#15 0x00007ffff5047c68
#16 0x00007ffff502256d
#17 0x00007ffff7534c75
#18 0x00007ffff758dd32
#19 0x00007ffff758bbe4
#20 0x0000003c74206a3a
#21 0x0000003c73ade77d
#22 0x0000000000000000
.
-------------in inet_recvmsg ()
in __sock_recvmsg_nosec ()
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
in
Hajime Tazaki (Keio University)
linux kernel
(net-next-2.6)
-------------ns-3-linux wrapper
--------------
sim_sock_recvmsg ()
sim_sock_recvmsg_forwarder ()
ns3::LinuxSocketFdFactory::Recvmsg ()
ns3::LinuxSocketFd::Recvmsg ()
ns3::LinuxSocketFd::Read ()
simu_read ()
redirected syscall
read ()
overrided symbol
readn ()
-------------stream_read ()
zebra
zebra_client_read ()
thread_call ()
main
main ()
-------------ns3::ProcessManager::DoStartProcess ()
ns3::TaskManager::Trampoline ()
ns-3 part
ns3::PthreadFiberManager::Run ()
start_thread ()
-------------clone ()
?? ()
ns-3 or die
SNDW, 27th July, 2010
16 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
できる ns-3 (本題)
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
17 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
今日のお題目
.1.
examples/tutorial/first.cc を使い,Hello ns-3!
.2.
examples/process/quagga-rocketfuel.cc を使い,RocketFuel
DSet より生成したトポロジで ospfd (zebra-0.95a)
.3.
examples/mpi/simple-distributed.cc と openmpi を使い,分散シ
ミュレーション
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
18 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
インストール
準備
• OS: Fedora 12, 64bit x86_64
• Packages:
gcc, cloog-ppl, cpp, glibc-devel, gcc-c++, libstdc++-devel,
python-devel, git, mercurial, valgrind, openmpi-devel,
glibc-debuginfo, libsqlite3x-devel
• SELinux: disabled
sudo /usr/sbin/setenforce 0
sudo vi /etc/selinux/config
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
19 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
インストール (cont.)
• ns-3-linux branch (by Mathieu Lacage).
http://code.nsnam.org/mathieu/ns-3-linux (2010/7/27)
.
mkdir ~/ns3
cd ~/ns3/
hg clone http://code.nsnam.org/mathieu/ns-3-linux
cd ns-3-linux
make download
make patch
make
.
iproute2 のビルド
.
cd ~/ns3/
wget http://devresources.linuxfoundation.org/dev/iproute2/download/iprout
tar jxf iproute2-2.6.33.tar.bz2
cd iproute2-2.6.33
.make CCOPTS=’-fPIC’ LDFLAGS=-pie
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
20 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
インストール (cont.)
• ns-3-simu 田崎ブランチ.
http://code.nsnam.org/thehajime/ns-3-simu-quagga
(2010/7/27 現在
準備中)
.
ns-3-simu のビルド
..
cd ~/ns3/
hg clone http://code.nsnam.org/thehajime/ns-3-simu-quagga
cd ns-3-simu-quagga
./waf configure --with-linux-stack=../ns-3-linux
./waf --build-quagga
./waf
cp
. ~/ns3/iproute2-2.6.33/ip/ip ./build/debug/
(最後に iproute2 を build/debug 配下へコピーする)
waf: python ベース (…) make のような build コマンド
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
21 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Hello World
お題 1 examples/tutorial/first.cc を使い,Hello ns-3!
.
./waf --run first
Waf: Entering directory ‘/home/tazaki/hgworks/ns-3-simu/build’
Waf: Leaving directory ‘/home/tazaki/hgworks/ns-3-simu/build’
’build’ finished successfully (9.293s)
Sent 1024 bytes to 10.1.1.2
Received 1024 bytes from 10.1.1.1
.Received 1024 bytes from 10.1.1.2
できあがり.
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
22 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Hello World (cont.)
first.cc の中身を覗いてみる.
• C++ によるシミュレーションスクリプト記述
• Python binding もあり,python でも記述可能 (first.py)
API リファレンス (単なる doxygen ですが…)
http://www.nsnam.org/doxygen-release/
.
int
main (int argc, char *argv[])
{
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO);
.
NodeContainer nodes;
nodes.Create (2);
シミュレートするノードの生成.
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
23 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Hello World (cont.)
ネットワークデバイスの作成.(例:P-to-P デバイス)
.
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
.
ns-3.9 サポートデバイスリスト
• tap-bridge
• bridge
•
• csma
• virtual-net-device
• emu (MAC Emulation)
• wifi
• mesh (802.11s)
• wimax
• point-to-point
Hajime Tazaki (Keio University)
Under-water Acoustic Network
ns-3 or die
SNDW, 27th July, 2010
24 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Hello World (cont.)
IP アドレスの設定.
.
InternetStackHelper stack;
stack.Install (nodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces = address.Assign (devices);
.
• InternetStackHelper
ns-3 内に実装されている,IPv4/IPv6 スタック (ARP, ICMP,
rtable 等) の初期化
• Ipv4AddressHelper
固定アドレス割り当て用のヘルパー
これで,基本トポロジの作成は終了.
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
25 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Hello World (cont.)
トポロジ上で動作させるアプリケーション,トラフィックの設定.
.
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
.
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
•
•
•
•
UdpEchoServerHelper: UDP エコーサーバのインストール
echoServer.Install (): ノード 1 へ,サーバのインストール
UdpEchoClientHelper: UDP エコークライアントのインストール
clientApps.Start/Stop(): トラフィック生成開始・終了タイミングの設定
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
26 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Hello World (cont.)
さぁ,シミュレーションを開始します.
.
Simulator::Run ();
Simulator::Destroy ();
return 0;
.}//end of main
.
./waf --run first
Waf: Entering directory ‘/home/tazaki/hgworks/ns-3-simu/build’
Waf: Leaving directory ‘/home/tazaki/hgworks/ns-3-simu/build’
’build’ finished successfully (9.293s)
Sent 1024 bytes to 10.1.1.2
Received 1024 bytes from 10.1.1.1
.Received 1024 bytes from 10.1.1.2
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
27 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
ospfd into ns-3-simu
お題 2 examples/process/quagga-rocketfuel.cc を使い,RocketFuel
DSet より生成したトポロジで ospfd (zebra-0.95a) を動作させる
.
Ptr<TopologyReader> inFile = 0;
TopologyReaderHelper topoHelp;
NodeContainer nodes;
string format ("Rocketfuel");
string input ("examples/topology-read/RocketFuel_toposample_1239_weights.txt");
.
topoHelp.SetFileName(input);
topoHelp.SetFileType(format);
inFile = topoHelp.GetTopologyReader();
if (inFile != 0)
{
nodes = inFile->Read ();
}
•
•
TopologyReaderHelper::Read () で,指定したファイルよりノード・リンク情報を解析
Sprint (AS1239) のデータセットを利用
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
28 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
ospfd into ns-3-simu (cont.)
Rocketfuel よりノードオブジェクト生成.
.
int totlinks = inFile->LinksSize ();
NS_LOG_INFO ("creating node containers");
NodeContainer nc[totlinks];
TopologyReader::ConstLinksIterator iter;
int i = 0;
for ( iter = inFile->LinksBegin (); iter != inFile->LinksEnd (); iter++, i++ )
.
nc[i] = NodeContainer (iter->GetFromNode (), iter->GetToNode ());
TopologyReader::ConstLinksIterator () にて,列挙されるノード情報を元に,Node オブジェク
ト生成
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
29 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
ospfd into ns-3-simu (cont.)
P2P デバイスの設定
.
NetDeviceContainer ndc[totlinks];
PointToPointHelper p2p;
for (int i = 0; i < totlinks; i++)
// p2p.SetChannelAttribute ("Delay", TimeValue(MilliSeconds(weight[i])));
p2p.SetChannelAttribute ("Delay", StringValue ("2ms"));
p2p.SetDeviceAttribute ("DataRate", StringValue ("5Mbps"));
ndc[i] = p2p.Install (nc[i]);
NS_LOG_INFO ("creating ipv4 interfaces");
Ipv4InterfaceContainer ipic[totlinks];
for (int i = 0; i < totlinks; i++)
ipic[i] = address.Assign (ndc[i]);
address.NewNetwork ();
.
p2p.EnablePcapAll ("quagga-rocketfuel");
•
•
•
PointToPointDevice::Install () で,p2p リンクをノードペアに対し追加.
Ipv4AddressHelper::Assign () 作成したリンクに IPv4 アドレスの設定
全 p2p リンクに pcap 出力の設定
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
30 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
ospfd into ns-3-simu (cont.)
Quagga (実は今は zebra-0.95a ベース) の起動
.
.
ProcessManagerHelper processManager;
processManager.Install (nodes);
QuaggaHelper quagga;
quagga.EnableOspf (nodes);
quagga.Install (nodes);
•
QuaggaHelper::Install () で,Zebra 起動と設定 (zebra.conf の 自動生成)
•
QuaggaHelper::EnableOspf () で,OSPF (IPv4) の起動と設定 (ospfd.conf 自動生成)
• 全インタフェースに network area 0 の設定
.
router ospf
network 10.0.0.0/30 area 0
network 10.0.0.12/30 area 0
network 10.0.0.16/30 area 0
(snip)
network 10.0.0.40/30 area 0
network 10.0.0.8/30 area 0
!
.
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
31 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
ospfd into ns-3-simu (cont.)
さぁ,実行しましょう.
.
% sudo ./waf -run quagga-rocketfuel
Rocketfuel topology created with 315 nodes and 972 links (from examples/topology-read/RocketFuel_
creating ip4 addresses
creating node containers
creating net device containers
creating ipv4 interfaces
creating all the route
creating quagga process
TTL: 64
End of experiment
.
実行完了に,Intel i5@ 2.67GHz で 10 分 (60 秒シミュレーション) く
らいかかります
注意:
• 実行に setrlimit (2) を内部で実行する必要があるので,sudo が必
要です.
• 315 ノード分の conf ファイル,stdout/stderr 等のファイルを open
するのに,limit (maxfd=1024) を上げる必要があるため
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
32 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
ospfd into ns-3-simu (cont.)
ログでも見てみる.
.
% less files-0/processes/53513/stdout
2008/04/04 13:45:22 OSPF: ========== OSPF routing table ==========
2008/04/04 13:45:22 OSPF: N 10.0.0.0/30 0.0.0.0 intra-area
10
2008/04/04 13:45:22 OSPF:
-> 0.0.0.0
2008/04/04 13:45:22 OSPF: N 10.0.0.4/30 0.0.0.0 intra-area
10
2008/04/04 13:45:22 OSPF:
-> 0.0.0.0
2008/04/04 13:45:22 OSPF: N 10.0.0.8/30 0.0.0.0 intra-area
10
2008/04/04 13:45:22 OSPF:
-> 0.0.0.0
2008/04/04 13:45:22 OSPF: N 10.0.0.12/30
0.0.0.0 intra-area
2008/04/04 13:45:22 OSPF:
-> 0.0.0.0
2008/04/04 13:45:22 OSPF: N 10.0.0.16/30
0.0.0.0 intra-area
2008/04/04 13:45:22 OSPF:
-> 0.0.0.0
2008/04/04 13:45:22 OSPF: N 10.0.0.20/30
0.0.0.0 intra-area
2008/04/04 13:45:22 OSPF:
-> 0.0.0.0
2008/04/04 13:45:22 OSPF: N 10.0.0.24/30
0.0.0.0 intra-area
2008/04/04 13:45:22 OSPF:
-> 0.0.0.0
.
•
•
•
•
10
10
10
10
files-0: ノード 0 の chroot
processes: ノード内の各プロセスの使用領域 (stdout/stderr)
53513: プロセス ID (ノード内一意)
stdout: 標準出力
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
33 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
ospfd into ns-3-simu (cont.)
Pcap も見てみる.
.
zak-imac:~/hgworks/ns-3-simu% tcpdump -r quagga-rocketfuel-101-4.pcap -n
reading from file quagga-rocketfuel-101-4.pcap, link-type PPP (PPP)
09:00:04.002105 IP 10.0.4.177 > 224.0.0.5: OSPFv2, Hello, length 44
09:00:12.100000 IP 10.0.4.178 > 224.0.0.5: OSPFv2, Hello, length 44
09:00:13.104210 IP 10.0.4.177 > 224.0.0.5: OSPFv2, Hello, length 44
(snip)
09:00:34.104210 IP 10.0.4.178 > 224.0.0.5: OSPFv2, Hello, length 48
09:00:43.002087 IP 10.0.4.177 > 10.0.4.178: OSPFv2, Database Description, length
09:00:43.104217 IP 10.0.4.177 > 224.0.0.5: OSPFv2, Hello, length 48
09:00:44.104210 IP 10.0.4.178 > 224.0.0.5: OSPFv2, Hello, length 48
09:00:48.002087 IP 10.0.4.177 > 10.0.4.178: OSPFv2, Database Description, length
09:00:51.100000 IP 10.0.4.178 > 10.0.4.177: OSPFv2, Database Description, length
(snip)
09:00:51.134125 IP 10.0.4.177 > 10.0.4.178: OSPFv2, Database Description, length
09:00:51.134125 IP 10.0.4.178 > 10.0.4.177: OSPFv2, LS-Request, length 1404
09:00:51.134218 IP 10.0.4.177 > 10.0.4.178: OSPFv2, LS-Request, length 36
09:00:51.136407 IP 10.0.4.178 > 224.0.0.5: OSPFv2, LS-Update, length 136
09:00:51.142637 IP 10.0.4.177 > 224.0.0.6: OSPFv2, LS-Update, length 1372
32
32
32
32
.
動いてます.
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
34 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Distributed Simulation
前述の Rocketfuel トポロジを実行するのに,60 秒のシミュレーション
に要する時間は 10 分.
• 10 倍の時間
• Wi-Fi,移動状態の計算などヘビーな処理のインタフェースでは更
に増大
.
MPI (Message Passing Interface) を利用した分散 CPU 処理により,
シミュレーション時間性能の改善
.
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
35 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Distributed Simulation (cont.)
.
int
main (int argc, char *argv[])
{
LogComponentEnable ("QuaggaRocketfuelMpi", LOG_LEVEL_INFO);
#ifdef NS3_MPI
MpiInterface::Enable (&argc, &argv);
GlobalValue::Bind ("SimulatorImplementationType",
StringValue ("ns3::DistributedSimulatorImpl"));
.
uint32_t systemId = MpiInterface::GetSystemId ();
uint32_t systemCount = MpiInterface::GetSize ();
• MpiInterface::Enable () にて,MPI 利用宣言
• スケジューラを ns3::DistributedSimulatorImpl に変更
• 各ノード毎の処理を,systemId で切り分ける
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
36 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Distributed Simulation (cont.)
.
if (systemId == 1)
{
(snip)
PacketSinkHelper sink = PacketSinkHelper ("ns3::Ipv4RawSocketFactory", dst);
ApplicationContainer apps = sink.Install (randomServerNode);
(snip)
if (systemId == 0)
{
(snip)
ApplicationContainer apps = onoff.Install (clientNodes);
apps.Start (Seconds (1.0));
apps.Stop (Seconds (2.0));
}
.
• systemId が 1 であれば,Traffic の受信ノードとして実行
• systemId が 0 であれば,Traffic の送信ノードとして実行
バースト Traffic のようなヘビーな処理を分散.
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
37 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Distributed Simulation (cont.)
最初に,MPI 用の build が必要です.
.
./waf configure --with-linux-stack=../ns-3-linux --enable-mpi
./waf
build
.
実行します.
.
./usr/lib64/openmpi/bin/mpirun
-np 2 ./waf --run quagga-rocketfuel-mpi
• MPI なし (お題 2): 10 分
• MPI あり (2LP ともに localhost): 41 分
• MPI あり (2LP 別ホスト): (これから実験します)
遅くなってしまっている (MPI の Partitioning によってはこういう事も
ある)
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
38 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Distributed Simulation (cont.)
次に,315 ノード,972 リンクの SPF 計算とか重そうなので,OSPF
プロセスを分散.
.
.
if (systemId == 1)
{
QuaggaHelper quagga;
quagga.EnableOspf (nodes_group1);
quagga.Install (nodes_group1);
if (systemId == 0)
{
QuaggaHelper quagga;
quagga.EnableOspf (nodes_group2);
quagga.Install (nodes_group2);
}
• MPI なし (お題 2): 10 分
• MPI あり (2LP ともに localhost):(これから実験します)
• MPI あり (2LP 別ホスト): (これから実験します)
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
39 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Other Utilities
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
40 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
PyViz
Python ベースのビジュアライザ
• ノードの位置表示 (移動込み)
• パケットの送受信状況の可視化
• 各ノードの状態 (netstat,ifstat 等) の表示
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
41 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
With Anybed ospf (WIDE-BB)
ns-3 のスクリプトは python でも書ける (要 pybindgen)
• ⇒ python ベースの既存スクリプトも流用可能
• Anybed 内の ospfwalk.py
• show ip ospf databae や MIB からトポロジが書ける
.
import ospfwalk
ospfwalk.parse_show_ip_ospf_database_router(
open("./show_ospf_db_r_wide.txt", "r").read(), rlsas, rlsas_dic)
ospfwalk.parse_show_ip_ospf_database_network(
open("./show_ospf_db_n_wide.txt", "r").read(), nlsas, nlsas_dic)
for router in routers:
n = ns3.Node();
internet.Install(n);
nodes.Add(n);
.
のような事も.
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
42 / 43
Intro.
.......
ns-3 Internal
......
Starting ns-3
...
Hello World
......
Zebra-ns3
.......
Dist Simulation
.....
Utilities
...
Resources
• ns-3 Web site: http://www.nsnam.org
• Developer mailing list: http://mailman.isi.edu/
mailman/listinfo/ns-developers
• User mailing list:
http://groups.google.com/group/ns-3-users
• IRC: #ns-3 at irc.freenode.net
• Tutorial: http:
//www.nsnam.org/docs/tutorial/tutorial.html
• Code server: http://code.nsnam.org
• Wiki:
http://www.nsnam.org/wiki/index.php/Main_Page
Hajime Tazaki (Keio University)
ns-3 or die
SNDW, 27th July, 2010
43 / 43
Fly UP