'How to use specified network interfaces for webRTC apps?
I would like to specify network interfaces for RTP stream for a simple webRTC application. I am using webRTC applications on my server-client testbed.
Here is what the testbed topology looks like:
- Server: NIC to external network with public ip 128.x.x.x, and another NIC connected only to the client with ip 192.168.100.1
- Client: NIC to external network with public ip 128.x.x.x, and another NIC connected only to the server with ip 192.168.100.2
My issue:
I would like my server to send RTP traffic only through the link 192.168.100.1 - 192.168.100.2, and as in the git issue@KaptenJansson described, maybe the default gateway setting causes the SDP offer message to show only use public IP addresses of my machines, and the default gateway for my server and client are all 128.x.x.x which I may not change. KaptenJansson suggested to use WebRTC Network Limiter, but I am not sure how to use it to solve my problem.
My questions are:
- Could someone give me some hints that how WebRTC Network Limiter can help here?
- Is it possible to actually modify SDP message to make sure the RTP traffic(media streaming packets) is through the user-defined network interfaces?
- Are there any other possible workaround here?
I am new to webRTC, and thanks in advance for any help!
Solution 1:[1]
Yes, you can modify the SDP offer content before sending it, but i think that it wouldn't help much. One thing you can do is filter the candidates, letting only ones containing local ip addresses.
Another idea is not to configure the ICEs (STUN) so that they dont know their publics ips, although this will not work for the server because it already knows.
The solution may would be a string.include() and check if it has a local ip address like 192.168.x.x, then send it. Here is an example of how you can get it:
pc.onicecandidate = (event) => {
if(event.candidate.candidate.includes('192.168.')) console.log(event.candidate)
};
Inside the callback of the onicecandidate event of the RTCPeerConnnection() object, you can do an if to check if the candidate includes the string 192.168.
And like that, all candidates with public ip addresses will be discarded.
Note: The beginning of the ip address should be according to the local network where the client and server are located.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | alph? |
