From eb688923d8b1239dbd5db8aa4337b6326f6b7758 Mon Sep 17 00:00:00 2001 From: Glenn Fiedler Date: Tue, 17 Sep 2024 07:22:22 -0400 Subject: [PATCH] Update README.md Signed-off-by: Glenn Fiedler --- README.md | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a509ba6..6427a80 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ Before you send a packet, you can ask reliable what sequence number the sent pac uint16_t sequence = reliable_endpoint_next_packet_sequence( endpoint ); ``` -This way you can map acked sequence numbers to the contents of packets you sent, for example to resend unacked messages until a packet that included that message was acked. +This way you can map acked sequence numbers to the contents of packets you sent, for example, resending unacked messages until a packet that included that message was acked. Make sure to update each endpoint once per-frame. This keeps track of network stats like latency, jitter, packet loss and bandwidth: @@ -111,13 +111,10 @@ reliable_endpoint_update( endpoint, time ); You can then grab stats from the endpoint: ```c - printf( "%" PRIi64 " sent | %" PRIi64 " received | %" PRIi64 " acked | rtt = %dms | jitter = %dms | packet loss = %d%% | sent = %dkbps | recv = %dkbps | acked = %dkbps\n", - counters[RELIABLE_ENDPOINT_COUNTER_NUM_PACKETS_SENT], - counters[RELIABLE_ENDPOINT_COUNTER_NUM_PACKETS_RECEIVED], - counters[RELIABLE_ENDPOINT_COUNTER_NUM_PACKETS_ACKED], - (int) reliable_endpoint_rtt_min( global_context.client ), - (int) reliable_endpoint_jitter( global_context.client ), - (int) ( reliable_endpoint_packet_loss( global_context.client ) + 0.5f ), + printf( rtt = %.1fms | jitter = %.1fms | packet loss = %.1f%%\n", + reliable_endpoint_rtt_min( endpoint ), + reliable_endpoint_jitter( endpoint ), + reliable_endpoint_packet_loss( endpoint ) ), ``` When you are finished with an endpoint, destroy it: