tkn-tub / ns3-gym

ns3-gym - The Playground for Reinforcement Learning in Networking Research
GNU General Public License v2.0
521 stars 197 forks source link

Waiting for simulation script to connect #2

Closed mkheirkhah closed 5 years ago

mkheirkhah commented 5 years ago

Hi,

Many thanks for the ns3gym work, very timely.

I am having problem running the examples in the scratch folder. I am constantly getting a message like “Waiting for simulation script to connect” then the ns3 does notting afterwards.

I am using Ubuntu16.4 with python3.5 over a virtualenv instance. I am running examples as follows: ./was --run "rl-tcp" (for example) The same is true when running test files.

Any clue why I am entering such a condition.

Cheers, Morteza

huckiyang commented 5 years ago

echo to @mkheirkhah, I have the same issue running the test_tcp.py with “Waiting for simulation script to connect” and wait around 20 min as kinda a stack.

Besides, when I ran the test.py in the ./rl-tcp/, I got a different error message as

~/ns3-gym/scratch/rl-tcp$ ./test.pyWaiting for simulation script to connect
Traceback (most recent call last):
  File "./test.py", line 41, in <module>
    print("Observation space: ", ob_space,  ob_space.dtype)
AttributeError: 'NoneType' object has no attribute 'dtype' 

I am using Ubuntu16.4 with python3.6 over a pyenv instance. Also, many thanks to this essential work for the network community!

pgawlowicz commented 5 years ago

Hi,

Thanks for the comments. I am working hard to make the code robust :) and also on the documentation.

In order to run rl-tcp example, you have to execute: In terminal 1:

./waf --run "rl-tcp"

It will start ns3 simulation process, that waits for the Python process to connect and talk with over ns3gym interface.

In terminal 2:

cd ./scratch/rl-tcp/
./test_tcp.py

It will start Gym agent that has TCP NewReno implemented in Python over ns3gym.

You can also start all in single terminal using single command:

cd ./scratch/rl-tcp/
./test_tcp.py --start=1

Note, that it gives the same number of transmitted packets as the one implemented in ns3! Please exacute the following command to cross-check:

./waf --run "rl-tcp --transport_prot=TcpNewReno"

Regarding the second issue, please make sure to kill all ns3 simulation processes that run and use the same port for communication. If your Gym agent (python) connects to the already running ns3 simulation you get the mentioned error. I will provide some check to prevent from doing that.

Let me know if the above works.

Best, Piotr

mkheirkhah commented 5 years ago

Thanks! It seems running ok.

huckiyang commented 5 years ago

Thanks, @pgawlowicz I switched the simulated port to 5556 in the test_tcp.py. line 27 port = 5556 Now it works without the mentioned errors.

pgawlowicz commented 5 years ago

@huckiyang I have also added some checks today, that prevents from starting Python gym agent on the already used port. Also if you use port 0, it will find and take a free port.

I am waiting for more comments and feedback about your experience :)