yimingliu / py-natpmp

a NAT-PMP library for Python
http://blog.yimingliu.com/2008/01/07/nat-pmp-client-library-for-python
Other
47 stars 19 forks source link

Corrected timeout increment between requests #9

Closed homedirectory closed 1 year ago

homedirectory commented 1 year ago

According to the RFC:

To determine the external IP address or request a port mapping, a NAT-PMP client sends its request packet to port 5351 of its configured gateway address, and waits 250ms for a response. If no NAT-PMP response is received from the gateway after 250ms, the client retransmits its request and waits 500ms. The client SHOULD repeat this process with the interval between attempts doubling each time. If, after sending its 9th attempt (and then waiting for 64 seconds), ...

Current implementation, however, always increments the timeout by 0.250 seconds, instead of doubling it. So after the 9th attempt the timeout would only be 2.25 seconds instead of desired 64.

yimingliu commented 1 year ago

Hi!

Thank you for all the contributions! Really appreciate your work on a library that I have not worked on in many years.

Some asks:

Again, definitely welcome contributions, but there is some concern here for making aggressive changes beyond the scope of the original PR. Let's take it easy and one step at a time?

Thank you!

homedirectory commented 1 year ago

@yimingliu Sorry, I forgot that I was still comitting to this PR's branch, so only the first commit is relevant. Otherwise, I agree with you on all points. I will recreate the PR and include run results.