Slashdot Mirror


Making BitTorrent Clients Prioritize By Geography?

Daengbo writes "While I live in S.Korea and have virtually unlimited bandwidth in and out of the country, not all my Asian friends are so lucky. Many of the SE Asian and African countries have small international pipes. Even when a user has a high-speed local connection, downloads from abroad will trickle in. Bittorrent clients apparently don't prioritize other users on the same ISP or at least in the same country. Why is that? Is it difficult to manage? If I were to write a plug-in for, say, Deluge, what hurdles would I be likely to come across? If this functionality is available in other clients or through plug-ins, please chime in."

54 of 227 comments (clear)

  1. Azereus already has a plugin for this by dave562 · · Score: 4, Informative

    There is already a plugin for Azereus that does this. I downloaded it about a year ago. I'm at work right now or otherwise I would look at my installation and tell you the exact name of it.

    1. Re:Azereus already has a plugin for this by LSD-OBS · · Score: 4, Informative

      Is that the same plugin that constantly runs a barrage of pings in a hidden shell? Can't remember the name, but I ran a similar sounding plugin and didn't see much speed improvement but it sure did chew up my CPU.

      --
      Today's weirdness is tomorrow's reason why. -- Hunter S. Thompson
    2. Re:Azereus already has a plugin for this by markov_chain · · Score: 5, Funny

      You can tell me, I work in the same place.

      --
      Tsunami -- You can't bring a good wave down!
    3. Re:Azereus already has a plugin for this by dave562 · · Score: 2, Informative

      It probably is the same one. I seem to remember that it was developed as part of a university project. I probably even read about it right here on /. I never checked the background activity so I can't comment on the barrage of pings. I do recall that it didn't make much of a difference in my torrent speeds. I'm on DSL at home and always get consistently good torrent performance.

    4. Re:Azereus already has a plugin for this by mark_hill97 · · Score: 5, Informative

      It is called Ono and it can be found here

    5. Re:Azereus already has a plugin for this by ElizabethGreene · · Score: 2, Interesting

      You could make a whole lot of ISP's happy by prioritizing the "closest" hosts. To do this would require computing the number of hops between the two devices. Ip packets have a ttl header that is (or should be) decremented by each router in the path. A little "magic" would be required since hosts don't universally have a consistent beginning ttl, and some firewalls play with it to obscure the host information. Discovering it shouldn't be too hard though. Another factor could be latency between hosts. This works on the assumption that a packet will have queue delays if it is on a congested link. This isn't always accurate because of high-bandwidth high-latency links. fun,fun,fun. -ellie

    6. Re:Azereus already has a plugin for this by electrosoccertux · · Score: 2, Funny

      Where do you two work, I want to come join you so I can browse /. instead of doing my job. :p

    7. Re:Azereus already has a plugin for this by Sancho · · Score: 4, Interesting

      ISPs actually like P4P. It gives the customers what they want (fast P2P) and it gives the ISPs what they want (less data sent to the tubes that they don't own, and thus reduced costs and overhead.)

    8. Re:Azereus already has a plugin for this by mcnellis · · Score: 5, Interesting
    9. Re:Azereus already has a plugin for this by Guspaz · · Score: 2, Insightful

      The "barrage" of pings may not have been necessary. A good first step is simply running the IPs through a geolocation database. There are various free ones available, and it's a pretty good first step for narrowing things down. They're very effective at getting the country right, and do a decent job at getting you to at least a nearby city.

      From there, if you need farther precision, a single ICMP packet is required to determine the number of hops to a host by checking the TTL. Combine these two things and it shouldn't take much work to get a list of close-by IPs.

      If you're considering connecting to 1000 hosts, it would take just a few seconds (or a fraction of a second) to run them all through a geolocation database, and then a few seconds to send off the thousand pings (while 1000 pings would only require 56KB of data to be sent, you might want to send them out a bit slower than that).

      All in all, I don't see why you couldn't evaluate all the IPs provided by the tracker in a matter of seconds, getting both geographic and network distances to each one. That should then be more than enough information to make decent guesses about what the best IPs to connect to are.

  2. "Prioritizing" by zombietangelo · · Score: 5, Insightful

    IPs could, theoretically, be prioritized based on a database of known general geographies associated with certain digits. Just remember - prioritizing is one thing, but it's a slippery slope to peer exclusion.

    1. Re:"Prioritizing" by evanbd · · Score: 4, Insightful

      Just remember - prioritizing is one thing, but it's a slippery slope to peer exclusion.

      Not really. Prioritize who you request data from, but not who you send it to. If all incoming requests are treated equally, but you only request from the optimal peers, you get all the benefits without any of the omgcensorship fud.

  3. uTorrent by SpitfireSMS · · Score: 5, Informative

    uTorrent has a feature called local peer discovery that does that exactly. It was even able to discover other people at my university sharing the files.

    1. Re:uTorrent by X0563511 · · Score: 5, Informative
      --
      For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
    2. Re:uTorrent by easyTree · · Score: 2, Funny

      But is there really a better torrent client?

      Negative.

    3. Re:uTorrent by GuldKalle · · Score: 2, Interesting

      It's not a plugin, and it doesn't make you more or less likely to get busted. It simply searched the peer list from the tracker and prioritizes peers on the same subnet as you, and optionally removes your throughput limits.
      A good feature, but it doesn't completely solve the problem, since it only works within your local subnet, and is therefore inherently incompatible with NAT.

      --
      What?
    4. Re:uTorrent by lc_overlord · · Score: 2, Interesting

      Well not exactly, it does try to find local users, but that is more or less useless on anything larger than any single localized network, like a university, which is all good and well.
      But i seriously doubt that it optimizes this in a way that takes the network infrastructure in consideration.
      Even though the local peer your downloading from may be your neighbor you might just end up being routed trough Zimbabwe for all utorrent cares at this moment, especially if net neutrality is destroyed.
      And that is not good for anyone.

      --
      - "There is nothing quite like an ineffective solution to an nonexistant problem"
    5. Re:uTorrent by F�an�ro · · Score: 4, Informative

      Local peer Discovery works only within a lan, the corresponding broadcast messages are not routed over the internet

    6. Re:uTorrent by Lundse · · Score: 3, Funny

      You must be root to do that!

      --
      IAIFARSIJDPOOTV - I Am In Fact A Reality Star; I Just Don't Play One On TV
    7. Re:uTorrent by Methlin · · Score: 2

      So you'd rather sacrifice performance, stability, footprint, and automation for shiny progress bars. Got it. Of course you could just use one of the several XMLRPC based GUIs for rtorrent.

    8. Re:uTorrent by __aardcx5948 · · Score: 2, Interesting

      Performance? We're talking downloading files here, not running benchmarks or some shit like that. At 1MiB/s, wine+utorrent uses roughly 3% CPU on my machine, which is nothing. Stability? It hasn't crashed so far in the 1+ year I've used it. Shiny progress bars? No, I've disabled them. I only see "% complete", no progress bar, among my torrents. The GUI is well done, it lets me do what I want and do it fast. I don't have to look for anything, buttons (if I'd use them) are in the right places. Actually I rarely press any buttons, utorrent autoopens any torrent I click on in the webbrowser and shows me a list of files in the torrent, all preselected. Then select files if you don't want them all, and any speed caps etc, press ok. Of course you could disable the box that shows up, if you're not into that sort of thing. IMO when just browsing the web, clicking around, I'd hate to put both hands on the keyboard just to type something in, or enter a key shortcut, when I could just move the mouse pointer somewhere and click a button. Seamless. But hey, maybe you don't use a DE, maybe you use a tiling WM with 2423423 xterms up, coding stuff. Then utorrent would stand out I guess.

    9. Re:uTorrent by Freultwah · · Score: 5, Interesting

      I run rtorrent in a detached screen session on a headless FreeBSD machine tucked away in the closet. I add torrent files to it just by dropping them into rtorrent's watch folder, everything else (starting, stopping, throttle management for off hours) is taken care of automatically. I do not have to have my laptop on or listen to the desktop whine all the time. Plus, rtorrent is blazing fast AND platform agnostic.

      It is also accessible in many ways, ssh being the most obvious, but there are also many GUIs available, with which you can manage torrents from afar. I like it how it is possible to add a torrent to the queue, then take a 3 hour train ride home and find it's all done for you. Magic. So, yes, a torrent client that is run in a terminal can be a Very Good Thing for those who can set it up and use it the way it was meant to be. (And I am pretty sure it was meant to be used that way.)

    10. Re:uTorrent by Free+the+Cowards · · Score: 4, Insightful

      That just means that ws_ftp's GUI is a pile of shit, it doesn't mean that GUIs are inherently slow.

      --
      If you mod me Overrated, you are admitting that you have no penis.
    11. Re:uTorrent by bluefoxlucid · · Score: 2, Insightful

      Actually they're both true. The OS will schedule the whole process, and react to threads; the GUI thread can overtake the network thread and the whole process will get bumped down as a unit once it's used its CPU allotment. Bad network protocol behavior, reacting to too much i/o demand, etc, and the OS will schedule a lot more CPU time to the GUI and slow down network transmission; bad programming in the UI can also affect this. In either case, the presence of a GUI or extremely active text UI will slow down network activity; it's usually by a very small amount if everyone did their homework, but it's present, even in Firefox vs. wget.

  4. Ono by pythonax · · Score: 5, Informative

    There is a plugin for Vuze (formerly Azureus) called Ono which does exactly that. Not sure what the problems they ran into, but as it is a college project I am sure they would be willing to discuss some of it with you. http://www.aqualab.cs.northwestern.edu/projects/Ono.html

  5. Non-geo-ip by rbanffy · · Score: 3, Interesting

    One would not even need to prioritize by geographic location: the client could easily give extra priority points by network class: C first, then B, then A, then the rest. The odds of having a very fat pipe to another machine in the same class C are far better than having a fat pipe to a random machine across the planet.

    And that would also alleviate the load on backbone links.

    1. Re:Non-geo-ip by VGPowerlord · · Score: 2, Informative

      That doesn't work well with networks split with CIDR. For example, the 24.x.y.z block is in the Class A address range, but it's not a class A block.

      --
      GLaDOS for President 2016! "Well here we are again. It's always such a pleasure." -- GLaDOS, 2011
  6. They should prioritize by altitude by Anonymous Coward · · Score: 4, Funny

    That way they can take advantage of the tendency of IP packets to flow downhill.

  7. Already Made "Ono" by StarWreck · · Score: 4, Informative

    What you're looking for is an Azureus plugin called "Ono". It prioritized based on router hops. Theoretically, this would make those connected to the same ISP preffered. After that it would make ISP's with direct connections to your ISP preferred. After that, resonably close geographically, ie same country.

    --
    ... and in the DRM, bind them.
    1. Re:Already Made "Ono" by drchoffnes · · Score: 2, Informative

      For the record, it's not quite based on router hops. Ono exploits CDN redirections for very efficient peer baising. You can find the technical details here: http://www.aqualab.cs.northwestern.edu/publications/DChoffnes08Sigcomm.html Also, if you want to restrict biasing to a custom set of IP address blocks, Ono now supports "manual peer biasing" toward those blocks. A description of how to use this feature (tailored for Kiwis) is here: http://homepages.xnet.co.nz/~createcoms/

  8. Latency? Hops? by Midnight+Thunder · · Score: 3, Interesting

    How good is latency or hops as indicator of distance from peer? The idea is that if it takes 5 hops, as opposed to 10, then the peer taking the least hops to get to is the closest.

    --
    Jumpstart the tartan drive.
  9. For Vuze, there's Ono and P4P by chrysrobyn · · Score: 5, Informative

    For Vuze, formerly Azureus, there are Ono and P4P, which should do what you're looking for, although for different reasons. Unfortunately, they both rely on people in your region being interested in the same torrents you are, while P4P additionally benefits from an iTracker, an ISP provided tracker that's topology aware (they did some work to prioritize based on ping latency, using that as a distance estimate, but I don't know if it's a fallback mechanism). Due to the iTracker infrastructure and possibly conflicting supporters, there are some privacy concerns.

  10. Geolocation libraries by VGPowerlord · · Score: 2, Informative

    "Bittorrent clients apparently don't prioritize other users on the same ISP or at least in the same country. Why is that? Is it difficult to manage?"
    The reason BitTorrent doesn't prioritize other users on the same ISP or the same country is that it doesn't know which ones are part of the same ISP or the same country. For ISPs, since the introduction of CIDR addresses, ISPs can have multiple blocks of IPs. Can you honestly tell me what all of, say, Comcast's IP blocks are with any degree of certainty?

    For countries, you either need to know which IP blocks IANA has allocated to which IP registry or use a geolocation library.

    MaxMind's GeoIP seems to be the de facto geolocation library, but they charge money for the "good" version. There is a free version now, but it has some annoying requirements, such as having to include "This product includes GeoLite data created by MaxMind, available from http://maxmind.com/" in all advertising materials and documentation. It also only has a 99.5% accuracy as claimed by its creators, which means the the accuracy is probably considerably lower than they claim. Even if it were 99.5%, that means it's wrong for 1 out of every 200 people.

    --
    GLaDOS for President 2016! "Well here we are again. It's always such a pleasure." -- GLaDOS, 2011
    1. Re:Geolocation libraries by yachius · · Score: 3, Insightful

      The 99.5% accuracy number is considerably greater than 1/200. The accuracy figure is not a percentage of lookups that are incorrect, but of how close to the correct physical location the query result will be. Even the .5% of wrong locations won't be on the wrong side of the planet so it still makes for a very useful resource for figuring out regions.

  11. Why don't the ISPs help? by PhrostyMcByte · · Score: 4, Insightful

    I've always wondered why ISPs can't give higher speeds if you stay within their network. You'd get your download faster. You'd use less peering bandwidth, costing the ISP less money. Everybody wins.

    1. Re:Why don't the ISPs help? by larry+bagina · · Score: 5, Funny

      Better yet, ISPs should just snail mail their customers linux cds/dvds. That would basically eliminate all torrent traffic.

      --
      Do you even lift?

      These aren't the 'roids you're looking for.

    2. Re:Why don't the ISPs help? by MooseMuffin · · Score: 5, Funny

      And then they could work on snail mailing truckloads of porn. That would basically eliminate all other traffic.

  12. Re:Stop It by Sparr0 · · Score: 5, Insightful

    Prioritize by network topology is a better way to put it, that just happens to coincide with physical AND political geography in many cases. In the case where you can get 10Mb over a 10-hop connection, or 8Mb over a 3-hop connection, which do you pick? If you pick the latter, there is a good chance that two other users can utilize the other 70% of that 10-hop connection, making total throughput (theoretically) 24Mb.

  13. Re:Stop It by Anonymous Coward · · Score: 2, Interesting

    No. Prioritize by ASN. A smart tracker would get a BGP feed and then hook users together based on locality of network connectivity.

    Any other approach is "wrong."

  14. Because it's a pointless thing to do by Nick+Ives · · Score: 4, Insightful

    If your ISPs international pipe is flooded then bittorrent will automatically prefer local peers as they'll be the only people who can send you data at a fast enough rate. If you notice local peers who you're not connected to then it's most likely just because they've already reached their connection limit.

    Most bittorent clients will connect to many peers and try to saturate your downstream bandwidth. They don't care where in the world those peers are as long as they're fast. If, in your part of the world, local peers are faster then that means you should just automatically connect to more local peers.

    --
    Nick
  15. Re:You Asians Have Big Pipelines by OpenYourEyes · · Score: 4, Funny

    But we American get email all the time offering to make our pipeline bigger!

  16. Napster's Old Peer Selection by Aloisius · · Score: 5, Interesting

    At Napster I wrote a system to weight peers that were closer to the person searching by using network distance.

    It was mostly because universities were complaining and so we weighted everyone on Internet 2 towards each other, but it also worked quite well for service providers like @Home and AOL. Since ISPs don't seem to care as much when their own bandwidth is used, a lot of complaints about our bandwidth consumption disappeared overnight. Indiana state university and someone else helped out if I remember correctly.

    It was a rather simple system that used BGP routing tables from a number of routers to build a graph of network connectivity. It wasn't perfect, but it didn't have to be.

    That said, with IPv6 weighting is *much* easier because of how the IP space is divided up. You can do a super naive implementation just by prefix.

    An Azureus plugin Ono does something similar, though I believe they just look up the IP address for a CDN and weight people that look up the same IP towards each other. It is a decent solution, but it only works for between people who are running the plugin.

  17. Tune your TCP Receive Window first by WinDev · · Score: 5, Informative

    The biggest speed issue facing Asia/Australia is the latency of traffic to the rest of the planet. The (Windows) TCP Receive Window is tuned too small for the distances required. If you change the receive window to the maximum, you can get 4x more data in the same period using any client (P2P, browsers, etc...).

    Refer to:
    http://cable-dsl.navasgroup.com/index.htm#IncreasingWindow

  18. Re:Stop It by Anonymous Coward · · Score: 2, Insightful

    I'm, I'll, can't, it's?

    Autonomous System Number. I don't think it helps much either way. You either know what it means or you don't. Also, Border Gateway Protocol.

  19. They're MY bits, not YOURS by PJ+The+Womble · · Score: 3, Interesting

    When I was in my first year at college, we were asked to produce a questionnaire about using ATMs, including the question: "If you could change one thing about your bank's ATMs, what would it be?"

    The most popular answer I managed to get was "if the machine's running out of money, they should restrict the cash withdrawal function to customers of this branch".

    Does anyone see a parallel here?

    1. Re:They're MY bits, not YOURS by PJ+The+Womble · · Score: 2, Funny

      I went to University of Teesside for 3 years. Have you ever been to Middlesbrough? It's grey, cold and wet in July, and the rest of the year the weather is *really* depressing. They're not the most optimistic people in the world. Even free money wouldn't improve their stoical disposition, IMHO.

    2. Re:They're MY bits, not YOURS by fred+fleenblat · · Score: 2, Funny

      I just want to see the see-through pneumatic tubes make a comeback.
      Or at least the ATM should make that THUMK sound when the cash is dispensed.

  20. Won't work by Andy+Dodd · · Score: 2, Insightful

    There is little to no support for multicast by last-mile ISPs.

    It would be nice - ISPs keep bitching about how P2P is eating their bandwidth, but they don't bother implementing multicast which would make P2P use a fraction of the bandwidth it currently does.

    Admittedly, in addition to lack of support, IPv4 multicast is pretty "meh" - there aren't many multicast addresses available and I have yet to see a good way of choosing/assigning them on a global network.

    --
    retrorocket.o not found, launch anyway?
    1. Re:Won't work by bluefoxlucid · · Score: 2, Insightful

      It would be nice - ISPs keep bitching about how P2P is eating their bandwidth, but they don't bother implementing multicast which would make P2P use a fraction of the bandwidth it currently does.

      I believe you mean P2P uses a fraction of the bandwidth it would if we had multicast. I have a constant upstream of 200k/s, to 5 clients, each getting 40k/s down from me. With multicast, I could have a constant upstream of 200k/s, to 5 clients, each getting 200k/s from me. This means I would send 200k/s up; my router would route for about 6 hops, then send duplicate packets out to 5 different routers from that hop, which would then send 200k/s down to various points on the Internet. Instead of consuming 200k/s + 200k/s, I'd consume 200k/s + 1000k/s. Further, if 100 people want to download that file at once, I can handle 200k/s transfer to 100 people, and 3 other people can do such, and they can download the file at 600k/s, and really clog the tubes.

      It'd be faster, but it'd chew a hell of a lot more bandwidth at once. The DoS potential would be massive.

    2. Re:Won't work by Andy+Dodd · · Score: 3, Informative

      Look at it from a different perspective - 100 people want one file of size A megabytes, and you start with one person seeding.

      With classic unicast distribution, 100*A needs to be sent by that one person.

      With P2P, much less needs to be sent, but still 100*A needs to traverse the network. It may or may not traverse fewer hops - it may in fact traverse more.

      With multicast, A megabytes leave the single origin, and that gets multipled by routers as needed in the most efficient manner. In the end, the least amount of data needs to be sent in order for everyone to achieve completion. Yes, in the short term the network load will probably not be reduced much, but the time that high load occurs for will be far less before everyone has the file and there is little need for lots of bandwidth.

      --
      retrorocket.o not found, launch anyway?
  21. Re:ISP's are against local serving by nabsltd · · Score: 2, Insightful

    Extending a business partnership with them, and convincing them that they CAN allow users to serve content without choking their already oversold bandwidth

    This is fairly easy to do right now eith US ISPs...it's called a "business account".

    They do cost more, but in my case I get 5 static IPs, guaranteed bandwidth, and no interference of any kind with my data (no port blocking, no throttling, and no caps) for $140. Compared to the non-business version with one dynamic IP, port blocking and some throttling (but no caps yet) at $70, it's not a bad deal.

  22. That isn't what ono does by Nick+Ives · · Score: 2, Interesting

    Ono uses statistical data from CDNs to be a little bit smarter about picking peers in certain cases. In most cases the random solution is fine; your client can just randomly pick peers then stick with fast ones and drop slow ones. Ono aims to improve performance in certain cases where that strategy isn't very good.

    Just in case anyone reading doesn't notice, Ono aims to find peers that are close to you on the network. That doesn't necessarily mean close to you geographically and so doesn't answer this ask /..

    --
    Nick
  23. 2 meg data file could solve most of this! by WittyName · · Score: 2, Interesting

    And I proposed it for two popular BitTorrent clients, only to be told, "we don't need that.."

    Simple enough to do. Start with Class C address.. less then 2^24 of them, as some
    are reserved, and not routable. Make a bitmap that big, so divide by 8.
    Only a two meg file. Then just watch your connections, total by bytes received, then divide by 8. If the result is greater than say 1 kb/sec sustained, then
    set the appropriate bit to true. Allow the bitmap to be zeroed if you move or whatever.

    After getting the list of peers, prioritize connection attempts towards those
    that have a useful sustainable rate. Nothing worse than seeing 80% of my
    connections saying connected 30 minutes, 100 KB transferred. Sigh.

    While in china, I had a 2 mb connection. But too many Chinese hammering it, so
    I could sustain, 2 mbit up, and 1 mbit down. Asymmetric the wrong way..

    Seems blindingly obvious to me, yet I still see no clients with this feature.

    --
    The law is a weapon of the government, not a protection for the likes of you. Surely you understand that.
  24. Re:Stop It by AmberBlackCat · · Score: 2, Interesting

    I think they've got it all wrong. The software shouldn't be connecting people to nodes in their area. It should be connecting people to nodes in regions that can't sue them for uploading.