-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Order pinger connections for each peer #1899
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very intertwined code, hard to track sequence when executed what.
Can you move all those go routines into functions and comment each function in detail. Especially PingPeer function.
c731dde
to
be37397
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation is based on the increasing TTL up to the 10 on the provider side.
In the real world, these ping from the provider will almost never reach the consumer. The only provider can receive these pings from the consumer.
So the decision of which connections to use is only on one side, which sends OK
to the consumer. This can be changed to send an index too in this message.
Obviously this doesn't work when you are testing everything in 127.0.0.1, because TTL 1 is enough to reach both sides and both peers can receive pings and keep this connection.
This can be resolved by sending OK
response explicitly only from one side.
So my suggestion is to make a decision on one side only which connection to use, instead of doing synchronization between two peers.
@soffokl It set's 128 TTL before doing these sync pings https://github.com/mysteriumnetwork/node/blob/master/nat/traversal/pinger.go#L178 so this should work. PingPeer method itself doesn't describe if this is consumer or provider. I can split it into two separate methods PingProviderV2 and PingConsumerV2 and implement you suggestions as it will simplify logic a lot. Later we will replace old PingProvider and PingConsumer anyway. |
@anjmao it sets TTL to 128 when connection established to notify another peer. The fast hack could be
|
It is ok to assume that all connections might establish. Its one of test cases :) As for identification - both sides have to know which connection is being used for which service. So logic behind this could be:
|
Codecov Report
@@ Coverage Diff @@
## master #1899 +/- ##
==========================================
+ Coverage 47.51% 47.79% +0.28%
==========================================
Files 286 286
Lines 12106 12203 +97
==========================================
+ Hits 5752 5833 +81
- Misses 5876 5888 +12
- Partials 478 482 +4
Continue to review full report at Codecov.
|
c216dac
to
48e9a7e
Compare
fd95e94
to
82bc3f0
Compare
It will allow to ping with the same ttl value for each n connection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code would still benefit from good sequence diagram and / or state machine with all internal go routines. For future generations. Better understandable abstractions helps to think and reason better. Also, if we specify this as "NAT traversal protocol" we would enable better interoperability for future services developed on MMN. Short framework this can be described with is here: http://www.ee.columbia.edu/~nick/EE6777/Chapter.04.Specification.pdf
We could add this as a separate documentation task of cause.
Currently nat pinger pings peer concurrently and returns n connections from max 10 possible (10 ports currently). The problem is that consumer and provider can select connection orders like [1,2] and [2,3] etc. For such cases connections will not match and we can't use them for later communication.
This PR splits PingPeer into PingConsumerPeer and PingProviderPeer and adds logic to notify consumer which connections should be used.