RTP AND RTCP
- Thuật toán tính toán khoảng thời gian truyền RTCP
double rtcp_interval(int members,
int senders,
double rtcp_bw,
int we_sent,
double avg_rtcp_size,
int initial)
{
double const RTCP_MIN_TIME = 5.;
double const RTCP_SENDER_BW_FRACTION = 0.25;
double const RTCP_RCVR_BW_FRACTION = (1-RTCP_SENDER_BW_FRACTION);
double const COMPENSATION = 2.71828 - 1.5;
double t; /* interval */
double rtcp_min_time = RTCP_MIN_TIME;
int n; /* no. of members for computation */
if (initial) {
rtcp_min_time /= 2;
}
n = members;
if (senders > 0 && senders < members * RTCP_SENDER_BW_FRACTION) {
if (we_sent) {
rtcp_bw *= RTCP_SENDER_BW_FRACTION;
n = senders;
} else {
rtcp_bw *= RTCP_RCVR_BW_FRACTION;
n -= senders;
}
}
t = avg_rtcp_size * n / rtcp_bw;
if (t < rtcp_min_time) t = rtcp_min_time;
t = t * (drand48() + 0.5);
t = t / COMPENSATION;
return t;
}
- Công thức tính RTT (round time trip):
RTT = A - LSR -DLSR Trong đó:
A : là giá trị thời điểm mà lúc gói RTCP của reciver được phản hồi lại
DLSR: (32 bit) là khoảng thời gian mà từ lúc nhận được gói RTCP do sender gửi đến
và thời diểm bắt đầu gửi gói RTCP trả về sender
LSR: (32 bit) là thời gian gói RTCP của sender được gửi, gói RTCP trước đó
# Cách chuyển đổi giá trị 64 bit timestamp sang 32 bit:
- Integral 32 bits : 0xb44db710
- Fractional 32 bits : 0x80000000
=> 32 bit giữa là : 0xb710:8000 (46864.500 seconds)
# Cách chuyển đổi 32 bit sang đơn vị seconds:
- 0xb710 là cơ hệ số 16 chuyển sang cơ số 10 sẽ = 46864
- 8000 chuyển sang hệ thập phân (hệ 10) sẽ =32768,từ thập phân chuyển sang millisecond
32768 * (10 ^ 6) / 2 ^ 16 (vì 16 bit) = 500
#Tham khảo thêm : http://thompsonng.blogspot.com/2010/04/ntp-timestamp_21.html
Lý thuyết :
https://drive.google.com/file/d/1YcnZ9Q80-z4a9pNJPBTTfDTkzThu4KUR/view?usp=sharing
Tham khảo:
https://www.ietf.org/proceedings/44/I-D/draft-ietf-avt-rtp-new-03.txt

Nhận xét
Đăng nhận xét