licode icon indicating copy to clipboard operation
licode copied to clipboard

Why is the DTLS 20-64 when parsing the received packet

Open a839419160 opened this issue 4 years ago • 0 comments

See the description in RFC5764:The process for demultiplexing a packet is as follows. The receiver looks at the first byte of the packet. If the value of this byte is 0 or 1, then the packet is STUN. If the value is in between 128 and 191 (inclusive), then the packet is RTP (or RTCP, if both RTCP and RTP are being multiplexed over the same destination port). If the value is between 20 and 63 (inclusive), the packet is DTLS.

DtlsSocketContext::PacketType DtlsSocketContext::demuxPacket(const unsigned char *data, unsigned int len) {
  assert(len >= 1);
  if ((data[0] == 0)   || (data[0] == 1))
  return stun;
  if ((data[0] >= 128) && (data[0] <= 191))
  return rtp;
  if ((data[0] >= 20)  && (data[0] <= 64))
  return dtls;

  return unknown;
}

a839419160 avatar Jan 11 '21 11:01 a839419160