NS3 Installation on OSX 10.12 Using Bake tool By: Adil A Alsuhaim Updated: June 29, 2017 The way I installed ns-3.26 on Mac successfully is by using the Bake tool.
General Pre-requisites : 1.
Install xcode command line tools. If you have already done that, you can skip it. You can do that by typing in the terminal xcode-select –install
2. Download MacPorts form http://www.macports.org Make sure your $PATH includes /opt/local/bin which is where MacPort’s command, port, is installed. It might be something different. But make sure MacPorts is correctly installed by typing port in the terminal. 3. Install HomeBrew tool (http://homebrew.sh) by simply using the command they provide (uses Ruby, which I believe is installed by xcode) /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 4. Install Mercurial using MacPorts using sudo port install mercurial
Now we will download pre-requisites for NS3 using Bake tool: 1. Download the bake tool using Mercurial command, hg, as follows: hg clone http://code.nsnam.org/bake The NS3 advises to add bake to your path. 2. Use the bake tool to check for pre-requisites: bake.py check On a fresh Mac OSX 10.12 (Sierra), you're probably going to be missing the following. This is what a CVS, Bazaar, Unrar tool, 7z data compression utility, XZ data compression utility, cMake and autoreconf 3. We will use MacPorts & HomeBrew to install the required packages as follows: • Install CVS: o sudo port install cvs o You can run ./bake.py check to see that CVS is no longer missing. • Install bazaar o brew install bzr o For some reason, “bake.py check” doesn’t like MacPort’s Bazaar. If you have issues installing something with MacPorts, try to do it with HomeBrew instead or vice versa.
•
• •
Install rar/7zip/xz tools using HomeBrew o brew install unrar o brew install p7zip o brew install xz Install cMake o brew install cMake Install Autoconf o brew install autoconf
4. Tell bake took what components do you want to install. In my case, I want ns-3.26. ./bake.py configure –e ns-3.26 This basically creates an XML file with your configuration 5. Now we want to check more pre-requisites for NS3 (I needed to have Python Binding because I needed to use Python Visualization (PyViz), which is an online visualization tool (you visualize your simulation as it runs, as opposed to NetAnim, which visualizes the simulation offline, or retrospectively (from an XML file using ns3::AnimationInterface) To run the check, run ./bake.py show In my case, I got the following missing pygoocanvas, pygraphviz, python-dev and qt4 Qt4, not Qt5 is needed for NetAnim. However, don’t waste your time downloading Qt4 from Qt’s website. OSX Sierra does not support. I could not even build Qt4 from sources on Sierra. What I used is HomeBrew, which applies a patch to Qt4 and then installs it successfully for OSX El-Capitan and Sierra!
OPTIONAL : Installing visualization tools pre-requisutes •
To install pygoocanvas, use MacPorts. This will depends on which version of Python do you have installed. I believe there are issues with Python3, so I am using Python2.7 o sudo port install py27-goocanvas o You should run ./bake.py show to see that pygoocanvas is now “OK”
•
To install pygraphviz, use MacPorts. o sudo port install py27-pygraphviz o You should run ./bake.py show to see that pygraphviz is now “OK”
•
If you have issues with Python version, you may run: o port select python Which will show you available Python on your system. You may get something like this Available for python: None (active) Python26-apple Python27 Python27-apple So I believe you can select which one you want to use. I believe I have installed python for MacPorts, and so I can choose python27 (as opposed to python27-apple) sudo port select python python27
•
I could not get “python-dev” requirement to be satisfied, but I installed ns3 and got what I needed installed with no issues.
•
To install Qt4 (which is needed to build NetAnim) on OSX Sierra you will need to use HomeBrew. You can check if you have Qt installed by running “qmake” or “qmake --version” to see what version. I used the following formula. o brew install cartr/qt4/qt-legacy-formula o Note that there was an older formula to do this “brew install cartr/qt4/qt”, which is now deprecated. This will download Qt4.8.7 and then applies a patch for your OSX version. It will apply the ElCapitan patch, which works for Sierra, I believe. Run ./bake.py show to show Qt4 dependency. Notice that it may show that it is “missing”, but will also tell you that Qt is Enabled. You can check by running qmake --version
Build NS3 using Bake tool Now we simply download and build ns3 using the bake tool as follows: ./bake.py download ./bake.py build or simply, you can do this in one go and type ./bake.py deploy You can now run ./waf configure if you see that PyViz is enabled good! Otherwise, you might need to do a little “trick”
Building NetAnim 3.107 and a PyViz trick! •
• • • • •
•
Once you installed Qt4, you can now build NetAnim 3.107 with Qt4. Go to the source directory of NetAnim and build it with make (this will use qmake for Qt4) o cd netanim-3.107 o make If this did not work, consider building NetAnim with the command: o make clean o qmake NetAnim.pro If NetAnim did not build correctly, it might be because you are using Qt5, so check which qmake does your system point to. Check Qt4 version by typing: o qmake –version If the version is Qt4.x, go ahead and build NetAnim. Otherwise, check where your qmake file is by typing: o which qmake You will get the location of your qmake file, which is likely something like this: o /usr/bin/qmake If you know where the qmake file for Qt4 is, make sure your system look in that directory first. You can do that by modifying your $PATH environment variable. First check your $PATH environment variables with the command: o echo $PATH The result will be something like this: /opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11 /bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
o
• • • •
• •
Notice that your system searches these directories in order for any command you type in terminal, so /opt/local/bin is checked first, then opt/local/sbin and so on. o We want to make sure the qmake for Qt4 is searched first if we want to build NetAnim with Qt4. Qt4 installed by HomeBrew installs will be placed in this directory: o /usr/local/Cellar/qt@4/ And the qmake for Qt4 is will be in the directory o /usr/local/Cellar/qt@4/4.8.7_1/bin We will add this directory to $PATH so that the system searches it first by typing: o export PATH=/usr/local/Cellar/qt@4/4.8.7_1/bin:$PATH We can check this again by typing echo $PATH to get: /usr/local/Cellar/qt@4/4.8.7_1/bin/opt/local/bin:/opt/local/sbin:/usr/l ocal/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks /Mono.framework/Versions/Current/Commands Notice that our Qt4 directory is searched first! Alternatively, you may choose to create a symbolic link to the qmake executable in /usr/local/bin and avoid adding the directory to $PATH so that you do not end up with a large $PATH variable that can be hard to read. To create a symbolic link, we type: o o
•
ln -s /usr/local/Cellar/qt@4/4.8.7_1/bin/qmake /usr/local/bin/qmake
Your system looks in /usr/local/bin before /usr/bin, and therefore it will find qmake in /usr/local/bin and use qmake for Qt4 instead.
Note that on Ubuntu, we have qtchooser which can be used to select which version of Qt to use. This does not seem to be available in OSX.
•
NS3 may not recognize PyGraphViz/PyBindGen that is needed for PyViz. The issue is due to a version number “string” mismatch! For example, when you run NS3’s ./waf configure, you may see Checking for pybindgen version : 0.17.0.post57+nga6376f2.d20161013 Pybindgen (found ‘0.17.0.post57+nga6376f2.d20161013’) , (need ‘0.17.0.post57+nga6376f2) The last portion of the version string need to be . This string is in the file: place_where_bake_was_downloaded/Bake/source/pybindgen/version.py In the line: Version = ‘0.17.0.post57+nga6376f2.d20161013’ You will remove the .d20161013 from the string, then save & quit. Run ./waf configure again, and now you should have PyViz enabled for NS3
I hope you find this useful. Regards, Adil A Alsuhaim Clemson University, USA Contact:
[email protected] or
[email protected]