Skip to content

Commit

Permalink
srth: send rtt_0 downstream
Browse files Browse the repository at this point in the history
  • Loading branch information
funman committed Apr 5, 2024
1 parent 8ef44cd commit 2dfe549
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/upipe-srt/upipe_srt_handshake.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ struct upipe_srt_handshake {

uint64_t last_hs_sent;

uint64_t rtt_0;

/** public upipe structure */
struct upipe upipe;
};
Expand Down Expand Up @@ -795,6 +797,8 @@ static void upipe_srt_handshake_finalize(struct upipe *upipe)
upipe_err(upipe, "damn");
}

uref_clock_set_latency(flow_def, upipe_srt_handshake->rtt_0);

This comment has been minimized.

Copy link
@kierank

kierank Apr 5, 2024

This will propagate downstream and anyway latency is not correct here as this is RTT.

This comment has been minimized.

Copy link
@funman

funman Apr 5, 2024

Author Owner

This will propagate downstream and anyway latency is not correct here as this is RTT.

Maybe we should add a RTT field to udict, might be useful for rist too


uref_pic_set_number(flow_def, upipe_srt_handshake->isn);
upipe_srt_handshake_store_flow_def(upipe, flow_def);
/* force sending flow definition immediately */
Expand Down Expand Up @@ -1405,6 +1409,7 @@ static struct uref *upipe_srt_handshake_handle_hs(struct upipe *upipe, const uin
upipe_srt_handshake->caller_conclusion = NULL;
}
} else {
upipe_srt_handshake->rtt_0 = now - upipe_srt_handshake->last_hs_sent;

This comment has been minimized.

Copy link
@kierank

kierank Apr 5, 2024

Not sure this is correct as if latency is high, a second HS is sent but the response may be from the first.

This comment has been minimized.

Copy link
@funman

funman Apr 5, 2024

Author Owner

Not sure this is correct as if latency is high, a second HS is sent but the response may be from the first.

Indeed, there appears to be no way to know.
Maybe it's better to assume it's an answer to the first packet, that'd give a worse case RTT

if (hs_packet.version != SRT_HANDSHAKE_VERSION || hs_packet.dst_socket_id != upipe_srt_handshake->socket_id) {
upipe_err_va(upipe, "Malformed handshake (%08x != %08x)",
hs_packet.dst_socket_id, upipe_srt_handshake->socket_id);
Expand All @@ -1418,6 +1423,7 @@ static struct uref *upipe_srt_handshake_handle_hs(struct upipe *upipe, const uin
}
} else { /* listener */
if (conclusion) {
upipe_srt_handshake->rtt_0 = now - upipe_srt_handshake->establish_time;
uref = upipe_srt_handshake_handle_hs_listener_conclusion(upipe, size, timestamp, &hs_packet);
} else {
if (hs_packet.version != SRT_HANDSHAKE_VERSION_MIN || hs_packet.encryption != SRT_HANDSHAKE_CIPHER_NONE ||
Expand Down

1 comment on commit 2dfe549

@kierank
Copy link

@kierank kierank commented on 2dfe549 Apr 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.