# sns3 安裝 若是在虛擬機上安裝,至少請給25G的空間,不然有可能會裝到一半沒空間。 ## 安裝Bake Bake是可以簡化ns3下載及安裝的工具,並且能夠擴充模組成sns3。 先把Bake clone下來: ``` $ git clone https://gitlab.com/nsnam/bake ``` 查看目前的位置: ``` $ pwd //沒意外的話是 "/home/主機名" ``` 將剛剛的位置加入PATH: ``` $ export BAKE_HOME=`pwd`/bake // `pwd`替換成剛剛查到的位置 $ export PATH=$PATH:$BAKE_HOME $ export PYTHONPATH=$PYTHONPATH:$BAKE_HOME ``` 檢查PATH是否有設定正確: ``` $ echo $BAKE_HOME ``` 為了擴充sns3模組,要先在bake裡設定,告訴bake哪邊可下載 ``` $ cd bake $ mkdir contrib $ ls bake bakeconf.xml bake.py build contrib doc examples generate-binary.py test TODO ``` 在contrib資料夾新增一個檔案"sns3.xml": ``` $ cd contrib $ nano sns3.xml 將以下內容貼進去sns3.xml ``` sns3.xml: ```xml= <configuration> <modules> <module name="sns3-satellite" type="ns-contrib" min_version="ns-3.29"> <source type="git"> <attribute name="url" value="https://github.com/sns3/sns3-satellite.git"/> <attribute name="module_directory" value="satellite"/> </source> <build type="none"> </build> </module> <module name="sns3-stats" type="ns-contrib" min_version="ns-3.29"> <source type="git"> <attribute name="url" value="https://github.com/sns3/stats.git"/> <attribute name="module_directory" value="magister-stats"/> </source> <build type="none"> </build> </module> <module name="sns3-traffic" type="ns-contrib" min_version="ns-3.29"> <source type="git"> <attribute name="url" value="https://github.com/sns3/traffic.git" /> <attribute name="module_directory" value="traffic"/> </source> <build type="none"> </build> </module> </modules> </configuration> ``` 如果有默認的bake檔案,要先清掉: ``` $ rm bakefile.xml ``` # 安裝sns3 接下來可以告訴bake你要安裝sns3了 (ns3 + sns3-satellite module): ``` $ ./bake.py configure -e ns-3.29 -e sns3-satellite -e sns3-stats -e sns3-traffic ``` 檢查有沒有東西還沒有裝好,下check指令後發現有miss的就把它裝起來 ``` $ ./bake.py show $ ./bake.py check ``` 像我的話是有裝: (看你自己缺啥) ``` $ sudo apt-get install cmake $ sudo apt-get install mercurial $ pip3 install setuptools ``` 都確認裝完以後就可以deploy(應該要蠻久的): ``` $ ./bake.py deploy ``` 去下載衛星模組: ``` $cd source/ns-3.29/contrib/satellite $git submodule update --init ``` 以上SNS3 安裝及初始化完成 檢查是否成功: ``` ./waf --run hello-simulator ``` 如果有跑出"Hello Simulator"就代表成功了