Discussion:
[libtorrent] Does libtorrent support "Hole Punching" ?
linxs
2017-04-25 14:01:37 UTC
Permalink
I want to use libtorrent in project which involves peers without global IPs but local IP(such as 192.168.1.100).
Does libtorrent support "hole punching" to make peers transfer data across router/gateway and so on.
Thanks!
Arvid Norberg
2017-04-26 01:14:19 UTC
Permalink
Post by linxs
I want to use libtorrent in project which involves peers without global
IPs but local IP(such as 192.168.1.100).
Does libtorrent support "hole punching" to make peers transfer data across
router/gateway and so on.
Yes it does.

But keep in mind that hole-punching is not really a "yes" or "no" kind of
feature. There's no hole punching that works with all NATs. BitTorrent's
hole punching is just the most basic, and it requires a shared introducer
peer that's not behind NAT (i.e. a swarm of only NATed peers won't work)
--
Arvid Norberg
linxs
2017-04-26 01:52:48 UTC
Permalink
Thanks!
But what is "a shared introducer peer" ? It is a libtorrent peer too?
Do I need to do some extra work(configure libtorrent, or setup an "introducer peer" server)
to enable libtorrent to "hole punching"?
Post by Arvid Norberg
Post by linxs
I want to use libtorrent in project which involves peers without global
IPs but local IP(such as 192.168.1.100).
Does libtorrent support "hole punching" to make peers transfer data across
router/gateway and so on.
Yes it does.
But keep in mind that hole-punching is not really a "yes" or "no" kind of
feature. There's no hole punching that works with all NATs. BitTorrent's
hole punching is just the most basic, and it requires a shared introducer
peer that's not behind NAT (i.e. a swarm of only NATed peers won't work)
--
Arvid Norberg
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libtorrent-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
Arvid Norberg
2017-04-26 03:09:09 UTC
Permalink
Post by linxs
Thanks!
But what is "a shared introducer peer" ? It is a libtorrent peer too?
What I mean is that for two NATed peers to be able to connect, they both
need to be connected to a 3rd peer that can introduce them to each other.
This is sometimes referred to as the rendezvous peer. The introduction is
done via an extension to the peer-exchange functionality. Both libtorrent
and uTorrent supports this, so it doesn't _have_ to be libtorrent, but some
other peer in the swarm.

Perhaps the most important consequence of this is that you can't have a
swarm with all NATed peers.
Post by linxs
Do I need to do some extra work(configure libtorrent, or setup an "introducer peer" server)
to enable libtorrent to "hole punching"?
no. But if you want higher reliability of it working for swarms entirely
made out of peers behind NAT, then you could build something like that (but
there's no built-in support in libtorrent for it).
--
Arvid Norberg
linxs
2017-04-27 08:30:42 UTC
Permalink
Thanks!

(all peers i used are client_test from libtorrent project)
I did an experiment and find that a NATed peer can transfer data to another peer with global IP. UPnP and NAT-PMP works in this case.
But in another case: a NATed peer (behind router supporting UPnP/NAT-PMP) can not transfer data to another NATed peer(behind router not supporting UPnP/NAT-PMP).
In this case, hole punching does not work. In what kind of situation, hole punching of libtorrent can work?
Post by Arvid Norberg
Post by linxs
Thanks!
But what is "a shared introducer peer" ? It is a libtorrent peer too?
What I mean is that for two NATed peers to be able to connect, they both
need to be connected to a 3rd peer that can introduce them to each other.
This is sometimes referred to as the rendezvous peer. The introduction is
done via an extension to the peer-exchange functionality. Both libtorrent
and uTorrent supports this, so it doesn't _have_ to be libtorrent, but some
other peer in the swarm.
Perhaps the most important consequence of this is that you can't have a
swarm with all NATed peers.
Post by linxs
Do I need to do some extra work(configure libtorrent, or setup an
"introducer peer" server)
to enable libtorrent to "hole punching"?
no. But if you want higher reliability of it working for swarms entirely
made out of peers behind NAT, then you could build something like that (but
there's no built-in support in libtorrent for it).
--
Arvid Norberg
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libtorrent-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
linxs
2017-04-28 01:32:31 UTC
Permalink
Sorry, something wrong is yesterday test.
I do experiment again. It now works for a NATed peer(behind router supporting UPnP, NAT-PMP)
to transfer data to another NATed peer(behind router supporting NAT, but not UPnP, NAT-PMP), and vice versa.
Post by linxs
Thanks!
(all peers i used are client_test from libtorrent project)
I did an experiment and find that a NATed peer can transfer data to another peer with global IP. UPnP and NAT-PMP works in this case.
But in another case: a NATed peer (behind router supporting UPnP/NAT-PMP) can not transfer data to another NATed peer(behind router not supporting UPnP/NAT-PMP).
In this case, hole punching does not work. In what kind of situation, hole punching of libtorrent can work?
Post by Arvid Norberg
Post by linxs
Thanks!
But what is "a shared introducer peer" ? It is a libtorrent peer too?
What I mean is that for two NATed peers to be able to connect, they both
need to be connected to a 3rd peer that can introduce them to each other.
This is sometimes referred to as the rendezvous peer. The introduction is
done via an extension to the peer-exchange functionality. Both libtorrent
and uTorrent supports this, so it doesn't _have_ to be libtorrent, but some
other peer in the swarm.
Perhaps the most important consequence of this is that you can't have a
swarm with all NATed peers.
Post by linxs
Do I need to do some extra work(configure libtorrent, or setup an
"introducer peer" server)
to enable libtorrent to "hole punching"?
no. But if you want higher reliability of it working for swarms entirely
made out of peers behind NAT, then you could build something like that (but
there's no built-in support in libtorrent for it).
--
Arvid Norberg
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libtorrent-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Libtorrent-discuss mailing list
https://lists.sourceforge.net/lists/listinfo/libtorrent-discuss
dave madden
2017-04-26 18:19:00 UTC
Permalink
Post by Arvid Norberg
Perhaps the most important consequence of this is that you can't have a
swarm with all NATed peers.
Hmmm, very interesting. I can see that this would be the case, although
I don't yet understand all the details that make it so.

Suppose I wanted to find the rendezvous peers in a swarm...is there a
reliable way to find some of them? All of them? Who will know who they
are?

Thanks!
--
Mersenne Law · www.mersenne.com · +1-503-679-1671
Small Business, Startup and Intellectual Property Law
9600 SW Oak Street · Suite 500 · Tigard, Oregon 97223
Arvid Norberg
2017-04-28 03:17:49 UTC
Permalink
Post by dave madden
Post by Arvid Norberg
Perhaps the most important consequence of this is that you can't have a
swarm with all NATed peers.
Hmmm, very interesting. I can see that this would be the case, although
I don't yet understand all the details that make it so.
If you can't connect to anyone, you won't have a peer to introduce you to
other NATed peers.
Post by dave madden
Suppose I wanted to find the rendezvous peers in a swarm...is there a
reliable way to find some of them? All of them? Who will know who they
are?
Every peer is a rendezvous peer (as long as it supports the extension).
Most importantly though, non-NATed peers are particularly useful. But
there's nothing stopping a NATed peer from acting as an introducer too, as
long as you manage to holepunch a connection to it.
--
Arvid Norberg
Łukasz Taczuk
2017-04-28 11:35:38 UTC
Permalink
Post by Arvid Norberg
Every peer is a rendezvous peer (as long as it supports the extension).
Is there anything to set up for this to work or is this extension turned on
by default for libtorrent clients?

Which extension exactly is it?
http://www.rasterbar.com/products/libtorrent/features.html
--
Lukasz Taczuk
Arvid Norberg
2017-04-28 12:37:30 UTC
Permalink
Post by Łukasz Taczuk
Post by Arvid Norberg
Every peer is a rendezvous peer (as long as it supports the extension).
Is there anything to set up for this to work or is this extension turned on
by default for libtorrent clients?
No, it's turned on by default as long as you don't override (and clear) the
flag add_default_plugins that's a default argument to the session.
Post by Łukasz Taczuk
Which extension exactly is it?
http://www.rasterbar.com/products/libtorrent/features.html
It's peer-exchange.
--
Arvid Norberg
Loading...