Skip to content
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

Implement Active TCP-ICE #394

Closed
wants to merge 1 commit into from
Closed

Implement Active TCP-ICE #394

wants to merge 1 commit into from

Conversation

ashellunts
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Oct 24, 2021

Codecov Report

Base: 78.23% // Head: 77.13% // Decreases project coverage by -1.10% ⚠️

Coverage data is based on head (1542ccb) compared to base (c0be5d1).
Patch coverage: 35.48% of modified lines in pull request are covered.

❗ Current head 1542ccb differs from pull request most recent head ed64aab. Consider uploading reports for the commit ed64aab to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #394      +/-   ##
==========================================
- Coverage   78.23%   77.13%   -1.10%     
==========================================
  Files          36       36              
  Lines        4273     4348      +75     
==========================================
+ Hits         3343     3354      +11     
- Misses        723      779      +56     
- Partials      207      215       +8     
Flag Coverage Δ
go 77.13% <35.48%> (-1.10%) ⬇️
wasm ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
agent_config.go 82.14% <ø> (ø)
selection.go 80.09% <0.00%> (-1.11%) ⬇️
agent.go 79.40% <17.02%> (-3.02%) ⬇️
candidate_base.go 86.84% <33.33%> (-1.00%) ⬇️
tcp_packet_conn.go 75.12% <40.00%> (-0.90%) ⬇️
gather.go 63.81% <47.45%> (-2.55%) ⬇️
candidate_host.go 93.47% <100.00%> (+0.62%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ashellunts
Copy link
Contributor Author

@dgunay were you able to make a successful connection?

agent_config.go Outdated Show resolved Hide resolved
agent.go Outdated
@@ -130,6 +131,10 @@ type Agent struct {
insecureSkipVerify bool

proxyDialer proxy.Dialer

tcpConnections map[string]net.Conn
Copy link
Member

Choose a reason for hiding this comment

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

I would store the tcpConnections inside the Active TCP candidate. Would love to avoid putting more state in the Agent itself

Does Chrome expose the ports it dialed on?

@ashellunts
Copy link
Contributor Author

TCP connection is ready and some messages are sent over the connection. But after first messages a connection freezes.
Here are logs:

artur@hp:~/git/ice$ go test -v -run TestActiveTCP
=== RUN   TestActiveTCP
[::]:7686
ice INFO: 2021/11/06 15:30:13 Listening TCP on [::]:7686
ice DEBUG: 15:30:13.695553 gather.go:178: GetConn by ufrag: FEtegJZjVRZGzPra
ice INFO: 2021/11/06 15:30:13 Ignoring remote candidate with tcpType active: tcp4 host 192.168.1.205:0
ice DEBUG: 15:30:13.696273 agent.go:455: Started agent: isControlling? true, remoteUfrag: "FEtegJZjVRZGzPra", remotePwd: "ftOozEzvZGmnzadZAWssKPCcgjcSWMxe"
ice INFO: 2021/11/06 15:30:13 Setting new connection state: Checking
ice DEBUG: 15:30:13.697976 agent.go:832: count of local candidates 1
ice DEBUG: 15:30:13.698086 agent.go:655: artur, addPair: local tcp4 host 192.168.1.205:0, remote tcp4 host 192.168.1.205:7686
ice DEBUG: 15:30:13.698121 agent.go:657: artur, addressToConnect 192.168.1.205:7686
ice DEBUG: 15:30:13.698477 agent.go:455: Started agent: isControlling? false, remoteUfrag: "SmxZXyxixwugeuYO", remotePwd: "vuSCEihcZbhTAruaftQdOjGwwLTGjyTx"
ice INFO: 2021/11/06 15:30:13 Setting new connection state: Checking
ice DEBUG: 15:30:13.698633 tcp_mux.go:96: Accepted connection from: 192.168.1.205:48332 to 192.168.1.205:7686
ice WARNING: 2021/11/06 15:30:13 pingAllCandidates called with no candidate pairs. Connection is not possible yet.
ice DEBUG: 15:30:13.698976 agent.go:664: artur, socket connected, local 192.168.1.205:48332, remote 192.168.1.205:7686
ice INFO: 2021/11/06 15:30:13 AddConn: tcp 192.168.1.205:7686
ice DEBUG: 15:30:13.700550 tcp_mux.go:186: msg attr: USERNAME: 0x46457465674a5a6a56525a477a5072613a536d785a58797869787775676575594f
ice DEBUG: 15:30:13.700761 tcp_mux.go:186: msg attr: ICE-CONTROLLING: 0xfd3cd86a20f35b19
ice DEBUG: 15:30:13.700822 tcp_mux.go:186: msg attr: PRIORITY: 0x7edfffff
ice DEBUG: 15:30:13.700864 tcp_mux.go:186: msg attr: MESSAGE-INTEGRITY: 0xd2b0404f181edfd6b04dd6a9b88fbdcaef27269e
ice DEBUG: 15:30:13.700901 tcp_mux.go:186: msg attr: FINGERPRINT: 0x623cd098
ice DEBUG: 15:30:13.700942 tcp_mux.go:197: Ufrag: FEtegJZjVRZGzPra
ice INFO: 2021/11/06 15:30:13 AddConn: tcp 192.168.1.205:48332
ice DEBUG: 15:30:13.701497 agent.go:1134: adding a new peer-reflexive candidate: 192.168.1.205:48332 
ice DEBUG: 15:30:13.701601 agent.go:832: count of local candidates 1

May be connection works only in 1 direction yet?

@ashellunts
Copy link
Contributor Author

@Sean-Der please take a look on new implementation.

@ashellunts
Copy link
Contributor Author

I see that pair nomination is not performed.

@ashellunts
Copy link
Contributor Author

Finally first working version (that goes to connected state).

@Sean-Der
Copy link
Member

Sean-Der commented Nov 8, 2021

holy shit! amazing work @ashellunts this is so exciting :)

I should have some time later today. sorry about the delay. This is really great. Will make clients better, and really excited to see coverage for servers improve.

@ashellunts ashellunts force-pushed the active-tcp-ice branch 2 times, most recently from 79392b9 to bc02898 Compare November 8, 2021 16:53
@ashellunts
Copy link
Contributor Author

holy shit! amazing work @ashellunts this is so exciting :)

I should have some time later today. sorry about the delay. This is really great. Will make clients better, and really excited to see coverage for servers improve.

Thanks. 2 days debugging finally worked out :D

@ashellunts
Copy link
Contributor Author

For now it works only if you have only 1 network interface 😭

agent_config.go Outdated
@@ -50,7 +50,8 @@ func defaultCandidateTypes() []CandidateType {
// AgentConfig collects the arguments to ice.Agent construction into
// a single structure, for future-proofness of the interface
type AgentConfig struct {
Urls []*URL
activeTCP bool
Copy link
Member

Choose a reason for hiding this comment

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

DisableActiveTCP

By default we should enable Active TCP

@Sean-Der
Copy link
Member

Sean-Der commented Nov 9, 2021

@ashellunts This looks really good! If you can fix the linter and test failures I think we can merge this really soon :)

agent.go Outdated Show resolved Hide resolved
agent.go Outdated Show resolved Hide resolved
agent.go Outdated Show resolved Hide resolved
a.log.Infof("Ignoring remote candidate with tcpType active: %s", c)
return nil
}
// if c.TCPType() == TCPTypeActive {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be deleted?

candidate_base.go Outdated Show resolved Hide resolved
@dgunay
Copy link

dgunay commented Dec 5, 2021

@Sean-Der addressed some comments and linter errors. There are still a few concurrency bugs it looks like.

@ashellunts
Copy link
Contributor Author

@dgunay Thank you so much for continuing the work!

@dgunay
Copy link

dgunay commented Mar 15, 2022

EDIT: nevermind, I've clearly forgotten how this PR works, it already initiates TCP connections - I'll keep digging

@dgunay
Copy link

dgunay commented Mar 15, 2022

Best I can tell for now is that none of the candidates are being nominated.

@stv0g
Copy link
Member

stv0g commented Feb 4, 2023

I am excited to see that you picked up the PR @ashellunts

Let me know if I can support with testing, reviewing or something else :)

@ashellunts
Copy link
Contributor Author

Thanks. I will appreciate if you can read PR changes and maybe notice something completely wrong.

Sometime ago I had the test passing. Now it doesn't work. And I am debugging to understand what is going on.

agent.go Show resolved Hide resolved
agent.go Show resolved Hide resolved
@stv0g
Copy link
Member

stv0g commented Feb 4, 2023

Thanks. I will appreciate if you can read PR changes and maybe notice something completely wrong.

I will dig into the RFC a bit more into detail later.

Something which confused me a bit: Does an agent always pick the active or the passive role? I thought it would make more sense to active & passive candidates gathered by the same agent.

@ashellunts
Copy link
Contributor Author

Not sure. But for me it looks logical to have either passive agent or active one.

@stv0g
Copy link
Member

stv0g commented Feb 4, 2023

Not sure. But for me it looks logical to have either passive agent or active one.

I've had a look at RFC6544, which is mainly concerned about active/passive/so TCP candidates for ICE. Not about active/passive agents.
I think we do not need to have an extra activeTCP flag as there the agent is already configured NetworkTypes and CandidateTypes to limit type of candidates or transport protocols.

We might want to think about maybe adding TCPCandidateTypes option which with the following options:

  • TCPCandidateTypeActive
  • TCPCandidateTypePassive
  • TCPCandidateTypeSimultaneousOpen

The reason why I am proposing this change is, that in my application I have might have situations in which each side of the P2P connection is/is-not dialable from the outside. So determine the role is not feasible beforehand and would require a complex role-conflict resolution (just like for Lite ICE agents).

Hence, I think its easier to generate all types of TCP candidates in the first place. And allow the user to limit those by the settings which I mentioned above.

@ashellunts
Copy link
Contributor Author

Not sure. But for me it looks logical to have either passive agent or active one.

I've had a look at RFC6544, which is mainly concerned about active/passive/so TCP candidates for ICE. Not about active/passive agents. I think we do not need to have an extra activeTCP flag as there the agent is already configured NetworkTypes and CandidateTypes to limit type of candidates or transport protocols.

We might want to think about maybe adding TCPCandidateTypes option which with the following options:

  • TCPCandidateTypeActive
  • TCPCandidateTypePassive
  • TCPCandidateTypeSimultaneousOpen

The reason why I am proposing this change is, that in my application I have might have situations in which each side of the P2P connection is/is-not dialable from the outside. So determine the role is not feasible beforehand and would require a complex role-conflict resolution (just like for Lite ICE agents).

Hence, I think its easier to generate all types of TCP candidates in the first place. And allow the user to limit those by the settings which I mentioned above.

Thank you for the feedback. Sounds good.

@ashellunts ashellunts mentioned this pull request May 7, 2023
@ashellunts
Copy link
Contributor Author

Created another PR instead of this one: #565

@ashellunts ashellunts closed this May 9, 2023
@ashellunts ashellunts deleted the active-tcp-ice branch May 24, 2023 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants