Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
801f7056
Commit
801f7056
authored
Sep 22, 2022
by
xiongguangjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix srt ack packet packet buf length error
parent
642ca499
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
47 行增加
和
14 行删除
+47
-14
srt/Ack.cpp
+2
-2
srt/SrtTransport.cpp
+24
-8
srt/SrtTransport.hpp
+2
-1
srt/Statistic.cpp
+19
-3
没有找到文件。
srt/Ack.cpp
查看文件 @
801f7056
...
...
@@ -59,10 +59,10 @@ bool ACKPacket::storeToData() {
storeUint32
(
ptr
,
rtt_variance
);
ptr
+=
4
;
storeUint32
(
ptr
,
pkt_recv_rat
e
);
storeUint32
(
ptr
,
available_buf_siz
e
);
ptr
+=
4
;
storeUint32
(
ptr
,
available_buf_siz
e
);
storeUint32
(
ptr
,
pkt_recv_rat
e
);
ptr
+=
4
;
storeUint32
(
ptr
,
estimated_link_capacity
);
...
...
srt/SrtTransport.cpp
查看文件 @
801f7056
...
...
@@ -292,7 +292,7 @@ void SrtTransport::handleHandshakeConclusion(HandshakePacket &pkt, struct sockad
return
;
}
_last_ack_pkt_seq_num
=
_init_seq_number
;
//
_last_ack_pkt_seq_num = _init_seq_number;
}
void
SrtTransport
::
handleHandshake
(
uint8_t
*
buf
,
int
len
,
struct
sockaddr_storage
*
addr
)
{
...
...
@@ -458,12 +458,22 @@ void SrtTransport::handleACKACK(uint8_t *buf, int len, struct sockaddr_storage *
ACKACKPacket
::
Ptr
pkt
=
std
::
make_shared
<
ACKACKPacket
>
();
pkt
->
loadFromData
(
buf
,
len
);
if
(
_ack_send_timestamp
.
find
(
pkt
->
ack_number
)
!=
_ack_send_timestamp
.
end
()){
uint32_t
rtt
=
DurationCountMicroseconds
(
_now
-
_ack_send_timestamp
[
pkt
->
ack_number
]);
_rtt_variance
=
(
3
*
_rtt_variance
+
abs
((
long
)
_rtt
-
(
long
)
rtt
))
/
4
;
_rtt
=
(
7
*
rtt
+
_rtt
)
/
8
;
// TraceL<<" rtt:"<<_rtt<<" rtt variance:"<<_rtt_variance;
_ack_send_timestamp
.
erase
(
pkt
->
ack_number
);
if
(
_last_recv_ackack_seq_num
<
pkt
->
ack_number
){
_last_recv_ackack_seq_num
=
pkt
->
ack_number
;
}
else
{
if
((
_last_recv_ackack_seq_num
-
pkt
->
ack_number
)
>
(
MAX_TS
>>
1
)){
_last_recv_ackack_seq_num
=
pkt
->
ack_number
;
}
}
}
}
void
SrtTransport
::
handlePeerError
(
uint8_t
*
buf
,
int
len
,
struct
sockaddr_storage
*
addr
)
{
...
...
@@ -484,14 +494,20 @@ void SrtTransport::sendACKPacket() {
pkt
->
pkt_recv_rate
=
_pkt_recv_rate_context
->
getPacketRecvRate
(
recv_rate
);
pkt
->
estimated_link_capacity
=
_estimated_link_capacity_context
->
getEstimatedLinkCapacity
();
pkt
->
recv_rate
=
recv_rate
;
if
(
pkt
->
pkt_recv_rate
==
0
){
TraceL
<<
pkt
->
pkt_recv_rate
<<
" pkt/s "
<<
recv_rate
<<
" byte/s "
<<
pkt
->
estimated_link_capacity
<<
" pkt/s (cap)"
;
TraceL
<<
_pkt_recv_rate_context
->
dump
();
if
(
1
){
TraceL
<<
pkt
->
pkt_recv_rate
<<
" pkt/s "
<<
recv_rate
<<
" byte/s "
<<
pkt
->
estimated_link_capacity
<<
" pkt/s (cap) "
<<
pkt
->
available_buf_size
<<
" available buf"
;
//TraceL<<_pkt_recv_rate_context->dump();
//TraceL<<"recv estimated:";
//TraceL<< _pkt_recv_rate_context->dump();
//TraceL<<"recv queue:";
//TraceL<<_recv_buf->dump();
}
if
(
pkt
->
available_buf_size
<
2
){
pkt
->
available_buf_size
=
2
;
}
pkt
->
storeToData
();
_ack_send_timestamp
[
pkt
->
ack_number
]
=
_now
;
_last_ack_pkt_seq_num
=
pkt
->
last_ack_pkt_seq_number
;
//
_last_ack_pkt_seq_num = pkt->last_ack_pkt_seq_number;
sendControlPacket
(
pkt
,
true
);
// TraceL<<"send ack "<<pkt->dump();
// TraceL<<_recv_buf->dump();
...
...
@@ -511,7 +527,7 @@ void SrtTransport::sendLightACKPacket() {
pkt
->
estimated_link_capacity
=
0
;
pkt
->
recv_rate
=
0
;
pkt
->
storeToData
();
_last_ack_pkt_seq_num
=
pkt
->
last_ack_pkt_seq_number
;
//
_last_ack_pkt_seq_num = pkt->last_ack_pkt_seq_number;
sendControlPacket
(
pkt
,
true
);
TraceL
<<
"send ack "
<<
pkt
->
dump
();
}
...
...
srt/SrtTransport.hpp
查看文件 @
801f7056
...
...
@@ -133,7 +133,8 @@ private:
uint32_t
_rtt_variance
=
50
*
1000
;
uint32_t
_light_ack_pkt_count
=
0
;
uint32_t
_ack_number_count
=
0
;
uint32_t
_last_ack_pkt_seq_num
=
0
;
//uint32_t _last_ack_pkt_seq_num = 0;
uint32_t
_last_recv_ackack_seq_num
=
0
;
uint32_t
_last_pkt_seq
=
0
;
UTicker
_ack_ticker
;
...
...
srt/Statistic.cpp
查看文件 @
801f7056
...
...
@@ -32,6 +32,9 @@ uint32_t PacketRecvRateContext::getPacketRecvRate(uint32_t &bytesps) {
int64_t
upper
=
median
<<
3
;
int64_t
lower
=
median
>>
3
;
int64_t
min
=
median
;
int64_t
min_size
=
0
;
bytesps
=
0
;
size_t
bytes
=
0
;
const
size_t
*
bp
=
_size_arr
;
...
...
@@ -43,14 +46,27 @@ uint32_t PacketRecvRateContext::getPacketRecvRate(uint32_t &bytesps) {
sum
+=
*
p
;
// usec counter
bytes
+=
*
bp
;
// byte counter
}
if
(
*
p
<
min
){
min
=
*
p
;
min_size
=
*
bp
;
}
++
p
;
// advance packet pointer
++
bp
;
// advance bytes pointer
}
uint32_t
max_ret
=
(
uint32_t
)
ceil
(
1e6
/
min
);
uint32_t
max_byteps
=
(
uint32_t
)
ceil
(
1e6
*
min_size
/
min
);
if
(
count
>
(
SIZE
>>
1
)){
bytesps
=
(
unsigned
long
)
ceil
(
1000000.0
/
(
double
(
sum
)
/
double
(
bytes
)));
auto
ret
=
(
uint32_t
)
ceil
(
1000000.0
/
(
sum
/
count
));
return
ret
;
bytesps
=
(
uint32_t
)
ceil
(
1000000.0
/
(
double
(
sum
)
/
double
(
bytes
)));
auto
ret
=
(
uint32_t
)
ceil
(
1000000.0
/
(
double
(
sum
)
/
double
(
count
)));
//bytesps = max_byteps;
return
max_ret
;
}
else
{
//TraceL<<max_ret<<" pkt/s "<<max_byteps<<" byte/s";
bytesps
=
0
;
return
0
;
}
bytesps
=
0
;
return
0
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论