direct-code-execution / ns-3-dce

Run real programs in the discrete time simulator ns3
http://www.nsnam.org/projects/direct-code-execution/
75 stars 46 forks source link

Compiling on a Raspberry Pi #72

Open regisin opened 6 years ago

regisin commented 6 years ago

Description of the problem

I'm trying to compile DCE/ns3 on a Raspberry Pi. I know it's not a tested platform, but I'm willing to put some effort to make it work. Currently, following instructions from the official docs, I ran into some issues.

  1. libc/libc-debug

The bakeconfig file lists some options for libc and libc-debug, but on a Raspbian, the path for the files it looks for are wrong.

To fix this (bake not finding libc), I had to create the following symlinks (I suppose editing the bake conf xml file would also work, but on a Pi, opening the xml was not easy) - this is a workaround, not following best practices:

sudo ln -s /lib/arm-linux-gnueabihf/ld-2.24.so /usr/lib/ld-2.24.so
sudo mkdir -p /usr/lib/debug/lib/x86_64-linux-gnu/
sudo ln -s /lib/arm-linux-gnueabihf/ld-2.24.so /usr/lib/debug/lib/x86_64-linux-gnu/ld-2.24.so

Note: similar issue with boost for ns-3 itself:

sudo apt-get -y install libboost-all-dev
sudo ln -s /usr/lib/arm-linux-gnueabihf /usr/lib64
  1. iperf outdated

Looks like the source for iperf that Bake downloads is not updated. While bake was compiling, it ran into this bug: iperf bug

My solution, which I believe is the correct one, was to simply replace the source/iperf folder by the updated source from here: iperf2.0.9

And then modifying Thread.c to add the sleep(1); to line 412 line as per instructions.

The following items fail during bake.py build -vvv. I split each item from the output, files are attached.

output of ./waf configure

If this refers to the dce waf configure, please see file dce.log attached.

Steps to reproduce

On a fresh install of the Raspbian Stretch on a Raspberry Pi 3 model B

sudo apt-get update
sudo apt-get install cmake cvs git
sudo apt-get install bzr unrar
sudo apt-get install bzr unrar-free
sudo apt-get install p7zip-full autoconf
sudo apt-get install mercurial

sudo apt-get install build-essential bison
sudo apt-get install flex g++
sudo apt-get install libc6 libc6-dev libc6-dbg
sudo apt-get install libpcap-dev tcpdump libssl-dev 
sudo apt-get install libdb-dev libexpat1-dev 
sudo apt-get install python-dev python-pygraphviz
sudo apt-get install python-pygoocanvas python-setuptools
sudo apt-get install qt4-dev-tools 
sudo apt-get install clang
sudo apt-get install libclang-dev

mkdir dce
cd dce
hg clone http://code.nsnam.org/bake bake
export BAKE_HOME=`pwd`/bake
export PATH=$PATH:$BAKE_HOME
export PYTHONPATH=$PYTHONPATH:$BAKE_HOME
mkdir ns3
cd ns3/

bake.py configure -e dce-ns3-1.9
bake.py download -vvv
bake.py build -vvv > log.txt

Note that I couldn't find a list of dependencies that DCE requires, because it mainly encourages you to install with bake, so I installed a lot of packages.

P.S. About documentation

I know bake is supposed to be the easiest way to build dce, but is it possible to improve the documentation? For example, the step-by-step of the instructions to build with WAF are not clear. Where do I put the source code for ns-3? How do I build it? How about each other source folder (i.e. ccnx, iperf, ping, etc)? If I do NOT need one of those applications, can I simply delete the folder or is there a special way to configure it?

teto commented 6 years ago

1.10 should solve some pbs already. I am not a huge fan of bake and I don't have commit access to it anyway but I am working on a nix-based packages which should be a lot more reliable. The last nix(os) release 18.09 seems to have brought some support for raspberry pi 3 so in the long term that could help, in the short term you are on your own sorry :) https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi https://www.reddit.com/r/NixOS/comments/5p3f7l/nixos_in_raspberry_pi/ https://github.com/NixOS/nixpkgs/issues/22014

regisin commented 6 years ago

Well, iperf error disappeared, but the rest are still there.

Do you know how I'd go about building with waf?

The docs are very vague. I don't need most of the subprojects (I don't need net-next-sim for example, just dce, ns3, iperf and ping to work together), but the docs don't say how to obtain them one by one.

I want to use this setup to actually test my own ns3 modules on a testbed.

I'm willing to write a good tutorial about that, but I have to learn first.

@teto

regisin commented 6 years ago

Update:

I'm tackling each problem individually.

iv. netanim (I think it's solved):

v. elf-loader (progress, not solved): The script extract-system-config.py looks for a libc-debug file. In the script onli ubuntu files are listed. I added '/lib/arm-linux-gnueabihf/ld-2.24.so', to the files_to_try list.

Now the problem seems to be that the python script can't read the values from that libc-debug file. Not sure why.

teto commented 6 years ago

I was sure we had a detailed explanation for ./waf only but can't find it. Maybe it was just on the mailing list or somewhere else. Basically you just need ./waf configure --with-ns3=/installed/ns3 directly. You can then deal with error along as you do /waf build. I never used netanim so not sure what's going on there.

To get iperf & co, you can look at the bakeconf.xml to see what urls/commands bake uses to fetch/compile.

regisin commented 6 years ago

So I think I'm on the right track. I started over and now I'm doing everything by hand.

I have:

Would DCE work this way or is there any other dependency I'm missing? I followed the folder structure from bakefile.xml

regisin commented 6 years ago

I've been getting this error when compiling dce:

pi@raspberrypi:~/Desktop/dce/ns-3-dce $ ./waf build
Waf: Entering directory `/home/pi/Desktop/dce/ns-3-dce/build'
[  9/255] Linking build/lib/libns3-netlink.so
[ 10/255] Creating build/lib/pkgconfig/libns3-dev-netlink-debug.pc
[ 11/255] Compiling model/dce-manager.cc
[ 12/255] Compiling model/dce-application.cc
[ 13/255] Compiling model/dce.cc
[ 14/255] Compiling model/dce-signal.cc
[ 15/255] Compiling model/libc-dce.cc
[ 16/255] Compiling model/utils.cc
../model/libc-ns3.h: In function ‘void libc_dce(Libc**)’:
../model/libc-dce.cc:191:61: error: invalid conversion from ‘int (*)(pollfd*, nfds_t, int, size_t) {aka int (*)(pollfd*, long unsigned int, int, unsigned int)}’ to ‘int (*)(pollfd*, long unsigned int, int, long unsigned int)’ [-fpermissive]
 #define DCE_EXPLICIT(name,rtype,...) (*libc)->name ## _fn = dce_ ## name;
                                                             ^
../model/libc-ns3.h:441:1: note: in expansion of macro ‘DCE_EXPLICIT’
 DCE_EXPLICIT (__poll_chk, int, struct pollfd *, long unsigned int, int, long unsigned int)
 ^~~~~~~~~~~~

Waf: Leaving directory `/home/pi/Desktop/dce/ns-3-dce/build'
Build failed
 -> task in './lib/ns3-dce' failed (exit status 1): 
    {task 1985207088: cxx libc-dce.cc -> libc-dce.cc.6.o}
['/usr/bin/g++', '-g', '-std=c++11', '-Wno-deprecated-declarations', '-Wno-psabi', '-fPIC', '-pthread', '-pthread', '-pthread', '-Imodel', '-I../model', '-Imodel/freebsd', '-I../model/freebsd', '-Ihelper', '-I../helper', '-Imodel/linux', '-I../model/linux', '-Iinclude', '-I../include', '-I/home/pi/Desktop/dce/build/include/ns3.26', '-DNS3_LOG_ENABLE', '-DNS3_ASSERT_ENABLE', '-DHAVE_STDINT_H=1', '-DHAVE_INTTYPES_H=1', '-DHAVE_SYS_TYPES_H=1', '-DHAVE_SYS_STAT_H=1', '-DHAVE_DIRENT_H=1', '-DHAVE_SECURE_GETENV=1', '-DHAVE_VALGRIND_VALGRIND_H=1', '-DHAVE_VALGRIND_MEMCHECK_H=1', '-DPYTHONDIR="/home/pi/Desktop/dce/build/lib/python2.7/site-packages"', '-DPYTHONARCHDIR="/home/pi/Desktop/dce/build/lib/python2.7/site-packages"', '-DHAVE_PYEMBED=1', '-DHAVE_PYEXT=1', '-DHAVE_PYTHON_H=1', '-DHAVE_NS3_CORE=1', '-DHAVE_NS3_NETWORK=1', '-DHAVE_NS3_INTERNET=1', '../model/libc-dce.cc', '-c', '-o', '/home/pi/Desktop/dce/ns-3-dce/build/model/libc-dce.cc.6.o']
pi@raspberrypi:~/Desktop/dce/ns-3-dce $ nano wscript 

I couldn't find the culprit.

teto commented 6 years ago

The prototypes are different, the last parameter especially. You might need to change it