Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send a UDP Packet with Web RTC - Javascript?

How do you send a UDP Packet using Web RTC?

like image 850
Taurian Avatar asked Nov 04 '12 07:11

Taurian


People also ask

Can Javascript send UDP?

No, you could use any other JS runtime, but you definitely can't send arbitrary UDP packets from a browser context.

Can you use UDP in browser?

UDP packets are not encrypted, so any data sent over these packets could be sniffed and read by an attacker, or even modified in transmit. It would be a massive step back for web security to create a new way for browsers to send unencrypted packets.

Does UDP buffer messages?

On every UDP socket, there's a “socket send buffer” that you put packets into. The Linux kernel deals with those packets and sends them out as quickly as possible. So if you have a network card that's too slow or something, it's possible that it will not be able to send the packets as fast as you put them in!

Does UDP wait for Acknowledgement?

UDP is a byte stream service. It does not know anything about the format of the data being sent. It simply takes the data, encapsulates it into a UDP packet, and sends it to the remote peer. The UDP protocol does not wait for any acknowledgement and is unable to detect any lost packets.


1 Answers

You can't send a UDP packet directly with WebRTC. That would violate the basic security constraints required by the browser.

You can send SRTP to an ICE-enabled host. That is probably not what you are looking for.

If a browser permitted sending arbitrary UDP packets, then malicious applications could send packets to any host.

This might not sound so bad, after all, hosts on the Internet need to be able to deal with that right? The problem is that some browsers are in protected environments where access to the network is restricted. Within those networks, some hosts are far less protected than a host on the public Internet might be. This would be OK, since access to the network is controlled.

If it were possible for a browser to send arbitrary packets, a user on a browser in that environment could be convinced to send specifically crafted packets to one of these poorly protected hosts. Likely, that would result in the network operator banning the browser, which is something browser-makers want very much to avoid.

WebRTC only sends certain types of UDP packet under specific conditions. If the host that you are interested in talking to understands ICE and is able to consume RTP with SRTP or SCTP over DTLS (unlikely methinks). Then perhaps you could force the browser to send something.

like image 188
Martin Thomson Avatar answered Oct 19 '22 15:10

Martin Thomson