How to embedd python codes in C++ codes of NS3

131 views
Skip to first unread message

Jie Chen

unread,
Dec 31, 2019, 2:14:28 AM12/31/19
to ns-3-users
Hi, I am running C++ program in NS3 and now need to call a piece of python codes during the execution of the C++ program.

I know there is a general how to guide on internet but would like to know if anyone has a concrete example/case, particular for NS3.

Thanks,

Best,

Jie

Enid

unread,
Jan 7, 2020, 8:31:22 AM1/7/20
to ns-3-users
Python code embedding within C as shown in tutorials online work perfectly fine. Take a look at https://www.codeproject.com/Articles/11805/Embedding-Python-in-C-C-Part-I for example.

Jie Chen

unread,
Jan 7, 2020, 10:21:53 AM1/7/20
to ns-3-users
Hi ,

Thanks for your message.

Somehow in my case as to implement it in NS3, it seems needing to change the wscript file, if I have understood the NS3 python binding mechanism correctly.

In my current configuration, the python binding has been enabled. And at compilation, it said apidefs dir not found.So the module could not be built.

I notice that in the visualiser module, the author has included ‘Python.h’ file and calls the python functions. Very unfortunately, the module could not be built as well because pygraphviz is not enabled.

Any idea? :)

Jie

Jie Chen

unread,
Jan 7, 2020, 11:56:27 AM1/7/20
to ns-3-...@googlegroups.com, tom.a...@gmail.com
Hi Tom,

Thanks for your message.

Somehow in my case as to implement it in NS3, it seems needing to change the wscript file, if I have understood the NS3 python binding mechanism correctly.

In my current configuration, the python binding has been enabled. At compilation, it said apidefs dir not found.So the module could not be built.

I notice that in the visualiser module, the author has included ‘Python.h’ file and calls the python functions. Very unfortunately, the module could not be built as well because pygraphviz is not enabled.

Any idea? :)

Jie

-- 
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 the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/a667a448-d6e4-4282-8113-49c99f34c80b%40googlegroups.com.

Enid

unread,
Jan 9, 2020, 5:50:42 AM1/9/20
to ns-3-users
Hi Jie

Would it be possible for you to post the error screenshots in case you haven't found a solution yet?


On Tuesday, January 7, 2020 at 5:56:27 PM UTC+1, Jie Chen wrote:
Hi Tom,

Thanks for your message.

Somehow in my case as to implement it in NS3, it seems needing to change the wscript file, if I have understood the NS3 python binding mechanism correctly.

In my current configuration, the python binding has been enabled. At compilation, it said apidefs dir not found.So the module could not be built.

I notice that in the visualiser module, the author has included ‘Python.h’ file and calls the python functions. Very unfortunately, the module could not be built as well because pygraphviz is not enabled.

Any idea? :)

Jie

On 7 Jan 2020, at 13:31, Enid <tom.a...@gmail.com> wrote:

Python code embedding within C as shown in tutorials online work perfectly fine. Take a look at https://www.codeproject.com/Articles/11805/Embedding-Python-in-C-C-Part-I for example.

On Tuesday, December 31, 2019 at 8:14:28 AM UTC+1, Jie Chen wrote:
Hi, I am running C++ program in NS3 and now need to call a piece of python codes during the execution of the C++ program.

I know there is a general how to guide on internet but would like to know if anyone has a concrete example/case, particular for NS3.

Thanks,

Best,

Jie

-- 
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 the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-...@googlegroups.com.

Jie Chen

unread,
Jan 9, 2020, 6:12:01 AM1/9/20
to ns-3-users
Hi,

I found the solution as to change the wscript.....pheww.

Thanks:).

J.

NINJA INFO

unread,
Jan 9, 2020, 10:09:51 AM1/9/20
to ns-3-...@googlegroups.com
Hi,

Please check this link. This page have some NS3 source code. It may helpful for you.


--
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 the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/f2d0f065-e8ea-4721-8c80-35ad1ca4e38a%40googlegroups.com.

Serene Banerjee

unread,
Mar 2, 2020, 12:05:59 AM3/2/20
to ns-3-users
Hi Jie,

Can you please post the solution. That is, what did you change in the wscript? Because, right now I am stuck at the same problem, ie the visualizer module is not being built and Pygraphviz and python bindings are not enabled.

Regards,

Serene
Reply all
Reply to author
Forward
0 new messages