How long is the heartbeat interval of SCTP in WebRTC? - webrtc

WebRTC DataChannels use SCTP. Looking at the graph of bits received from chrome://webrtc-internals, there is a regular sending of a small amount of data. Is this the SCTP heartbeat?

From what I understand, this is the ICE heartbeat.

I am just elaborating Sam's answer.
WebRTC DataChannel uses Stream Control Transport Protocol (SCTP) for sending
and receiving arbitrary data. Since, WebRTC requires that all WebRTC traffic be
encrypted, DTLS is used. However, most routers and NAT devices don't handle this
protocol well. Hence, SCTP is tunneled over DTLS and UDP. Now, even when two
peers are exchanging arbitrary data, it is happening over UDP. Hence, I too
believe that it is not a SCTP heartbeat.
As you might know, RTCPeerConnection uses ICE for resolving connectivity issues between
peers. ICE uses STUN keep-alives to check the connectivity status between
the peers. Currently, I believe chrome sends out STUN Binding Request every 450 ms to perform connectivity checks, but there is an ongoing discussion on extending that time interval.

Related

Should I worry about home routers support of RTCDataChannel? [duplicate]

I saw that SCTP is going to be used for Data Channels starting in Chrome 31, and officially RTP based channels are going to be deprecated sometimes in February 2014 according to this google group thread:
https://groups.google.com/forum/#!topic/discuss-webrtc/y2A97iCByTU
Does this also mean that webrtc audio and video channels are also going to be transported over SCTP eventually(if not already in the works)?
How does RTP fit in the whole SCTP transport effort? Does that mean SRTP packets will flow over SCTP data channel? Or perhaps just the payload will be sent over SCTP transport protocol.
If I am reading info on SCTP, it combines best of TCP and UDP protocols; but it does not include encryption by default; so in mind the traffic flowing over should still be encrypted.
Any additional info would be helpful. Thanks!
The audio and video will keep going over RTP (actually SRTP which is the secure version or RTP) but the data channel will uses SCTP over DTLS over UDP. Both Firefox and Chrome are implementing this and you can find it described in the IETF draft specifications. For some types of NAT / Firewall traversal, the UDP packets may get tunneled in TURN over TCP.
Glad to provide you pointers to the draft specifications if that helps.
SCTP stands for Stream Control Transmission Protocol.
SCTP as a protocol can be seen as a hybrid of UDP and TCP.
At its core, SCTP holds the following characteristics:
Connection oriented. Similar to TCP, SCTP is connection oriented. It also offers a multi-homing capability that isn’t used by WebRTC
Optional reliability. Reliability is optional in SCTP and is up to the implementer using SCTP to decide if he needs this capability or not
Optional ordering. Ordering of packets sent via SCTP is optional and is left for the implementer to decide if this is necessary for him or not
Message oriented. SCTP makes sure that each message sent is properly parsed on the receiver end in the same manner in which it was sent
Flow control. Similar to TCP, SCTP provides a flow control mechanism that makes sure the network doesn’t get congested
SCTP is not implemented by all operating systems. In such cases, an application level implementation of SCTP will usually be used.
SCTP is used in WebRTC for the implementation and delivery of the Data Channel.
Google is experimenting with the QUIC protocol as a future replacement to SCTP

Is RTCDataChannel when configuration reliable = true faster then Websockets?

I was reading and trying to find out about WebRTC's RTCDataChannel. As I understand Websockets are on top of TCP and have higher latency than SCTP that underlies WebRTC, when for example sending binary data between server and browser, that also could be 2 peers in WebRTC. When RTCDataChannel is set to unreliable mode (possible package loss but faster), its underlying SCTP becomes analogous to User Datagram Protocol (UDP) and when set to reliable it becomes TCP-like.
Is RTCDataChannel, when configured to be reliable (“TCP-like”), still faster then Websockets (TCP) and if so, how much faster?

WebRtc client to server connection

I'm going to implement Java VoiP server to work with WebRtc. Implementation of browser p2p connection is really straightforward. Server to client connection is slightly more tricky.
After a quick look at RFC I wrote down what should be done to make Java server as browser. Kindly help me to complete list below.
Implement STUN server. Server should be abke to respond binding
request and keep-alive pings.
Implement DTLS protocol along with DTLS handshake. After the DTLS
handshake shared secret will be used as keying material within SRTP
and SRTCP.
Support multiplexing of SRTP and SRTCP stream. SRTP and SRTCP use
same port to adress NAT issue.
Not sure whether should I implement SRTCP. I believe connection will
not be broken, if server does not send SRTCP reports to client.
Decode SRTP stream to RTP.
Questions:
Is there anything else which should be done on server-side ?
How webRtc handles SRTCP reports ? Does it adjust sample rate/bit
rate depends on SRTCP report?
WebRtc claims that following issues will be addressed:
packet loss concealment
echo cancellation
bandwidth adaptivity
dynamic jitter buffering
automatic gain control
noise reduction and suppression
Is is webRtc internals or codec(Opus) internals? Do I need to do anything on server side to handle this issues, for example variable bitrate etc ?
The first step would be to implement Interactive Connectivity Establishement (RFC 5245). Whether you make use of a STUN/TURN server or not is irrelevant, your code needs to issue connectivity checks (which use STUN messages) to the browser and respond to the brower's connectivity checks. ICE is a fairly complex state machine, but it's doable.
You don't have to reinvent the wheel. STUN / TURN servers are external components. Use as they are. WebRTC source code is available which you can use in your application code and call the related methods.
Pls. refer to similar post - Server as WebRTC data channel peer

SCTP and webrtc

I saw that SCTP is going to be used for Data Channels starting in Chrome 31, and officially RTP based channels are going to be deprecated sometimes in February 2014 according to this google group thread:
https://groups.google.com/forum/#!topic/discuss-webrtc/y2A97iCByTU
Does this also mean that webrtc audio and video channels are also going to be transported over SCTP eventually(if not already in the works)?
How does RTP fit in the whole SCTP transport effort? Does that mean SRTP packets will flow over SCTP data channel? Or perhaps just the payload will be sent over SCTP transport protocol.
If I am reading info on SCTP, it combines best of TCP and UDP protocols; but it does not include encryption by default; so in mind the traffic flowing over should still be encrypted.
Any additional info would be helpful. Thanks!
The audio and video will keep going over RTP (actually SRTP which is the secure version or RTP) but the data channel will uses SCTP over DTLS over UDP. Both Firefox and Chrome are implementing this and you can find it described in the IETF draft specifications. For some types of NAT / Firewall traversal, the UDP packets may get tunneled in TURN over TCP.
Glad to provide you pointers to the draft specifications if that helps.
SCTP stands for Stream Control Transmission Protocol.
SCTP as a protocol can be seen as a hybrid of UDP and TCP.
At its core, SCTP holds the following characteristics:
Connection oriented. Similar to TCP, SCTP is connection oriented. It also offers a multi-homing capability that isn’t used by WebRTC
Optional reliability. Reliability is optional in SCTP and is up to the implementer using SCTP to decide if he needs this capability or not
Optional ordering. Ordering of packets sent via SCTP is optional and is left for the implementer to decide if this is necessary for him or not
Message oriented. SCTP makes sure that each message sent is properly parsed on the receiver end in the same manner in which it was sent
Flow control. Similar to TCP, SCTP provides a flow control mechanism that makes sure the network doesn’t get congested
SCTP is not implemented by all operating systems. In such cases, an application level implementation of SCTP will usually be used.
SCTP is used in WebRTC for the implementation and delivery of the Data Channel.
Google is experimenting with the QUIC protocol as a future replacement to SCTP

Why is SNMP usually run over UDP and not TCP/IP?

This morning, there were big problems at work because an SNMP trap didn't "go through" because SNMP is run over UDP. I remember from the networking class in college that UDP isn't guaranteed delivery like TCP/IP. And Wikipedia says that SNMP can be run over TCP/IP, but UDP is more common.
I get that some of the advantages of UDP over TCP/IP are speed, broadcasting, and multicasting. But it seems to me that guaranteed delivery is more important for network monitoring than broadcasting ability. Particularly when there are serious high-security needs. One of my coworkers told me that UDP packets are the first to be dropped when traffic gets heavy. That is yet another reason to prefer TCP/IP over UDP for network monitoring (IMO).
So why does SNMP use UDP? I can't figure it out and can't find a good reason on Google either.
UDP is actually expected to work better than TCP in lossy networks (or congested networks). TCP is far better at transferring large quantities of data, but when the network fails it's more likely that UDP will get through. (in fact, I recently did a study testing this and it found that SNMP over UDP succeeded far better than SNMP over TCP in lossy networks when the UDP timeout was set properly). Generally, TCP starts behaving poorly at about 5% packet loss and becomes completely useless at 33% (ish) and UDP will still succeed (eventually).
So the right thing to do, as always, is pick the right tool for the right job. If you're doing routine monitoring of lots of data, you might consider TCP. But be prepared to fall back to UDP for fixing problems. Most stacks these days can actually use both TCP and UDP.
As for sending TRAPs, yes TRAPs are unreliable because they're not acknowledged. However, SNMP INFORMs are an acknowledged version of a SNMP TRAP. Thus if you want to know that the notification receiver got the message, please use INFORMs. Note that TCP does not solve this problem as it only provides layer 3 level notification that the message was received. There is no assurance that the notification receiver actually got it. SNMP INFORMs do application level acknowledgement and are much more trustworthy than assuming a TCP ack indicates they got it.
If systems sent SNMP traps via TCP they could block waiting for the packets to be ACKed if there was a problem getting the traffic to the receiver. If a lot of traps were generated, it could use up the available sockets on the system and the system would lock up. With UDP that is not an issue because it is stateless. A similar problem took out BitBucket in January although it was syslog protocol rather than SNMP--basically, they were inadvertently using syslog over TCP due to a configuration error, the syslog server went down, and all of the servers locked up waiting for the syslog server to ACK their packets. If SNMP traps were sent over TCP, a similar problem could occur.
http://blog.bitbucket.org/2012/01/12/follow-up-on-our-downtime-last-week/
Check out O'Reilly's writings on SNMP: https://library.oreilly.com/book/9780596008406/essential-snmp/18.xhtml
One advantage of using UDP for SNMP traps is that you can direct UDP to a broadcast address, and then field them with multiple management stations on that subnet.
The use of traps with SNMP is considered unreliable. You really should not be relying on traps.
SNMP was designed to be used as a request/response protocol. The protocol details are simple (hence the name, "simple network management protocol"). And UDP is a very simple transport. Try implementing TCP on your basic agent - it's considerably more complex than a simple agent coded using UDP.
SNMP get/getnext operations have a retry mechanism - if a response is not received within timeout then the same request is sent up to a maximum number of tries.
Usually, when you're doing SNMP, you're on a company network, you're not doing this over the long haul. UDP can be more efficient. Let's look at (a gross oversimplification of) the conversation via TCP, then via UDP...
TCP version:
client sends SYN to server
server sends SYN/ACK to client
client sends ACK to server - socket is now established
client sends DATA to server
server sends ACK to client
server sends RESPONSE to client
client sends ACK to server
client sends FIN to server
server sends FIN/ACK to client
client sends ACK to server - socket is torn down
UDP version:
client sends request to server
server sends response to client
generally, the UDP version succeeds since it's on the same subnet, or not far away (i.e. on the company network).
However, if there is a problem with either the initial request or the response, it's up to the app to decide. A. can we get by with a missed packet? if so, who cares, just move on. B. do we need to make sure the message is sent? simple, just redo the whole thing... client sends request to server, server sends response to client. The application can provide a number just in case the recipient of the message receives both messages, he knows it's really the same message being sent again.
This same technique is why DNS is done over UDP. It's much lighter weight and generally it works the first time because you are supposed to be near your DNS resolver.