Monthly Archives: February 2015

1 Comment

Update Oct. 7th: As of version 2.1, ndn-cxx and NFD are now "integrated" in the ndnSIM git repository, therefore this post is now obsolete.

Update June 25th: ndn-cxx must be compiled as a shared library now! Changes are already included in this tutorial, but you must also follow the information provided here: ndn-cxx and ndnSIM - shared library problem.

If you ever wondered what you have to do to get ndnSIM + ndn-cxx run without having root access, then this is the right guide.
However, I do assume that SOMEONE does have root access and can install standard-libraries for you.
This is what it looks like on Ubuntu 14.04 (64 bit):

Make your administrator install the following packages (if not already installed)

sudo apt-get install build-essential libsqlite3-dev libcrypto++-dev libboost-all-dev
sudo apt-get install pkg-config git

And then continue with the following commands yourself (assuming you are in your home directory):

mkdir ndnSIM
cd ndnSIM
git clone ndn-cxx
git clone ndn-cxx
git clone ns-3
git clone pybindgen
git clone ns-3/src/ndnSIM
cd ndn-cxx
./waf configure --prefix /home/$USER/ndnSIM/usr/local/ --enable-shared --disable-static
./waf install

export LIBRARY_PATH=/home/$USER/ndnSIM/usr/local/lib/
export LD_LIBRARY_PATH=/home/$USER/ndnSIM/usr/local/lib/
export CPLUS_INCLUDE_PATH=/home/$USER/ndnSIM/usr/local/include/
cd ..
cd ns-3/

./waf configure --prefix /home/$USER/ndnSIM/usr/local/ -d optimized --disable-python
./waf install

You may copy the exports into your .bashrc file and adapt them like this:

export LIBRARY_PATH=/home/$USER/ndnSIM/usr/local/lib/:$LIBRARY_PATH
export LD_LIBRARY_PATH=/home/$USER/ndnSIM/usr/local/lib/:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/home/$USER/ndnSIM/usr/local/lib/pkgconfig
export CPLUS_INCLUDE_PATH=/home/$USER/ndnSIM/usr/local/include/:$CPLUS_INCLUDE_PATH

When using waf / wscript for compiling a project, you might come across the problem of adding another library, e.g., a shared object, to the compile and run process of waf. The task is trivial, but tutorials on that matter seem to be rare.

In my specific example, the task at hand was to add an external library, which I built from source, to an existing complex project. For now, we call this library libExternalStuff.
I assume that libExternalStuff has been built externally with whatever tools it was required to built, and it generated the following:
$SOMEDIR/libExternalStuff/includes/*.h (in particular, we are going to use externalStuff.h)
Where $SOMEDIR could be anywhere, e.g., in your home directory.

If you would "install" the library to your includes and library paths on Linux, you would probably be able to skip the following steps. Though if you don't want to mess with your Linux distributions configuration, or if you want to have a custom version of a certain library, this should be helpful.

Open the wscript file of your project (or subproject). Find the part where it says
def configure(conf):

Within this method, add the following:

test_code = '''
#include "externalStuff.h"

int main()
return 0;

conf.env.append_value('INCLUDES', os.path.abspath(os.path.join("$SOMEDIR/libExternalStuff/includes/", ".")))

conf.check(args=["--cflags", "--libs"], fragment=test_code, package='libExternalStuff', lib='ExternalStuff', mandatory=True, define_name='EXTERNAL_STUFF',
uselib_store='EXTERNAL_STUFF',libpath=os.path.abspath(os.path.join("$SOMEDIR/libExternalStuff/bin/", ".")))

conf.env.append_value('PROJECT_MODULE_PATH',os.path.abspath(os.path.join("$SOMEDIR/libExternalStuff/bin/", ".")))

This should get you going when you call:
./waf configure

What are those lines doing? First of all, we are creating a test code, which tries including one of the generated/provided header files. This can be adapted to anything you would like, and is mainly a sanity check. Second, we are adding the includes directory to the global INCLUDES path. This is important, else the compiler wouldn't know where to find the include script. Then we are creating a configuration entry for libdash. I'm not an expert with waf/wscript, but this line seems to have worked fine for me. Most importantly, make sure to have the lib parameter set properly (e.g., if your shared object is called, then the lib parameter reflects the -l parameter of gcc, and needs to be set to ExternalStuff). libpath is used for the linker to determine where to find the .so file.
The last line
conf.env.append_value('PROJECT_MODULE_PATH',os.path.abspath(os.path.join("$SOMEDIR/libExternalStuff/bin/", ".")))
is something specific to your project and you would have to figure out how the global variable is called in your project. This is the path where the project will look for the shared object file when using ./waf --run.

If your projct also has a --run method, then you will have to add the library to the run-configuration.
Find out where dynamic libraries are specified in your wscript, and add it to the line, e.g.:
module.uselib = 'LIB1 LIB2 EXTERNAL_STUFF'

I'm not an expert with waf/wscript, but those lines should get you going. However, based on the used project, some lines might have to be added, modified or deleted.

Apparently the tutorial suggests to download the ndnSIM scenario template, however, this does not look to be compatible with ndnSIM 2.0 (yet).

The mailing list suggests using the ns-3/scratch/ folder (for now), so here is an example of how to use that folder to run your scenario:

cd ns-3
cd scratch
mv ndn-simple.cpp
cd ..
./waf --run my-ndn-code --vis


UPDATE June 25th: ndn-cxx MUST be compiled as a shared library now, the tutorial is now reflecting this change by executing ./waf configure --enable-shared --disable-static for ndn-cxx

First of all: follow the tutorial provided here:
Second: If you feel comfortable enough, you can copy and paste the commands from this how-to, which will generate the following directory structure:


Third: This tutorial comes without warranty. Double check every command before you copy/paste it to your commandline.

Commands for Ubuntu 14.04:

# install pre-requesits for ndn-cxx, ns-3, etc...
sudo apt-get install git
sudo apt-get install python-dev python-pygraphviz python-kiwi
sudo apt-get install python-pygoocanvas python-gnome2
sudo apt-get install python-rsvg ipython
sudo apt-get install build-essential
sudo apt-get install libsqlite3-dev libcrypto++-dev
sudo apt-get install libboost-all-dev

# install mercurial for BRITE
sudo apt-get install mercurial

mkdir ndnSIM
cd ndnSIM

# clone git repositories for ndn/ndnSIM
git clone ndn-cxx
git clone ns-3
git clone pybindgen
git clone ns-3/src/ndnSIM

# download and built BRITE
hg clone
ls -la
cd ..

# build ndn-cxx
cd ndn-cxx
./waf configure --enable-shared --disable-static
# install ndn-cxx
sudo ./waf install
cd ..

# build ns-3/ndnSIM with brite
cd ns-3
./waf configure -d optimized --with-brite=/home/$USER/ndnSIM/BRITE
sudo ./waf install

Ideally, this outputs:

Modules built:
antenna aodv applications
bridge brite (no Python) buildings
config-store core csma
csma-layout dsdv dsr
emu energy fd-net-device
flow-monitor internet lr-wpan
lte mesh mobility
mpi ndnSIM netanim (no Python)
network nix-vector-routing olsr
point-to-point point-to-point-layout propagation
sixlowpan spectrum stats
tap-bridge test (no Python) topology-read
uan virtual-net-device visualizer
wave wifi wimax

Modules not built (see ns-3 tutorial for explanation):
click openflow


New Project: amus-ndnSIM
Blending Adaptive Multimedia Streaming (e.g., MPEG-DASH) with Named-Data Networking (NDN) using the ndnSIM simulation software.

Step 1: Install ndnSIM 2.0
Step 2: Invent a file transfer protocol
Step 3: Write a client that can download files
Step 4: Add multimedia streaming
Step 5: ???
Step 6: Come up with a cooler name
Step 7: Profit

What could go wrong?