ns3.26 python binding

885 views
Skip to first unread message

Tang Yuxin

unread,
Jul 1, 2017, 10:03:02 PM7/1/17
to ns-3-users
Actually, I am now binding the python in ns3.26 and some problems occur.

The procedures of binding are listed:

sudo ./build.py --enable-examples --enable-tests

Output:
---- Summary of optional NS-3 features:
Build profile                 : debug
Build directory               :
BRITE Integration             : not enabled (BRITE not enabled (see option --with-brite))
DES Metrics event collection  : not enabled (defaults to disabled)
Emulation FdNetDevice         : enabled
Examples                      : enabled
File descriptor NetDevice     : enabled
GNU Scientific Library (GSL)  : enabled
Gcrypt library                : not enabled (libgcrypt not found: you can use libgcrypt-config to find its location.)
GtkConfigStore                : enabled
MPI Support                   : not enabled (option --enable-mpi not selected)
NS-3 Click Integration        : not enabled (nsclick not enabled (see option --with-nsclick))
NS-3 OpenFlow Integration     : not enabled (OpenFlow not enabled (see option --with-openflow))
Network Simulation Cradle     : not enabled (NSC not found (see option --with-nsc))
PlanetLab FdNetDevice         : not enabled (PlanetLab operating system not detected (see option --force-planetlab))
PyViz visualizer              : enabled
Python API Scanning Support   : enabled
Python Bindings               : enabled
Real Time Simulator           : enabled
SQlite stats data output      : enabled
Tap Bridge                    : enabled
Tap FdNetDevice               : enabled
Tests                         : enabled
Threading Primitives          : enabled
Use sudo to set suid bit      : not enabled (option --enable-sudo not selected)
XmlIo                         : enabled

Modules built:
antenna                   aodv                      applications             
bridge                    buildings                 config-store             
core                      csma                      csma-layout              
dsdv                      dsr                       energy                   
fd-net-device             flow-monitor              internet                 
internet-apps             lr-wpan                   lte                      
mesh                      mobility                  mpi                      
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             traffic-control           uan                      
virtual-net-device        visualizer                wave                     
wifi                      wimax                    

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

Leaving directory `./ns-3.26'

sudo ./waf configure --enable-examples --enable-tests
---- Summary of optional NS-3 features:
Build profile                 : debug
Build directory               :
BRITE Integration             : not enabled (BRITE not enabled (see option --with-brite))
DES Metrics event collection  : not enabled (defaults to disabled)
Emulation FdNetDevice         : enabled
Examples                      : enabled
File descriptor NetDevice     : enabled
GNU Scientific Library (GSL)  : enabled
Gcrypt library                : not enabled (libgcrypt not found: you can use libgcrypt-config to find its location.)
GtkConfigStore                : enabled
MPI Support                   : not enabled (option --enable-mpi not selected)
NS-3 Click Integration        : not enabled (nsclick not enabled (see option --with-nsclick))
NS-3 OpenFlow Integration     : not enabled (OpenFlow not enabled (see option --with-openflow))
Network Simulation Cradle     : not enabled (NSC not found (see option --with-nsc))
PlanetLab FdNetDevice         : not enabled (PlanetLab operating system not detected (see option --force-planetlab))
PyViz visualizer              : enabled
Python API Scanning Support   : enabled
Python Bindings               : enabled
Real Time Simulator           : enabled
SQlite stats data output      : enabled
Tap Bridge                    : enabled
Tap FdNetDevice               : enabled
Tests                         : enabled
Threading Primitives          : enabled
Use sudo to set suid bit      : not enabled (option --enable-sudo not selected)
XmlIo                         : enabled


It seems that the Python API Scanning Support and Python Bindings are all enabled.

However, when I import the ns.core as the root, it gives me the error like this:

(seems it cannot find ns modules)
root@superhero:/home/yuxin/Workspace/ns-allinone-3.26/ns-3.26# python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ns.core
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named ns.core

However, after I run the example
./waf shell examples/tutorial/first.py

There is no error when importing ns.core

Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ns.core
>>>

Then, when I quit the root, it will give me a error:
exit
'shell' finished successfully (16m35.386s)
No function examples/tutorial/first.py defined in /home/yuxin/Workspace/ns-allinone-3.26/ns-3.26/wscript


I just wonder why the ImportError will happen after I have already made the Python API Scanning Support and Python Bindings enabled.

And why after I running the example(first.py), the ImportError wont happen again.

Does that mean everytime when i want to use "import ns.core"or some other ns modules, I must log in with the root and then run the exmple(first.py) first?

Actually I think there may be some problems. But I cannot find that, could anyone help me? Many many thanks!!

Tang Yuxin

unread,
Jul 1, 2017, 10:06:53 PM7/1/17
to ns-3-users
root@yuxin-superhero:/home/yuxin/Workspace/ns-allinone-3.26/ns-3.26# echo $PYTHONPATH

root@yuxin-superhero:/home/yuxin/Workspace/ns-allinone-3.26/ns-3.26# ./waf shell examples/tutorial/first.py
Waf: Entering directory `/home/yuxin/Workspace/ns-allinone-3.26/ns-3.26/build'
Waf: Leaving directory `/home/yuxin/Workspace/ns-allinone-3.26/ns-3.26/build'
Build commands will be stored in build/compile_commands.json
root@yuxin-superhero:/home/yuxin/Workspace/ns-allinone-3.26/ns-3.26# echo $PYTHONPATH
/home/yuxin/Workspace/ns-allinone-3.26/ns-3.26/build/bindings/python:/home/yuxin/Workspace/ns-allinone-3.26/ns-3.26/src/visualizer:/home/yuxin/Workspace/ns-allinone-3.26/pybindgen-0.17.0.post57+nga6376f2

The PYTHONPATH is different as well. After I run the example, the pythonpath will be changed...



在 2017年7月1日星期六 UTC-7下午7:03:02,Tang Yuxin写道:

Juan Camilo Baquero Bustos

unread,
Oct 30, 2017, 8:45:08 PM10/30/17
to ns-3-users
Dear Yung, i am trying to install the PLC module but first i have a problem with python bindings and i solved it changing the wscript file, then bindings were enabled at the same time Python API Scanning Support was desactivated because the gccxml couldn't be read or it's too old" i send a "screenshot" of my process at this moment:

juancamilo@JuanBaquero-VirtualBox:~/ns3.26/bake/source/ns-3.26$ sudo ./waf --enable-examples --enable-tests configure
Setting top to                           : /home/juancamilo/ns3.26/bake/source/ns-3.26
Setting out to                           : /home/juancamilo/ns3.26/bake/source/ns-3.26/build
Checking for 'gcc' (C compiler)          : /usr/bin/gcc
Checking for cc version                  : 5.4.1
Checking for 'g++' (C++ compiler)        : /usr/bin/g++
Checking for compilation flag -Wl,--soname=foo support : ok
Checking for program 'python'                          : /usr/bin/python
Checking for python version                            : (2, 7, 12, 'final', 0)
python-config                                          : /usr/bin/python-config
Asking python-config for pyembed '--cflags --libs --ldflags' flags : yes
Testing pyembed configuration                                      : yes
Asking python-config for pyext '--cflags --libs --ldflags' flags   : yes
Testing pyext configuration                                        : yes
Checking for compilation flag -fvisibility=hidden support          : ok
Checking for compilation flag -Wno-array-bounds support            : ok
Checking for pybindgen location                                    : ../pybindgen (guessed)
Checking for python module 'pybindgen'                             : 0.17.0.post57+ga6376f2
Checking for pybindgen version                                     : 0.17.0.post57+ga6376f2
Checking for code snippet                                          : yes
Checking for types uint64_t and unsigned long equivalence          : no
Checking for code snippet                                          : no
Checking for types uint64_t and unsigned long long equivalence     : yes
Checking for the apidefs that can be used for Python bindings      : gcc-LP64
Checking for internal GCC cxxabi                                   : complete
Checking for python module 'pygccxml'                              : 1.0.0
Checking for pygccxml version                                      : 1.0.0
Checking for program 'gccxml'                                      : /usr/bin/gccxml
Checking for gccxml version                                        : GCC-XML compatibility CastXML wrapper
gccxml version unknown or too old, need version >= 0.9; automatic scanning of API definitions will not be possible
Checking boost includes                                            : 1_58
Checking boost libs                                                : ok
Checking for boost linkage                                         : ok
Checking for click location                                        : not found
Checking for program 'pkg-config'                                  : /usr/bin/pkg-config
Checking for 'gtk+-2.0' >= 2.12                                    : yes
Checking for 'libxml-2.0' >= 2.7                                   : yes
Checking for type uint128_t                                        : not found
Checking for type __uint128_t                                      : yes
Checking high precision implementation                             : 128-bit integer (default)
Checking for header stdint.h                                       : yes
Checking for header inttypes.h                                     : yes
Checking for header sys/inttypes.h                                 : not found
Checking for header sys/types.h                                    : yes
Checking for header sys/stat.h                                     : yes
Checking for header dirent.h                                       : yes
Checking for header stdlib.h                                       : yes
Checking for header signal.h                                       : yes
Checking for header pthread.h                                      : yes
Checking for header stdint.h                                       : yes
Checking for header inttypes.h                                     : yes
Checking for header sys/inttypes.h                                 : not found
Checking for library rt                                            : yes
Checking for header sys/ioctl.h                                    : yes
Checking for header net/if.h                                       : yes
Checking for header net/ethernet.h                                 : yes
Checking for header linux/if_tun.h                                 : yes
Checking for header netpacket/packet.h                             : yes
Checking for NSC location                                          : not found
Checking for OpenFlow location                                     : not found
Checking for 'sqlite3'                                             : yes
Checking for header linux/if_tun.h                                 : yes
Checking for python module 'gtk'                                   : ok
Checking for python module 'goocanvas'                             : 0.14.1
Checking for python module 'pygraphviz'                            : 1.3.1
Checking for program 'sudo'                                        : /usr/bin/sudo
Checking for program 'valgrind'                                    : /usr/bin/valgrind
Checking for 'gsl'                                                 : yes
python-config                                                      : not found
Checking for compilation flag -Wno-error=deprecated-d... support   : ok
Checking for compilation flag -Wno-error=deprecated-d... support   : ok
Checking for compilation flag -fstrict-aliasing support            : ok
Checking for compilation flag -fstrict-aliasing support            : ok
Checking for compilation flag -Wstrict-aliasing support            : ok
Checking for compilation flag -Wstrict-aliasing support            : ok
Checking for program 'doxygen'                                     : /usr/bin/doxygen
---- Summary of optional NS-3 features:
Build profile                 : debug
Build directory               :
BRITE Integration             : not enabled (BRITE not enabled (see option --with-brite))
DES Metrics event collection  : not enabled (defaults to disabled)
Emulation FdNetDevice         : enabled
Examples                      : enabled
File descriptor NetDevice     : enabled
GNU Scientific Library (GSL)  : enabled
Gcrypt library                : not enabled (libgcrypt not found: you can use libgcrypt-config to find its location.)
GtkConfigStore                : enabled
MPI Support                   : not enabled (option --enable-mpi not selected)
NS-3 Click Integration        : not enabled (nsclick not enabled (see option --with-nsclick))
NS-3 OpenFlow Integration     : not enabled (OpenFlow not enabled (see option --with-openflow))
Network Simulation Cradle     : not enabled (NSC not found (see option --with-nsc))
PlanetLab FdNetDevice         : not enabled (PlanetLab operating system not detected (see option --force-planetlab))
PyViz visualizer              : enabled
Python API Scanning Support   : not enabled (gccxml too old)

Python Bindings               : enabled
Real Time Simulator           : enabled
SQlite stats data output      : enabled
Tap Bridge                    : enabled
Tap FdNetDevice               : enabled
Tests                         : enabled
Threading Primitives          : enabled
Use sudo to set suid bit      : not enabled (option --enable-sudo not selected)
XmlIo                         : enabled
'configure' finished successfully (6.412s)

Another problem i actually have is that:
- I don't know how to install determined versions of some packages (not exactly the latest, because i have all but not the required by the PLC insallation guide) the packages are

cmake (2.8.2+dfsg.1‐0+squeeze1)
cmake‐data (2.8.2+dfsg.1‐0+squeeze1)
cmake‐doc (2.8.2+dfsg.1‐0+squeeze1)
gccxml (0.9.0+cvs20100501‐2)
libxmlrpc‐c3 (1.06.27‐1.1)
python2.6‐dev (2.6.6‐8+b1)
python‐pygccxml (1.0.0‐4)

Can you tell me which versions of ns3, ubuntu and python are you using? I urgently need to install this module for my thesis.

Thanks for your time.
Best regards,
Juan

Yuxin Tang

unread,
Oct 30, 2017, 9:37:30 PM10/30/17
to ns-3-...@googlegroups.com
Hi Juan:

     I think you should check the version of gccxml and ubuntu.  Actually, I have ever encountered the same problem as you.
     According to my memory, the gccxml is not compatible with gcc5, which is the default version of gcc in  ubuntu 16.04. You can google it and find more information. My solution is to use ubuntu14.04gcc4.5 and gccxml. If you want to use ubuntu16.04, you can try but I think the gccxml may not work.

    ns3 version is not so important, I think 3.26 is enough.
    
  
Bests,
Yuxin
    

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/IlZqtc2qvFk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.



--
Best Regards,
===========================================
Yuxin Tang
Department of Computer Science
Shanghai Jiao Tong University, Shanghai, China
Zipcode: 200240


Tom Henderson

unread,
Oct 30, 2017, 11:10:38 PM10/30/17
to ns-3-...@googlegroups.com, Yuxin Tang
On 10/30/2017 06:37 PM, Yuxin Tang wrote:
> Hi Juan:
>
>      I think you should check the version of *gccxml *and *ubuntu*.
> Actually, I have ever encountered the same problem as you.
>      According to my memory, the *gccxml* is not compatible with
> *gcc5*, which is the default version of *gcc *in *ubuntu 16.04. *You can
> google it and find more information. My solution is to use
> *ubuntu14.04*, *gcc4.5* and *gccxml. *If you want to use *ubuntu16.04*,
> you can try but I think the *gccxml *may not work.


gccxml can work for compiler version gcc-4.9, for ns-3.26 and earlier
(but not for the latest release ns-3.27). gcc-4.9 is available for
Ubuntu 16.04:
https://www.howtoinstall.co/en/ubuntu/xenial/gcc-4.9

The project is migrating to castxml for ns-3.27 and later releases, for
which the C++-11 support is better.

- Tom

hongyu deng

unread,
Dec 21, 2017, 9:53:40 AM12/21/17
to ns-3-users
Hi Tom,

Thanks for your work!

BUT even i change GCC to version 4.9.3, the Python API Scanning Support does not enable!(seeing in figures)
Why this happen? Could you give some advice?
Thanks!

Best,
Hong

在 2017年10月31日星期二 UTC+8上午11:10:38,Tom Henderson写道:
1.png
2.png
Reply all
Reply to author
Forward
0 new messages