Opened 10 years ago

Closed 9 years ago

Last modified 8 years ago

#79 closed feature-request (Fixed)

Bind outgoing connections to local port

Reported by: peterdk Owned by: andar
Priority: minor Milestone:
Component: Core Version: 1.1.0_dev
Keywords: bind to local port tcp SO_REUSEADDR Cc: deluge@…

Description

I am using QoS at home to manage my bittorrent traffic. Unfortunately not all trafic is caught with the L7 and IPP2P filters. Though it is possible to set incoming ports, it is not possible yet to define the outgoing port(s). QoS filtering is therefore not really possible, only if one would totally define all traffic except www traffic as "low" class.

A solution to this problem is to bind all the outgoing Deluge connections to a specified local port instead of just letting the OS randomly assigning a unique port for every single one.

Azureus has implemented this and this allows for a easy QoS rule that filters all traffic coming from the defined port. It is a ideal solution for home QoS filtering without having any effect on the QoS of ISP's, so possible encryption doesn't need to be turned off.

Someone from the Azureus channel explained how it could be done:

[17:55] <wereHamster> so I'd like to know how it's possible to initiate multiple connections from the same port :)
[17:58] <The_8472> tools -> options -> connections -> advanced network settings -> bind to port
[17:58] <wereHamster> I know, but how is it technically done, bind() fails if the port is already taken (EADDRINUSE
[17:59] <The_8472> use SO_REUSEADDR
[18:01] <wereHamster> This socket option tells the kernel that even if this port is busy (in the TIME_WAIT state), go ahead and reuse it anyway. If it is busy, but with another state, you will still get an address already in use
[18:02] <wereHamster> error.
[18:02] <The_8472> that only applies to the same socket pair
[18:03] <The_8472> if it's a different socket pair then it does what you want
[18:03] <wereHamster> ok, thanks

Since I am planning to move from Azureus to a more native Linux app, I would like to request that the option of forced binding to a local port be added to Deluge. I also submitted this feature request to Transmission and I hope this will help making Deluge too a better client.

Something from the Azureus wiki that maybe is good to know if this feature is added/developed:

  • Bind to local Port This sets outgoing connections to a fixed source port. This can be used with full cone NAT routers to reduce the number of NAT table entries and thus prevent crashes on some router models. When the outgoing port is bound to the same as the incoming port that might even solve NAT problems on full cone NAT routers.

Note: Binding to the same port as the incoming port works under Windows 2k and greater only. Unix users should use a different port. It's not working at all under Mac OS X.

Change History (8)

comment:1 Changed 10 years ago by peterdk

It looks like this has been implemented in libtorrent: http://code.rasterbar.com/libtorrent/changeset/2040

comment:2 Changed 10 years ago by markybob

  • Version changed from 0.5.8.5 to 0.6.0svn

this is only in libtorrent trunk, which 0.5 will never use.

comment:3 Changed 9 years ago by andar

  • Milestone set to 1.1.0
  • Version changed from 0.6.0svn to 1.1.0_dev

comment:4 Changed 9 years ago by andar

  • Resolution set to fixed
  • Status changed from new to closed

Implemented [3602]

comment:5 Changed 9 years ago by anonymous

  • Milestone 1.1.0 deleted

Milestone 1.1.0 deleted

comment:6 Changed 9 years ago by xak

It appears that on my Linux machine I can only bind to the /same/ port as the incoming listen port. Attempting to bind to a different port results in "java.net.BindException?: Cannot assign requested address" error. All is well using same port as incoming listen port.

System: Ubuntu Hardy 8.04 kernel 2.6.24-22-server x86_64 sun-java-6-jre version 6-07-3ubuntu2 build 1.6.0_07-b06 Azureus 2009.01.26 version 4.1.0.0

comment:7 Changed 8 years ago by alisazhao2009

If you’re a dedicated follower of tiffany co like me. Don't miss the tiffany uk & co. on sale including pendants, necklace, earrings, bracelets on line. tiffanys is the one thing that outlasts the cake, champagne and music.

Note: See TracTickets for help on using tickets.