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 ICE-TCP #293

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

Sean-Der
Copy link
Contributor

This is going to take me a while, but I wanted to check in before I started!

I am going to implement both active + passive. My reasoning is I want to be able to test it E2E.

I don't have any hard ideas/opinions on how it should be implemented. Do you have any advice as I learn the code base?

@Sean-Der Sean-Der force-pushed the ice-tcp branch 2 times, most recently from 2e10e4d to eba7075 Compare January 22, 2025 03:23
@Sean-Der
Copy link
Contributor Author

@paullouisageneau Looking at the different modes conn types (Poll/Thread/Mux) it seems unlikely I would succeed putting the concept of TCP into them.

Should I create something multi-threaded that does TCP as its own thread/struct?

@Sean-Der Sean-Der closed this Jan 22, 2025
@Sean-Der Sean-Der reopened this Jan 22, 2025
@paullouisageneau
Copy link
Owner

paullouisageneau commented Feb 4, 2025

OK, this is complicated because the whole library is designed with the assumption that candidates can only be UDP. It would be way simpler to implement TURN TCP.

I think you can't realistically implement something on the side running in its own thread. It seems to me the best way to implement this is to add optional TCP sockets for each agent to the thread and poll connectivity backends (I don't think mux mode can have TCP candidates as you would have to create new sockets).

TCP sockets would be polled and read by the backend. A lot of functions assume addresses are UDP only, like conn_get_addrs() and agent_conn_recv(), you will probably need to introduce a socket type in addr_record_t to distinguish between UDP and TCP.

You would then need to modify the logic to match candidates pairs properly. You would probably need to introduce a function to order the backend to actively connect to a remote TCP address.

Again, this is complicated and requires fundamental changes, contrary to TURN TCP (as candidates are still UDP in that case).

typedef enum juice_ice_tcp_mode {
JUICE_ICE_TCP_MODE_NONE = 0, // ICE-TCP is disabled
JUICE_ICE_TCP_MODE_ACTIVE, // ICE-TCP will operate as a client
JUICE_ICE_TCP_MODE_PASSIVE, // ICE-TCP will operate as a server
Copy link
Owner

Choose a reason for hiding this comment

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

As I understand TCP candidates are not exclusive. An agent may gather both active, passive (and possibly simultaneous open) candidates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They can be! I believe browsers only do active TCP. They don't accept inbound TCP connections.

@Sean-Der
Copy link
Contributor Author

Sean-Der commented Feb 9, 2025

It would be way simpler to implement TURN TCP.

Requiring users to run TURN servers would make for a worse ecosystem. It wouldn't be fatal, but I would have regret for pushing the complexity onto everyone.

Many WebRTC implementations don't support adding TURN servers after the setLocalDescription (gathering locally). This means that for WHIP I would have to ask users to support both OPTIONS + POST (for returning TURN servers).

If we do ICE-TCP users don't have to run additional TURN servers with all the extra infrastructure needed to make it work. I hope you think that's a good enough justification to add this to lib juice.

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.

2 participants