About using Python to write ns3 script instructions

41 views
Skip to first unread message

Andy LU

unread,
Apr 2, 2024, 4:52:37 AM4/2/24
to ns-3-users
Hi,
I have recently been studying issues related to factors affecting communication performance in 5G communications. I used a sample code nr-multi-flow-sched file and modified its parameters to observe the impact of each parameter on simulation performance.
I put the variable list into the Python code and used the subprocess library in Python to write the command  to run the ns3 script, but it always reported an error and was considered to be a problem with the command. However, after testing and inspection, I found no code problem. Please help me, help me figure out what's wrong with my Python code.
Sincere thanks.
Andy

ns3代码.png
Pic 1. This is the part of the code where I wrote the ns3 run instructions in Python.

result1.png
Pic 2.  The most common error reported during the test is this. I did not add the 'shell=True' parameter in the Python code, and the default is 'shell=False'.

result2.png
Pic 3. When I added the 'shell=True' parameter to the Python code, the Python code could run normally, but the actual ns3 script file was not executed. My modified script 'my_qos_0329' did not output the corresponding results.

I really don't know what's wrong, please help me. Thank you so much.

Andy LU

unread,
Apr 2, 2024, 8:09:00 AM4/2/24
to ns-3-users
I have solved this problem so far. The solution is to construct the command in string mode, then add the shell=True parameter to subprocess.Popen, and then run it in batches.
Thanks again to everyone who paid attention to this issue.

Reply all
Reply to author
Forward
0 new messages