Keep Muninn parity under LAN RUDP MTU
This commit is contained in:
parent
9d4d5bb9bf
commit
ff62252b5e
2 changed files with 37 additions and 29 deletions
|
|
@ -58,7 +58,7 @@ const MUNINN_RUDP_MEDIA_VIDEO_BITRATE_KBPS: u32 = 16_000;
|
|||
const MUNINN_RUDP_MEDIA_VBV_FRAME_BUDGETS: u32 = 1;
|
||||
const MUNINN_RUDP_MEDIA_LOW_DELAY_KEY_FRAME_SCALE: u32 = 4;
|
||||
const MUNINN_RUDP_MEDIA_VIDEO_DPB_SIZE: u32 = 1;
|
||||
const MUNINN_RUDP_MEDIA_PACKET_BYTES: usize = 860;
|
||||
const MUNINN_RUDP_MEDIA_PACKET_BYTES: usize = 848;
|
||||
const MUNINN_RUDP_IPV4_UDP_PAYLOAD_BYTES: usize = 1_472;
|
||||
const MUNINN_RUDP_FIXED_HEADER_BYTES: usize = 36;
|
||||
const MUNINN_RUDP_MEDIA_MAX_FRAGMENT_BYTES: usize = MUNINN_RUDP_IPV4_UDP_PAYLOAD_BYTES
|
||||
|
|
@ -74,9 +74,11 @@ const MUNINN_RUDP_MEDIA_REPAIR_MIN_CHUNKS_PER_SECOND: usize = 8;
|
|||
const MUNINN_RUDP_MEDIA_REPAIR_MAX_CHUNKS_PER_SECOND: usize = 6_144;
|
||||
const MUNINN_RUDP_MEDIA_REPAIR_ADD_CHUNKS_PER_SECOND: usize = 512;
|
||||
const MUNINN_RUDP_MEDIA_REPAIR_RECOVERY_INTERVAL_MS: u64 = 2_000;
|
||||
const MUNINN_RUDP_MEDIA_REPAIR_MAX_FEEDBACK_PER_POLL: usize = 8;
|
||||
const MUNINN_RUDP_MEDIA_REPAIR_MAX_CHUNKS_PER_POLL: usize = 64;
|
||||
const MUNINN_RUDP_MEDIA_SOCKET_BUFFER_BYTES: usize = 4 * 1024 * 1024;
|
||||
const MUNINN_RUDP_MEDIA_SEND_PACE_EVERY_PAYLOADS: usize = 16;
|
||||
const MUNINN_RUDP_MEDIA_SEND_PACE_SLEEP_US: u64 = 500;
|
||||
const MUNINN_RUDP_MEDIA_SEND_PACE_EVERY_PAYLOADS: usize = 4;
|
||||
const MUNINN_RUDP_MEDIA_SEND_PACE_SLEEP_US: u64 = 250;
|
||||
const MUNINN_RUDP_ACTIVE_CATALOG_REPUBLISH_MS: u64 = 2_000;
|
||||
const PS_MOVE_LED_REPORT_LEN: usize = 49;
|
||||
|
||||
|
|
@ -1913,17 +1915,25 @@ fn poll_rudp_media_receiver_feedback(
|
|||
send_pacer: &mut MuninnRudpMediaSendPacer,
|
||||
queue_dropped: u64,
|
||||
) -> Result<()> {
|
||||
let mut feedback_processed = 0_usize;
|
||||
loop {
|
||||
match transport.receive_once() {
|
||||
Ok(Some(frame)) => {
|
||||
if feedback_processed >= MUNINN_RUDP_MEDIA_REPAIR_MAX_FEEDBACK_PER_POLL {
|
||||
return Ok(());
|
||||
}
|
||||
feedback_processed += 1;
|
||||
let repair_payloads =
|
||||
record_rudp_media_receiver_feedback(&frame, stats, repair_cache)?;
|
||||
let requested_repairs = repair_payloads.len();
|
||||
let poll_limited_repairs =
|
||||
requested_repairs.min(MUNINN_RUDP_MEDIA_REPAIR_MAX_CHUNKS_PER_POLL);
|
||||
let allowed_repairs =
|
||||
repair_budget.take(repair_payloads.len(), Instant::now(), queue_dropped);
|
||||
repair_budget.take(poll_limited_repairs, Instant::now(), queue_dropped);
|
||||
stats.repair_chunks_per_second = repair_budget.chunks_per_second();
|
||||
stats.deferred_repair_chunks = stats
|
||||
.deferred_repair_chunks
|
||||
.saturating_add(repair_payloads.len().saturating_sub(allowed_repairs) as u64);
|
||||
.saturating_add(requested_repairs.saturating_sub(allowed_repairs) as u64);
|
||||
for payload in repair_payloads.into_iter().take(allowed_repairs) {
|
||||
if send_rudp_media_payload_with_backpressure(
|
||||
transport,
|
||||
|
|
|
|||
|
|
@ -287,7 +287,8 @@ struct VideoParityShardWirePayload<'a>(
|
|||
u16,
|
||||
u16,
|
||||
u16,
|
||||
&'a [u32],
|
||||
u32,
|
||||
u32,
|
||||
#[serde(with = "serde_bytes")] &'a [u8],
|
||||
);
|
||||
|
||||
|
|
@ -966,17 +967,19 @@ pub fn build_video_parity_shard(
|
|||
}
|
||||
|
||||
let mut payload_len = 0_usize;
|
||||
let mut payload_lengths = Vec::with_capacity(first.chunk_count as usize);
|
||||
let mut last_chunk_payload_bytes = 0_u32;
|
||||
for index in 0..first.chunk_count {
|
||||
let chunk = by_index
|
||||
.get(&index)
|
||||
.ok_or_else(|| anyhow!("video parity missing chunk_index {index}"))?;
|
||||
payload_len = payload_len.max(chunk.payload.len());
|
||||
payload_lengths.push(
|
||||
u32::try_from(chunk.payload.len())
|
||||
.context("video parity chunk payload length exceeds u32")?,
|
||||
);
|
||||
if index == first.chunk_count - 1 {
|
||||
last_chunk_payload_bytes = u32::try_from(chunk.payload.len())
|
||||
.context("video parity last chunk payload length exceeds u32")?;
|
||||
}
|
||||
}
|
||||
let chunk_payload_bytes =
|
||||
u32::try_from(payload_len).context("video parity chunk payload length exceeds u32")?;
|
||||
|
||||
let mut parity = vec![0_u8; payload_len];
|
||||
for index in 0..first.chunk_count {
|
||||
|
|
@ -1001,7 +1004,8 @@ pub fn build_video_parity_shard(
|
|||
chunk_count: first.chunk_count,
|
||||
parity_index: 0,
|
||||
parity_count: 1,
|
||||
chunk_payload_lengths: payload_lengths,
|
||||
chunk_payload_bytes,
|
||||
last_chunk_payload_bytes,
|
||||
payload: parity,
|
||||
}))
|
||||
}
|
||||
|
|
@ -1687,7 +1691,8 @@ fn encode_video_parity_record_payload(
|
|||
record.chunk_count,
|
||||
record.parity_index,
|
||||
record.parity_count,
|
||||
&record.chunk_payload_lengths,
|
||||
record.chunk_payload_bytes,
|
||||
record.last_chunk_payload_bytes,
|
||||
&record.payload,
|
||||
))
|
||||
}
|
||||
|
|
@ -1789,18 +1794,14 @@ fn validate_video_parity_record(record: &MuninnMediaVideoParityShardRecord) -> R
|
|||
"video parity media record currently supports exactly one XOR parity shard"
|
||||
));
|
||||
}
|
||||
if record.chunk_payload_lengths.len() != record.chunk_count as usize {
|
||||
if record.chunk_payload_bytes == 0 || record.last_chunk_payload_bytes == 0 {
|
||||
return Err(anyhow!(
|
||||
"video parity media record payload length table does not match chunk_count"
|
||||
"video parity media record chunk lengths must be non-zero"
|
||||
));
|
||||
}
|
||||
if record
|
||||
.chunk_payload_lengths
|
||||
.iter()
|
||||
.any(|length| *length == 0)
|
||||
{
|
||||
if record.last_chunk_payload_bytes > record.chunk_payload_bytes {
|
||||
return Err(anyhow!(
|
||||
"video parity media record chunk payload lengths must be non-zero"
|
||||
"video parity media record last chunk length exceeds regular chunk length"
|
||||
));
|
||||
}
|
||||
if record.payload.is_empty() {
|
||||
|
|
@ -1808,13 +1809,9 @@ fn validate_video_parity_record(record: &MuninnMediaVideoParityShardRecord) -> R
|
|||
"video parity media record payload must be non-empty"
|
||||
));
|
||||
}
|
||||
if record
|
||||
.chunk_payload_lengths
|
||||
.iter()
|
||||
.any(|length| *length as usize > record.payload.len())
|
||||
{
|
||||
if record.chunk_payload_bytes as usize != record.payload.len() {
|
||||
return Err(anyhow!(
|
||||
"video parity media record payload is shorter than a declared chunk"
|
||||
"video parity media record payload length does not match declared chunk length"
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
|
|
@ -2370,7 +2367,8 @@ mod tests {
|
|||
assert_eq!(parity.chunk_count, 3);
|
||||
assert_eq!(parity.parity_index, 0);
|
||||
assert_eq!(parity.parity_count, 1);
|
||||
assert_eq!(parity.chunk_payload_lengths, vec![2, 2, 1]);
|
||||
assert_eq!(parity.chunk_payload_bytes, 2);
|
||||
assert_eq!(parity.last_chunk_payload_bytes, 1);
|
||||
assert_eq!(parity.payload, vec![1 ^ 3 ^ 5, 2 ^ 4]);
|
||||
|
||||
let mut recovered = parity.payload.clone();
|
||||
|
|
@ -2379,7 +2377,7 @@ mod tests {
|
|||
recovered[offset] ^= *byte;
|
||||
}
|
||||
}
|
||||
recovered.truncate(parity.chunk_payload_lengths[1] as usize);
|
||||
recovered.truncate(parity.chunk_payload_bytes as usize);
|
||||
assert_eq!(recovered, records[1].payload);
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue