😎

SkWay調査

2021/02/18に公開

権限と接続

  • そもそも許可されてないと
    • カメラ
      • stream取得時に落ちる
    • マイク
      • 接続時に落ちる
  • マイク・カメラのストリームの確認
    • MediaStream自体は持っていない
  • getStatsを見てみる
    • muteにするとちゃんとbyteRecievedは減る
    • ただ0にはならない

getStats

  • jsonArray で取得できる
  • idやtypeを持ったstats情報が取れる
  • 上記でフィルターして必要な情報を取得する
  • 一部のcodecなどはidだけ入っており一度取得してから再度探索して取得する必要がある

https://gist.github.com/jumbo-in-Jap/7ceb26ed131ff9783517233ba97047e0

問題の検知ロジック

発火のタイミング

  • すでにMediaConnectionが接続されているときにそもそも有効にする
  • 5秒に一回発火してstats情報を集積する

提供するもの

  • 集積しているstatsの情報
  • 現在のcodecの情報
  • 異常があればthrowする

異常の定義

通信品質を変える

sudo dnctl pipe 1 config bw 50000kbit/s
sudo vi /etc/pf.conf
sudo pfctl -f /etc/pf.conf
sudo pfctl -e

実験

  • 接続中に帯域をいじる
  • 接続が悪化したときに状態をちゃんと検知したい
  • 復旧したことも検知したい

fractionLost

2021-02-18 21:52:45.357 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 13345 bytesSent: 10418 packetsLost: 1.0 packetsReceived: 216.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.01802083333333333 fractionLost: 0.0 bitrate: 0.0 remoteInboundRoundTripTime: 0.097
2021-02-18 21:52:50.267 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 28076 bytesSent: 23255 packetsLost: 2.0 packetsReceived: 466.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.018375 fractionLost: 0.004 bitrate: 27007.333469138317 remoteInboundRoundTripTime: 0.098
2021-02-18 21:52:55.247 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 43183 bytesSent: 36293 packetsLost: 2.0 packetsReceived: 716.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.0025 fractionLost: 0.0 bitrate: 27307.29062060655 remoteInboundRoundTripTime: 0.005
2021-02-18 21:53:00.213 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 58291 bytesSent: 49643 packetsLost: 2.0 packetsReceived: 965.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002520833333333333 fractionLost: 0.0 bitrate: 27375.07549828871 remoteInboundRoundTripTime: 0.007
2021-02-18 21:53:05.204 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 73470 bytesSent: 62259 packetsLost: 2.0 packetsReceived: 1216.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.0024375 fractionLost: 0.0 bitrate: 27371.468643558404 remoteInboundRoundTripTime: 0.004
2021-02-18 21:53:10.218 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 88538 bytesSent: 74352 packetsLost: 2.0 packetsReceived: 1466.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.001833333333333333 fractionLost: 0.0 bitrate: 27073.667398682373 remoteInboundRoundTripTime: 0.006
2021-02-18 21:53:15.219 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 104233 bytesSent: 87641 packetsLost: 2.0 packetsReceived: 1715.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.0016875 fractionLost: 0.0 bitrate: 28228.41726618705 remoteInboundRoundTripTime: 0.005

// 劣化させる

2021-02-18 21:53:20.217 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 110211 bytesSent: 100194 packetsLost: 99.0 packetsReceived: 1806.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.0016875 fractionLost: 1.065934065934066 bitrate: 10766.860116069642 remoteInboundRoundTripTime: 0.005
2021-02-18 21:53:25.207 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 117844 bytesSent: 111727 packetsLost: 247.0 packetsReceived: 1930.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002354166666666667 fractionLost: 1.1935483870967742 bitrate: 13764.175515928671 remoteInboundRoundTripTime: 1.094
2021-02-18 21:53:30.210 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 125684 bytesSent: 123934 packetsLost: 348.0 packetsReceived: 2083.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002354166666666667 fractionLost: 0.6601307189542484 bitrate: 14100.719424460432 remoteInboundRoundTripTime: 0.68
2021-02-18 21:53:35.204 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 132295 bytesSent: 136546 packetsLost: 469.0 packetsReceived: 2211.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002354166666666667 fractionLost: 0.9453125 bitrate: 11911.71171171171 remoteInboundRoundTripTime: 0.68
2021-02-18 21:53:40.213 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 138453 bytesSent: 148740 packetsLost: 583.0 packetsReceived: 2331.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002333333333333334 fractionLost: 0.95 bitrate: 11066.693290734825 remoteInboundRoundTripTime: 0.821
2021-02-18 21:53:45.207 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 144284 bytesSent: 160740 packetsLost: 728.0 packetsReceived: 2440.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002333333333333334 fractionLost: 1.3302752293577982 bitrate: 10508.410092110535 remoteInboundRoundTripTime: 0.821
2021-02-18 21:53:50.205 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 151476 bytesSent: 172409 packetsLost: 847.0 packetsReceived: 2573.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002479166666666667 fractionLost: 0.8947368421052632 bitrate: 12955.964771817455 remoteInboundRoundTripTime: 0.913
2021-02-18 21:53:55.204 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 158332 bytesSent: 184426 packetsLost: 969.0 packetsReceived: 2707.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002479166666666667 fractionLost: 0.9104477611940298 bitrate: 12338.332333533295 remoteInboundRoundTripTime: 0.913

// 帯域を戻す

2021-02-18 21:54:00.204 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 172895 bytesSent: 197511 packetsLost: 995.0 packetsReceived: 2971.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002479166666666667 fractionLost: 0.09848484848484848 bitrate: 26213.4 remoteInboundRoundTripTime: 0.913
2021-02-18 21:54:05.203 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 187389 bytesSent: 209252 packetsLost: 995.0 packetsReceived: 3221.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002125 fractionLost: 0.0 bitrate: 26094.418883776758 remoteInboundRoundTripTime: 0.005
2021-02-18 21:54:10.203 24251-24322/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 200010 bytesSent: 220898 packetsLost: 995.0 packetsReceived: 3471.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002208333333333333 fractionLost: 0.0 bitrate: 22717.8 remoteInboundRoundTripTime: 0.006

RTT (Round Trip Time)

https://www.callstats.io/blog/why-is-round-trip-time-a-valuable-webrtc-metric-for-call-centers

  • 300msが一つの指標とも言われているっぽい
  • ちゃんと劣化したときに変わる
2021-02-15 00:39:13.143 26940-27007/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 736679 bytesSent: 549063 packetsLost: 7.0 packetsReceived: 9460.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002145833333333333 fractionLost: 0.0 bitrate: 36453.32800319808 remoteInboundRoundTripTime: 0.005
2021-02-15 00:39:18.104 26940-27065/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: run stats
2021-02-15 00:39:18.140 26940-27007/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 755981 bytesSent: 563848 packetsLost: 7.0 packetsReceived: 9710.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002645833333333333 fractionLost: 0.0 bitrate: 34771.41713370697 remoteInboundRoundTripTime: 0.004
2021-02-15 00:39:23.104 26940-27065/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: run stats
2021-02-15 00:39:23.141 26940-27007/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 775742 bytesSent: 577963 packetsLost: 7.0 packetsReceived: 9960.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.004208333333333333 fractionLost: 0.0 bitrate: 35562.6874625075 remoteInboundRoundTripTime: 0.028
2021-02-15 00:39:28.105 26940-27065/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: run stats
2021-02-15 00:39:28.141 26940-27007/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 793834 bytesSent: 590653 packetsLost: 7.0 packetsReceived: 10185.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002208333333333333 fractionLost: 0.0 bitrate: 32585.15109065439 remoteInboundRoundTripTime: 0.005
2021-02-15 00:39:33.106 26940-27065/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: run stats
2021-02-15 00:39:33.149 26940-27007/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 813977 bytesSent: 604969 packetsLost: 7.0 packetsReceived: 10435.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.00225 fractionLost: 0.0 bitrate: 36192.253942902775 remoteInboundRoundTripTime: 0.503
2021-02-15 00:39:38.107 26940-27065/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: run stats
2021-02-15 00:39:38.143 26940-27007/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 834032 bytesSent: 618531 packetsLost: 7.0 packetsReceived: 10685.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002291666666666667 fractionLost: 0.0 bitrate: 36149.60945323452 remoteInboundRoundTripTime: 0.504
2021-02-15 00:39:43.106 26940-27065/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: run stats
2021-02-15 00:39:43.137 26940-27007/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 855632 bytesSent: 634482 packetsLost: 7.0 packetsReceived: 10960.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.002145833333333333 fractionLost: 0.0 bitrate: 38911.1289031225 remoteInboundRoundTripTime: 0.504
2021-02-15 00:39:48.107 26940-27065/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: run stats
2021-02-15 00:39:48.132 26940-27007/com.ntt.ecl.webrtc.sample_p2p_videochat D/skyway-stats-manager: bytesReceived: 875645 bytesSent: 648399 packetsLost: 7.0 packetsReceived: 11210.0 remoteInboundPacketLoss: 0.0 remoteInboundJitter: 0.0023125 fractionLost: 0.0 bitrate: 36052.241793434754 remoteInboundRoundTripTime: 0.003

Discussion