mediasoup

/ home / Documentation / v3 / mediasoup / RTC Statistics

RTC Statistics

All mediasoup RTC classes include a getStats() method with the following signature:

@async

@returns Array<Object>

Below a list of statistics as generated by the different RTC classes in mediasoup.


WebRtcTransport Statistics

const stats = await webRtcTransport.getStats();

// =>
[
  {
    "availableIncomingBitrate": 4230170,
    "bytesReceived": 5282775,
    "bytesSent": 8229,
    "dtlsState": "connected",
    "iceRole": "controlled",
    "iceSelectedTuple": 
    {
      "localIp": "11.22.33.44",
      "localPort": 48151,
      "protocol": "udp",
      "remoteIp": "55.66.77.88",
      "remotePort": 54628
    },
    "iceState": "completed",
    "maxIncomingBitrate": 3500000,
    "recvBitrate": 654388,
    "sendBitrate": 104,
    "timestamp": 922749895,
    "transportId": "0b38d662-ea00-4c70-9ae3-b675d6a89e0a",
    "type": "webrtc-transport"
  }
]

PlainRtpTransport Statistics

const stats = await plainRtpTransport.getStats();

// =>
[
  {
    "bytesReceived": 467406,
    "bytesSent": 0,
    "comedia": true,
    "multiSource": false,
    "rtcpMux": true,
    "recvBitrate": 22006,
    "sendBitrate": 24,
    "timestamp": 924308648,
    "transportId": "8e7dc219-5cb0-4cca-b1ca-0bbbc584a364",
    "tuple": 
    {
      "localIp": "11.22.33.44",
      "localPort": 45346,
      "protocol": "udp",
      "remoteIp": "55.66.77.88",
      "remotePort": 56971
    },
    "type": "plain-rtp-transport"
  }
]

PipeTransport Statistics

const stats = await pipeTransport.getStats();

// =>
[
  {
    "bytesReceived": 35785508,
    "bytesSent": 1200458,
    "timestamp": 924308980,
    "transportId": "352f60cd-10ac-443b-8529-6474ecba2e46",
    "tuple": 
    {
      "localIp": "11.22.33.44",
      "localPort": 12455,
      "protocol": "udp",
      "remoteIp": "11.22.33.44",
      "remotePort": 42301
    },
    "type": "pipe-transport"
  }
]

Producer Statistics

The producer's statistics contain an entry for each RTP stream being received so, if simulcast is used, there will be as many entries as discovered RTP streams. Note that the producer's statistics show the RTP streams received my mediasoup as they are sent by the producer endpoint, this is, without any packet modification.

const stats = await producer.getStats();

// =>
[
  {
    "bitrate": 678400,
    "bitrateByLayer": 
    {
      "0.0": 237992,
      "0.1": 145496,
      "0.2": 294912
    },
    "byteCount": 4265668,
    "firCount": 0,
    "fractionLost": 0,
    "jitter": 0,
    "kind": "video",
    "mimeType": "video/VP8",
    "nackCount": 0,
    "nackPacketCount": 0,
    "packetCount": 4150,
    "packetsDiscarded": 0,
    "packetsLost": 0,
    "packetsRepaired": 0,
    "packetsRetransmitted": 95,
    "pliCount": 5,
    "rid": "r2",
    "rtxSsrc": 2830213299,
    "score": 10,
    "ssrc": 689337360,
    "timestamp": 925298114,
    "type": "inbound-rtp"
  },
  {
    "bitrate": 242784,
    "bitrateByLayer": 
    {
      "0.0": 85608,
      "0.1": 52752,
      "0.2": 104424
    },
    "byteCount": 1677745,
    "firCount": 0,
    "fractionLost": 0,
    "jitter": 0,
    "kind": "video",
    "mimeType": "video/VP8",
    "nackCount": 5,
    "nackPacketCount": 31,
    "packetCount": 2045,
    "packetsDiscarded": 0,
    "packetsLost": 4294967281,
    "packetsRepaired": 15,
    "packetsRetransmitted": 563,
    "pliCount": 3,
    "rid": "r1",
    "rtxSsrc": 2486781276,
    "score": 10,
    "ssrc": 2995277190,
    "timestamp": 925298114,
    "type": "inbound-rtp"
  },
  {
    "bitrate": 86768,
    "bitrateByLayer": 
    {
      "0.0": 29648,
      "0.1": 19344,
      "0.2": 37776
    },
    "byteCount": 581258,
    "firCount": 0,
    "fractionLost": 0,
    "jitter": 2,
    "kind": "video",
    "mimeType": "video/VP8",
    "nackCount": 0,
    "nackPacketCount": 0,
    "packetCount": 1362,
    "packetsDiscarded": 0,
    "packetsLost": 0,
    "packetsRepaired": 0,
    "packetsRetransmitted": 10,
    "pliCount": 1,
    "rid": "r0",
    "rtxSsrc": 2118917939,
    "score": 10,
    "ssrc": 3060700812,
    "timestamp": 925298114,
    "type": "inbound-rtp"
  }
]

Consumer Statistics

The consumer's statistics include two entries: the statistics of the RTP stream in the consumer (type: "outbound-rtp") and the statistics of the associated RTP stream in the producer (type: "inbound-rtp").

const stats = await consumer.getStats();

// =>
[
  {
    "bitrate": 625312,
    "byteCount": 879947,
    "firCount": 0,
    "fractionLost": 0,
    "kind": "video",
    "mimeType": "video/VP8",
    "nackCount": 0,
    "nackPacketCount": 0,
    "packetCount": 979,
    "packetsDiscarded": 0,
    "packetsLost": 0,
    "packetsRepaired": 0,
    "packetsRetransmitted": 0,
    "pliCount": 0,
    "roundTripTime": 33.02001953125,
    "rtxSsrc": 836324070,
    "score": 10,
    "ssrc": 328066115,
    "timestamp": 925531753,
    "type": "outbound-rtp"
  },
  {
    "bitrate": 627872,
    "bitrateByLayer": 
    {
      "0.0": 238856,
      "0.1": 145872,
      "0.2": 243144
    },
    "byteCount": 883855,
    "firCount": 0,
    "fractionLost": 0,
    "jitter": 2,
    "kind": "video",
    "mimeType": "video/VP8",
    "nackCount": 0,
    "nackPacketCount": 0,
    "packetCount": 979,
    "packetsDiscarded": 0,
    "packetsLost": 0,
    "packetsRepaired": 0,
    "packetsRetransmitted": 167,
    "pliCount": 2,
    "rtxSsrc": 1976184061,
    "score": 10,
    "ssrc": 2440984788,
    "timestamp": 925531753,
    "type": "inbound-rtp"
  }
]

There is, however, an exception when the consumer has been created on a PipeTransport. In this case the consumer forwards all producer's RTP streams to its destination. The statistics of this consumer include an entry for each RTP stream being forwarded (type: "outbound-rtp") and does not include entries for the associated RTP streams in the producer (type: "inbound-rtp").

const stats = await pipeConsumer.getStats();

// =>
[
  {
    "bitrate": 868184,
    "byteCount": 19478693,
    "firCount": 0,
    "fractionLost": 0,
    "kind": "video",
    "mimeType": "video/VP8",
    "nackCount": 0,
    "nackPacketCount": 0,
    "packetCount": 18696,
    "packetsDiscarded": 0,
    "packetsLost": 0,
    "packetsRepaired": 0,
    "packetsRetransmitted": 0,
    "pliCount": 0,
    "roundTripTime": 55690732,
    "score": 10,
    "ssrc": 116684231,
    "timestamp": 514442975,
    "type": "outbound-rtp"
  },
  {
    "bitrate": 350000,
    "byteCount": 8393425,
    "firCount": 0,
    "fractionLost": 0,
    "kind": "video",
    "mimeType": "video/VP8",
    "nackCount": 0,
    "nackPacketCount": 0,
    "packetCount": 9417,
    "packetsDiscarded": 0,
    "packetsLost": 0,
    "packetsRepaired": 0,
    "packetsRetransmitted": 0,
    "pliCount": 0,
    "roundTripTime": 55690732,
    "score": 10,
    "ssrc": 116684230,
    "timestamp": 514442975,
    "type": "outbound-rtp"
  },
  { 
    "bitrate": 153456,
    "byteCount": 3442897,
    "firCount": 0,
    "fractionLost": 0,
    "kind": "video",
    "mimeType": "video/VP8",
    "nackCount": 0,
    "nackPacketCount": 0,
    "packetCount": 5393,
    "packetsDiscarded": 0,
    "packetsLost": 0,
    "packetsRepaired": 0,
    "packetsRetransmitted": 0,
    "pliCount": 0,
    "roundTripTime": 0.0152587890625,
    "score": 10,
    "ssrc": 116684229,
    "timestamp": 514442975,
    "type": "outbound-rtp"
  }
]