Bug 111127 - UDP Tracker Port Option Not Working
Summary: UDP Tracker Port Option Not Working
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Applications
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-20 03:58 UTC by Jason Carter
Modified: 2005-08-24 10:24 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Torrent which uses UDP trackers (27.75 KB, application/x-bittorrent)
2005-08-20 12:59 UTC, Joris Guisson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Carter 2005-08-20 03:58:52 UTC
Version:           SVN (using KDE KDE 3.4.2)
Installed from:    Compiled From Sources
Compiler:          gcc version 3.3.5-20050130 (Gentoo 3.3.5.20050130-r1, ssp-3.3.5.20050130-1, pie-8.7.7.1) 
OS:                Linux

Changing the UDP Tracker Port option in KTorrent's configuration dialog does not seem to work properly. Even with all torrents stopped, changing the option does not immediately take effect, requiring you to restart KTorrent before it will honor the change made.

Upon restarting KTorrent and checking which ports KTorrent is listening in on, you see something very, very odd going on.

I have Port set to 45451 and UDP Tracker Port set to 45454. Upon restart and checking with 'netstat -l -p --numeric-ports | grep ktorrent' gives me the following:

 tcp        0      0 *:45451                 *:*                     LISTEN      17816/ktorrent
udp        0      0 *:36866                 *:*                                 17816/ktorrent

Despite having selected 45454 for the UDP Tracker Port, it's listening in on 36866 instead which is definitely not being properly port forwarded from my router. (The range I'm forwarding is 45450-45455.) That's an odd port number.

So let's try something here. I'm going to change the UDP Port and restart the program and see what port numbers it gives me.

45450 -> udp *:36884
45452 -> udp *:36890

This time, I just quit the program without changing the UDP port at all and...

udp *:36893

So it looks like UDP port selection isn't working properly.. unless I'm completely misunderstanding things here and got overzealous with netstat. Could this be a reason why I'm getting speed problems, since the ports being used for UDP tracker port is blocked?
Comment 1 Jason Carter 2005-08-20 04:12:16 UTC
Also, the trackers are showing me as using port 0 for some reason.
Comment 2 Joris Guisson 2005-08-20 10:48:35 UTC
And I was thinking about releasing a 1.1 beta ...

Yeah the speed problems can probably be attributed to this :

- You send your announce, but you never get reply back, which means you get no list of peers to connect to
- Seeing that the tracker knows you, other people connect to you through the properly forwarded TCP port

You obviously are going to get low speeds because of this.

Port changes only take effect when you restart KTorrent, you can't switch ports in the middle of a download.
Comment 3 Joris Guisson 2005-08-20 10:50:55 UTC
*** Bug 111050 has been marked as a duplicate of this bug. ***
Comment 4 Jason Carter 2005-08-20 10:58:19 UTC
"Port changes only take effect when you restart KTorrent, you can't switch ports in the middle of a download."

I wasn't expecting the port changes to take effect in the middle of a download, but it would be nice for it to take effect right away if no torrents are currently active though. Notification that the port change will only take effect once KTorrent is restarted, or when all torrents are stopped (if you decide to implement it) would be good as well.
Comment 5 Joris Guisson 2005-08-20 12:40:27 UTC
KTorrent listens to the correct ports :
I put my ports on 6881 (for tcp) and 7000 (udp tracker port)
tcp        0      0 0.0.0.0:6881            0.0.0.0:*               LISTEN      10664/ktorrent
udp        0      0 0.0.0.0:7000            0.0.0.0:*                           10664/ktorrent


I did fix a serious bug in the UDP Tracker. Which is probably the cause of the speed issues. 
Comment 6 Joris Guisson 2005-08-20 12:47:50 UTC
Post a link to the torrent, if the torrent doesn't use UDP trackers, normally no UDP ports will be created.
Comment 7 Joris Guisson 2005-08-20 12:52:21 UTC
Wait a second, the UDP port will only be created when the tracker of a torrent uses UDP, so if you startup you should only see a TCP port.
Comment 8 Joris Guisson 2005-08-20 12:59:27 UTC
Created attachment 12275 [details]
Torrent which uses UDP trackers

Try this torrent which uses UDP trackers, after you open it, run netstat.
Comment 9 Jason Carter 2005-08-20 13:37:11 UTC
tcp        0      0 *:45451                 *:*                     LISTEN      30059/ktorrent
udp        0      0 *:45452                 *:*                                 30059/ktorrent
udp        0      0 *:41079                 *:*                                 30059/ktorrent

No idea why there's an extra one on the list. When I first added the UDP torrent, I already had two that jumped up and started going on their own because I had restarted the program.. so maybe that's why this looks a little different. Anyways, this is after just restarting the program with ONLY that UDP torrent you sent.
Comment 10 Joris Guisson 2005-08-20 14:58:17 UTC
These are the ports you selected ? (ignoring the phantom port)
Comment 11 Jason Carter 2005-08-20 15:08:52 UTC
Yes, 45451 and 45452 are the selected ports. Also, it seems the ports are opened even if there are no torrents listed in ktorrent at all.
Comment 12 Joris Guisson 2005-08-21 10:49:17 UTC
Yeah the TCP one is open all the time.

Bug closed, there was no bug.
Comment 13 Jason Carter 2005-08-22 13:35:02 UTC
What about the UDP phantom port that also always seems open and isn't the same as the selected UDP tracker port? Separate bug?
Comment 14 Joris Guisson 2005-08-22 14:25:19 UTC
Ports just don't get opened by accident, so it must be something in the KDE libs which is opening the port. I don't seem to get this phantom port.

Maybe a port used by KHTML to do DNS lookups ? DNS operates over UDP, and if you search something KHTML will have to lookup the IP address of it. But this is just a guess.
Comment 15 Jason Carter 2005-08-24 03:28:56 UTC
Read comment #5 on http://bugs.kde.org/show_bug.cgi?id=111050.
I believe this is the same problem.
Comment 16 Thiago Macieira 2005-08-24 05:40:21 UTC
So why did you reopen both bugs?

This one seems to be fixed. The "phantom port" is actually the one Qt creates for DNS. If Joris were using the KDE API, that port wouldn't show.
Comment 17 Joris Guisson 2005-08-24 10:24:39 UTC
Well I tried to switch to the KDE api, but it only resulted in crashes inside the KDE api. Then a whole bunch of bugs where reported, so I dealt with those first.

Bug closed.