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

Unused TURN allocations #1487

Open
quadriq opened this issue May 10, 2024 · 3 comments
Open

Unused TURN allocations #1487

quadriq opened this issue May 10, 2024 · 3 comments

Comments

@quadriq
Copy link

quadriq commented May 10, 2024

Hi,
I noticed, that if I have TURN Server in ICE credentials. like:

{
    "iceServers": [
        {
            "urls": [
                "stun:some_stun_server:3478"
            ]
        },
        {
            "username": "user",
            "credential": "cred",
            "urls": [
                "turn:myturn.host.com:3478?transport=udp",
                "turn:myturn.host.com:3478?transport=tcp"
            ]
        }
    ]
}

The TURN server usually creates 4 allocations(2UDP + 2 TCP), even if the TURN connection is not needed, because WebRTC clients are in the same network and can communicate via the 'host' candidate. I believe this occurs during the process of gathering all available candidates. These are TURN session allocations, not STUN, as I am certain because I run STUN and TURN servers on different machines.

Now my question is, is there an indicator to filter out those 'unused' sessions on the TURN server? Maybe there is a place in the source code where I can look?

I would like to count the real usage of the TURN server by clients. My first thought was to simply check active TURN allocations, but because the allocation is always there, even the turn server was not really used, I am unsure how to achieve this.

Thank you for any ideas.

@dangngoctam00
Copy link

dangngoctam00 commented May 12, 2024

Hello @quadriq,
I know one way but I haven't tested it carefully, you could check function void turn_report_session_usage(void *session, int force_invalid),

  • active allocation will publish message to peer traffic when ss->received_packets + ss->sent_packets + ss->peer_received_packets + ss->peer_sent_packets == 4096, and 4 values in this expression are not equal 0.
  • inactive allocation will also publish this message, but because they only contain refreshed message, so ss->peer_received_packets + ss->peer_sent_packets will be equal to 0.

you could try this way and give me feedback, like I said above, I haven't tested it carefully.
Thanks

@quadriq
Copy link
Author

quadriq commented May 12, 2024

Hi @dangngoctam00 thank you, I will try it out. Does it actually means that "inactive allocation" would always have peer usage (peer_received_packets and, ss->peer_sent_packets) equal zero ?

@dangngoctam00
Copy link

dangngoctam00 commented May 12, 2024

Hi @quadriq, this is what I've observed but I think you can test it yourself when having host-host candidate, it may take a long time to wait total of refreshed message equals to 4096.
I've tested with turnutils_uclient, here I sent refreshed message only, so the traffic of peer equals to 0.

image

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

No branches or pull requests

2 participants