Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

readme <3 #11

Merged
merged 2 commits into from
Apr 12, 2016
Merged

readme <3 #11

merged 2 commits into from
Apr 12, 2016

Conversation

hackergrrl
Copy link
Contributor

addresses part of ipfs/js-ipfs#116

@hackergrrl
Copy link
Contributor Author

Still pending: documenting peer.addSafe().

@diasdavid what is this?

@daviddias
Copy link
Member

re: peer.addSafe()

It is to save from multiaddr explosion

what is a "multiaddr explosion"? What is this trying to protect from happening? https:/diasdavid/js-peer-info/blob/master/src/index.js#L37

multiaddr explosion is when you have peers that tell you they see you in a certain addr, but pretty much only then can see you that way ( network topologies ) so we always confirm two times before saying that a multiaddr is valid

@hackergrrl
Copy link
Contributor Author

Could you take another angle at explaining this again? Is this related to NATs?

@daviddias
Copy link
Member

First, are you familiar with the Identify protocol, why it exists and how does it work?

@hackergrrl
Copy link
Contributor Author

This is the only information I can find about Identify. I'm unclear on what "observed addresses" are in this context.

@daviddias
Copy link
Member

Got it. Identify is to help NAT traversal. We keep exchanging the "Addresses that we see with the peers we connect", it is like STUN, but every time you connect to a peer.

Since we reuse the port for incoming connections, if two peers try to connect to each other, eventually, they will get through a NAT. This is not the perfect solution, as typical hole punching means that you have a way to notify the other peer you are trying to dial them, so that both try to pierce the NAT at the same time (having one of the sides failing on the first try, and succeeding on the second), but this has given us some very good results that have kept us from having to go with more advanced NAT traversal implementations for a while.

However, the number of addrs that we get from other peers that connected to us vary greatly and if two peers are in the same LAN, their respective observed addrs are pretty much irrelevant for the rest of the network, as no one else will be able to dial to them from their local area network, so we use the addSafe to save us from multiaddr explosion, which is filling up our list of multiaddrs with addresses that are of little value. Note that also, LANs have subnets IPs pretty much standardised, it can could be annoying announcing to the network that you are available in a 192.168.. IP, because then other peers would try to dial to non existing peers in their subnets.

Hope this helped :)


Adds a new multiaddress that `peer` can be reached at.

..Safely? **TODO**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add this:

The addSafe call, in comparison to the add, will only add the multiaddr to the list of multiaddrs available, if the same multiaddr gets added twice. This is a simple mechanism to prevent 'multiaddr explosion', a phenomenon that happens when we exchange observed addrs with peers which will not provide a useful multiaddr to be shared to the rest of the network (e.g. inside LANs).

@hackergrrl
Copy link
Contributor Author

Ah, I see now. Thank you for explaining! <3

@daviddias
Copy link
Member

No problem. Thank you for adding this :):)

@daviddias daviddias merged commit 140c4ed into libp2p:master Apr 12, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants