ns-3環境の構築
研究でns3を利用することになったので,仮想環境の設定から,ns3の環境構築までをざっとメモ
仮想環境
- 仮想環境:VirtualBox
- OS:Ubuntu Desktop 18.04(Desktopじゃなくてもいい気がする)
- メモリ数:8GB
- ビデオメモリ:128M
- ストレージ:40GB(多めに取っておいた方がいい)
- CPU:2
- クリップボードの共有:双方向
- ドラッグ&ドロップの共有:双方向
- Insert guest additions cd imageのインストール
- ネットワーク:ホストオンリーアダプタ
- Gitインストール
- vimインストール
- sshインストール
ns-3|環境構築
- 事前準備:Installation - Nsnam
- ns-3コードのインストール
- 方法1:wgetでコードをダウンロード
$ wget https://www.nsnam.org/release/ns-allinone-3.29.tar.bz2
$ tar xjf ns-allinone-3.29.tar.bz2
- 方法2:gitでclone
- 入手先:nsnam / ns-3-allinone · GitLab
$ git clone https://gitlab.com/nsnam/ns-3-allinone
$ cd ns-3-allinone
$ python download.py
- 入手先:nsnam / ns-3-allinone · GitLab
- 方法1:wgetでコードをダウンロード
- リポジトリ作成(Git)
ビルド
- waf設定
$ ./waf clean #wafのビルド設定をリセットする $ ./waf configure --build-profile=debug --enable-examples --enable-tests --out=build/debug
- wafのビルド設定の確認
$ ./waf --check-profile #プロファイルの設定確認(debug, optimized, release) $ ./waf --check-config #ns3の設定全般を表示(オプションの有無)
- wafでビルド
$ ./waf (build) #省略可能
- テストコード
$ ./test.py
- HelloWorld(簡易スクリプト実行)
$ ./waf --run hello-simulator
- 自作スクリプトの実行
$ ./waf $ ./waf --run scratch/<スクリプト名> #scratchディレクトリ配下に保存
ns-3|コマンド
- wafのオプション確認
$ ./waf --help
NetAnim3.108
- サンプル(ns-3.29/src/netanim/examples/dumbbell-animation.cc)をビルド
$ ./waf --run "dumbbell-animation --nLeftLeaf=5 --nRightLeaf=5 --animFile=dumbbell.xml"
- netanim-3.108ディレクトリ移動(ns-allinone-3.29に同封されている)
$ cd workspace/ns-allinone-3.29/netanim-3.108
- NetAnim起動
$ ./NetAnim
- ファイルボタンをクリックし,XMLトレースファイルを選択
ns-3|リンクまとめ
- 公式サイト:ns-3 | a discrete-event network simulator for internet systems
- 事前準備(Ubuntu環境):Installation - Nsnam
- チュートリアル、マニュアル、API、ライブラリ:Documentation | ns-3
- APIドキュメント:ns-3: ns-3 Documentation
- NetAnim:NetAnim 3.108 - Nsnam
OFSwitch13|設定
ns-3へOpenFlow1.3を利用するためのモジュールを追加
- 事前準備
$ sudo apt-get install build-essential gcc g++ python git mercurial unzip cmake $ sudo apt-get install pkg-config autoconf libtool libboost-dev
- OFSwitch13モジュール(ofswitch13)のダウンロード
$ cd ns-3.29/src $ git clone --recurse-submodules https://github.com/ljerezchaves/ofswitch13.git
- ofswitch13を最新に変更
$ cd ofswitch13 $ git checkout 4.0.0 && git submodule update --recursive
- モジュールのコンパイル(静的ライブラリへ)
$ cd lib/ofsoftswitch13 $ ./boot.sh $ ./configure --enable-ns3-lib $ make
- ofsoftswitch13を利用するために、ns-3の一部モジュールに受信部を追加(CsmaNetDevice, VirtualNetDevice)
$ cd ../../../../ $ patch -p1 < src/ofswitch13/utils/ofswitch13-src-3_29.patch $ patch -p1 < src/ofswitch13/utils/ofswitch13-doc-3_29.patch
- ns-3の設定確認
$ ./waf configure
- ns-3ビルド
$ ./waf