Skip to content

Commit 04cde1a

Browse files
Update README.md
Signed-off-by: Glenn Fiedler <glenn@networknext.com>
1 parent e3b36b3 commit 04cde1a

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

README.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,32 @@ Once you process all acks, clear them:
9494
reliable_endpoint_clear_acks( endpoint );
9595
```
9696
97-
And make sure to update each endpoint once per-frame, so it keeps track of network connection stats like latency, jitter, packet loss and bandwidth:
97+
Before you send a packet, you can ask reliable what sequence number the sent packet will have:
98+
99+
```c
100+
uint16_t sequence = reliable_endpoint_next_packet_sequence( endpoint );
101+
```
102+
103+
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.
104+
105+
Make sure to update each endpoint once per-frame. This keeps track of network stats like latency, jitter, packet loss and bandwidth:
98106

99107
```c
100108
reliable_endpoint_update( endpoint, time );
101109
```
102110
111+
You can then grab stats from the endpoint:
112+
113+
```c
114+
printf( "%" PRIi64 " sent | %" PRIi64 " received | %" PRIi64 " acked | rtt = %dms | jitter = %dms | packet loss = %d%% | sent = %dkbps | recv = %dkbps | acked = %dkbps\n",
115+
counters[RELIABLE_ENDPOINT_COUNTER_NUM_PACKETS_SENT],
116+
counters[RELIABLE_ENDPOINT_COUNTER_NUM_PACKETS_RECEIVED],
117+
counters[RELIABLE_ENDPOINT_COUNTER_NUM_PACKETS_ACKED],
118+
(int) reliable_endpoint_rtt_min( global_context.client ),
119+
(int) reliable_endpoint_jitter( global_context.client ),
120+
(int) ( reliable_endpoint_packet_loss( global_context.client ) + 0.5f ),
121+
```
122+
103123
When you are finished with an endpoint, destroy it:
104124

105125
```c

0 commit comments

Comments
 (0)