Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Signed-off-by: Glenn Fiedler <[email protected]>
  • Loading branch information
gafferongames authored Sep 17, 2024
1 parent 04cde1a commit eb68892
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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:
Expand Down

0 comments on commit eb68892

Please sign in to comment.