rbsrt 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,546 @@
1
+ require 'minitest/spec'
2
+ require "rbsrt"
3
+
4
+ describe SRT::Stats do
5
+
6
+ before do
7
+ # puts "server start"
8
+ @server = SRT::Socket.new
9
+ @server.bind "127.0.0.1", "6789"
10
+ @server.listen 2
11
+
12
+ @client = SRT::Socket.new
13
+ @client.connect "127.0.0.1", "6789"
14
+
15
+ @remote_client = @server.accept
16
+ end
17
+
18
+ after do
19
+ # puts "server stop"
20
+ @remote_client.close if @remote_client
21
+ @client.close if @client
22
+ @server.close if @server
23
+ end
24
+
25
+
26
+ describe "properties and aliases" do
27
+ let(:stats) do
28
+ SRT::Stats.new @remote_client, :clear => false
29
+ end
30
+
31
+ it "has time since the UDT entity is started, in milliseconds" do
32
+ assert_kind_of(Numeric, stats.msTimeStamp)
33
+ assert_kind_of(Numeric, stats.ms_time_stamp)
34
+ assert_kind_of(Numeric, stats.mstimestamp)
35
+ end
36
+
37
+ it "has total number of sent data packets, including retransmissions" do
38
+ assert_kind_of(Numeric, stats.pktSentTotal)
39
+ assert_kind_of(Numeric, stats.pkt_sent_total)
40
+ assert_kind_of(Numeric, stats.pktsenttotal)
41
+ end
42
+
43
+ it "has total number of received packets" do
44
+ assert_kind_of(Numeric, stats.pktRecvTotal)
45
+ assert_kind_of(Numeric, stats.pkt_recv_total)
46
+ assert_kind_of(Numeric, stats.pktrecvtotal)
47
+ end
48
+
49
+ it "has total number of lost packets (sender side)" do
50
+ assert_kind_of(Numeric, stats.pktSndLossTotal)
51
+ assert_kind_of(Numeric, stats.pkt_snd_loss_total)
52
+ assert_kind_of(Numeric, stats.pktsndlosstotal)
53
+ end
54
+
55
+ it "has total number of lost packets (receiver side)" do
56
+ assert_kind_of(Numeric, stats.pktRcvLossTotal)
57
+ assert_kind_of(Numeric, stats.pkt_rcv_loss_total)
58
+ assert_kind_of(Numeric, stats.pktrcvlosstotal)
59
+ end
60
+
61
+ it "has total number of retransmitted packets" do
62
+ assert_kind_of(Numeric, stats.pktRetransTotal)
63
+ assert_kind_of(Numeric, stats.pkt_retrans_total)
64
+ assert_kind_of(Numeric, stats.pktretranstotal)
65
+ end
66
+
67
+ it "has total number of sent ACK packets" do
68
+ assert_kind_of(Numeric, stats.pktSentACKTotal)
69
+ assert_kind_of(Numeric, stats.pkt_sent_ack_total)
70
+ assert_kind_of(Numeric, stats.pktsentacktotal)
71
+ end
72
+
73
+ it "has total number of received ACK packets" do
74
+ assert_kind_of(Numeric, stats.pktRecvACKTotal)
75
+ assert_kind_of(Numeric, stats.pkt_recv_ack_total)
76
+ assert_kind_of(Numeric, stats.pktrecvacktotal)
77
+ end
78
+
79
+ it "has total number of sent NAK packets" do
80
+ assert_kind_of(Numeric, stats.pktSentNAKTotal)
81
+ assert_kind_of(Numeric, stats.pkt_sent_nak_total)
82
+ assert_kind_of(Numeric, stats.pktsentnaktotal)
83
+ end
84
+
85
+ it "has total number of received NAK packets" do
86
+ assert_kind_of(Numeric, stats.pktRecvNAKTotal)
87
+ assert_kind_of(Numeric, stats.pkt_recv_nak_total)
88
+ assert_kind_of(Numeric, stats.pktrecvnaktotal)
89
+ end
90
+
91
+ it "has total time duration when UDT is sending data (idle time exclusive)" do
92
+ assert_kind_of(Numeric, stats.usSndDurationTotal)
93
+ assert_kind_of(Numeric, stats.us_snd_duration_total)
94
+ assert_kind_of(Numeric, stats.ussnddurationtotal)
95
+ end
96
+
97
+ it "has number of too-late-to-send dropped packets" do
98
+ assert_kind_of(Numeric, stats.pktSndDropTotal)
99
+ assert_kind_of(Numeric, stats.pkt_snd_drop_total)
100
+ assert_kind_of(Numeric, stats.pktsnddroptotal)
101
+ end
102
+
103
+ it "has number of too-late-to play missing packets" do
104
+ assert_kind_of(Numeric, stats.pktRcvDropTotal)
105
+ assert_kind_of(Numeric, stats.pkt_rcv_drop_total)
106
+ assert_kind_of(Numeric, stats.pktrcvdroptotal)
107
+ end
108
+
109
+ it "has number of undecrypted packets" do
110
+ assert_kind_of(Numeric, stats.pktRcvUndecryptTotal)
111
+ assert_kind_of(Numeric, stats.pkt_rcv_undecrypt_total)
112
+ assert_kind_of(Numeric, stats.pktrcvundecrypttotal)
113
+ end
114
+
115
+ it "has number of control packets supplied by packet filter" do
116
+ assert_kind_of(Numeric, stats.pktSndFilterExtraTotal)
117
+ assert_kind_of(Numeric, stats.pkt_snd_filter_extra_total)
118
+ assert_kind_of(Numeric, stats.pktsndfilterextratotal)
119
+ end
120
+
121
+ it "has number of control packets received and not supplied back" do
122
+ assert_kind_of(Numeric, stats.pktRcvFilterExtraTotal)
123
+ assert_kind_of(Numeric, stats.pkt_rcv_filter_extra_total)
124
+ assert_kind_of(Numeric, stats.pktrcvfilterextratotal)
125
+ end
126
+
127
+ it "has number of packets that the filter supplied extra (e.g. FEC rebuilt)" do
128
+ assert_kind_of(Numeric, stats.pktRcvFilterSupplyTotal)
129
+ assert_kind_of(Numeric, stats.pkt_rcv_filter_supply_total)
130
+ assert_kind_of(Numeric, stats.pktrcvfiltersupplytotal)
131
+ end
132
+
133
+ it "has number of packet loss not coverable by filter" do
134
+ assert_kind_of(Numeric, stats.pktRcvFilterLossTotal)
135
+ assert_kind_of(Numeric, stats.pkt_rcv_filter_loss_total)
136
+ assert_kind_of(Numeric, stats.pktrcvfilterlosstotal)
137
+ end
138
+
139
+ it "has total number of sent data bytes, including retransmissions" do
140
+ assert_kind_of(Numeric, stats.byteSentTotal)
141
+ assert_kind_of(Numeric, stats.byte_sent_total)
142
+ assert_kind_of(Numeric, stats.bytesenttotal)
143
+ end
144
+
145
+ it "has total number of received bytes" do
146
+ assert_kind_of(Numeric, stats.byteRecvTotal)
147
+ assert_kind_of(Numeric, stats.byte_recv_total)
148
+ assert_kind_of(Numeric, stats.byterecvtotal)
149
+ end
150
+
151
+ it "has total number of lost bytes SRT_ENABLE_LOSTBYTESCOUNT" do
152
+ assert_kind_of(Numeric, stats.byteRcvLossTotal)
153
+ assert_kind_of(Numeric, stats.byte_rcv_loss_total)
154
+ assert_kind_of(Numeric, stats.bytercvlosstotal)
155
+ end
156
+
157
+ it "has total number of retransmitted bytes" do
158
+ assert_kind_of(Numeric, stats.byteRetransTotal)
159
+ assert_kind_of(Numeric, stats.byte_retrans_total)
160
+ assert_kind_of(Numeric, stats.byteretranstotal)
161
+ end
162
+
163
+ it "has number of too-late-to-send dropped bytes" do
164
+ assert_kind_of(Numeric, stats.byteSndDropTotal)
165
+ assert_kind_of(Numeric, stats.byte_snd_drop_total)
166
+ assert_kind_of(Numeric, stats.bytesnddroptotal)
167
+ end
168
+
169
+ it "has number of too-late-to play missing bytes (estimate based on average packet size)" do
170
+ assert_kind_of(Numeric, stats.byteRcvDropTotal)
171
+ assert_kind_of(Numeric, stats.byte_rcv_drop_total)
172
+ assert_kind_of(Numeric, stats.bytercvdroptotal)
173
+ end
174
+
175
+ it "has number of undecrypted bytes" do
176
+ assert_kind_of(Numeric, stats.byteRcvUndecryptTotal)
177
+ assert_kind_of(Numeric, stats.byte_rcv_undecrypt_total)
178
+ assert_kind_of(Numeric, stats.bytercvundecrypttotal)
179
+ end
180
+
181
+ it "has number of sent data packets, including retransmissions" do
182
+ assert_kind_of(Numeric, stats.pktSent)
183
+ assert_kind_of(Numeric, stats.pkt_sent)
184
+ assert_kind_of(Numeric, stats.pktsent)
185
+ end
186
+
187
+ it "has number of received packets" do
188
+ assert_kind_of(Numeric, stats.pktRecv)
189
+ assert_kind_of(Numeric, stats.pkt_recv)
190
+ assert_kind_of(Numeric, stats.pktrecv)
191
+ end
192
+
193
+ it "has number of lost packets (sender side)" do
194
+ assert_kind_of(Numeric, stats.pktSndLoss)
195
+ assert_kind_of(Numeric, stats.pkt_snd_loss)
196
+ assert_kind_of(Numeric, stats.pktsndloss)
197
+ end
198
+
199
+ it "has number of lost packets (receiver side)" do
200
+ assert_kind_of(Numeric, stats.pktRcvLoss)
201
+ assert_kind_of(Numeric, stats.pkt_rcv_loss)
202
+ assert_kind_of(Numeric, stats.pktrcvloss)
203
+ end
204
+
205
+ it "has number of retransmitted packets" do
206
+ assert_kind_of(Numeric, stats.pktRetrans)
207
+ assert_kind_of(Numeric, stats.pkt_retrans)
208
+ assert_kind_of(Numeric, stats.pktretrans)
209
+ end
210
+
211
+ it "has number of retransmitted packets received" do
212
+ assert_kind_of(Numeric, stats.pktRcvRetrans)
213
+ assert_kind_of(Numeric, stats.pkt_rcv_retrans)
214
+ assert_kind_of(Numeric, stats.pktrcvretrans)
215
+ end
216
+
217
+ it "has number of sent ACK packets" do
218
+ assert_kind_of(Numeric, stats.pktSentACK)
219
+ assert_kind_of(Numeric, stats.pkt_sent_ack)
220
+ assert_kind_of(Numeric, stats.pktsentack)
221
+ end
222
+
223
+ it "has number of received ACK packets" do
224
+ assert_kind_of(Numeric, stats.pktRecvACK)
225
+ assert_kind_of(Numeric, stats.pkt_recv_ack)
226
+ assert_kind_of(Numeric, stats.pktrecvack)
227
+ end
228
+
229
+ it "has number of sent NAK packets" do
230
+ assert_kind_of(Numeric, stats.pktSentNAK)
231
+ assert_kind_of(Numeric, stats.pkt_sent_nak)
232
+ assert_kind_of(Numeric, stats.pktsentnak)
233
+ end
234
+
235
+ it "has number of received NAK packets" do
236
+ assert_kind_of(Numeric, stats.pktRecvNAK)
237
+ assert_kind_of(Numeric, stats.pkt_recv_nak)
238
+ assert_kind_of(Numeric, stats.pktrecvnak)
239
+ end
240
+
241
+ it "has number of control packets supplied by packet filter" do
242
+ assert_kind_of(Numeric, stats.pktSndFilterExtra)
243
+ assert_kind_of(Numeric, stats.pkt_snd_filter_extra)
244
+ assert_kind_of(Numeric, stats.pktsndfilterextra)
245
+ end
246
+
247
+ it "has number of control packets received and not supplied back" do
248
+ assert_kind_of(Numeric, stats.pktRcvFilterExtra)
249
+ assert_kind_of(Numeric, stats.pkt_rcv_filter_extra)
250
+ assert_kind_of(Numeric, stats.pktrcvfilterextra)
251
+ end
252
+
253
+ it "has number of packets that the filter supplied extra (e.g. FEC rebuilt)" do
254
+ assert_kind_of(Numeric, stats.pktRcvFilterSupply)
255
+ assert_kind_of(Numeric, stats.pkt_rcv_filter_supply)
256
+ assert_kind_of(Numeric, stats.pktrcvfiltersupply)
257
+ end
258
+
259
+ it "has number of packet loss not coverable by filter" do
260
+ assert_kind_of(Numeric, stats.pktRcvFilterLoss)
261
+ assert_kind_of(Numeric, stats.pkt_rcv_filter_loss)
262
+ assert_kind_of(Numeric, stats.pktrcvfilterloss)
263
+ end
264
+
265
+ it "has sending rate in Mb/s" do
266
+ assert_kind_of(Numeric, stats.mbpsSendRate)
267
+ assert_kind_of(Numeric, stats.mbps_send_rate)
268
+ assert_kind_of(Numeric, stats.mbpssendrate)
269
+ end
270
+
271
+ it "has receiving rate in Mb/s" do
272
+ assert_kind_of(Numeric, stats.mbpsRecvRate)
273
+ assert_kind_of(Numeric, stats.mbps_recv_rate)
274
+ assert_kind_of(Numeric, stats.mbpsrecvrate)
275
+ end
276
+
277
+ it "has busy sending time (i.e., idle time exclusive)" do
278
+ assert_kind_of(Numeric, stats.usSndDuration)
279
+ assert_kind_of(Numeric, stats.us_snd_duration)
280
+ assert_kind_of(Numeric, stats.ussndduration)
281
+ end
282
+
283
+ it "has size of order discrepancy in received sequences" do
284
+ assert_kind_of(Numeric, stats.pktReorderDistance)
285
+ assert_kind_of(Numeric, stats.pkt_reorder_distance)
286
+ assert_kind_of(Numeric, stats.pktreorderdistance)
287
+ end
288
+
289
+ it "has average time of packet delay for belated packets (packets with sequence past the ACK)" do
290
+ assert_kind_of(Numeric, stats.pktRcvAvgBelatedTime)
291
+ assert_kind_of(Numeric, stats.pkt_rcv_avg_belated_time)
292
+ assert_kind_of(Numeric, stats.pktrcvavgbelatedtime)
293
+ end
294
+
295
+ it "has number of received AND IGNORED packets due to having come too late" do
296
+ assert_kind_of(Numeric, stats.pktRcvBelated)
297
+ assert_kind_of(Numeric, stats.pkt_rcv_belated)
298
+ assert_kind_of(Numeric, stats.pktrcvbelated)
299
+ end
300
+
301
+ it "has number of too-late-to-send dropped packets" do
302
+ assert_kind_of(Numeric, stats.pktSndDrop)
303
+ assert_kind_of(Numeric, stats.pkt_snd_drop)
304
+ assert_kind_of(Numeric, stats.pktsnddrop)
305
+ end
306
+
307
+ it "has number of too-late-to play missing packets" do
308
+ assert_kind_of(Numeric, stats.pktRcvDrop)
309
+ assert_kind_of(Numeric, stats.pkt_rcv_drop)
310
+ assert_kind_of(Numeric, stats.pktrcvdrop)
311
+ end
312
+
313
+ it "has number of undecrypted packets" do
314
+ assert_kind_of(Numeric, stats.pktRcvUndecrypt)
315
+ assert_kind_of(Numeric, stats.pkt_rcv_undecrypt)
316
+ assert_kind_of(Numeric, stats.pktrcvundecrypt)
317
+ end
318
+
319
+ it "has number of sent data bytes, including retransmissions" do
320
+ assert_kind_of(Numeric, stats.byteSent)
321
+ assert_kind_of(Numeric, stats.byte_sent)
322
+ assert_kind_of(Numeric, stats.bytesent)
323
+ end
324
+
325
+ it "has number of received bytes" do
326
+ assert_kind_of(Numeric, stats.byteRecv)
327
+ assert_kind_of(Numeric, stats.byte_recv)
328
+ assert_kind_of(Numeric, stats.byterecv)
329
+ end
330
+
331
+ it "has number of retransmitted bytes SRT_ENABLE_LOSTBYTESCOUNT" do
332
+ assert_kind_of(Numeric, stats.byteRcvLoss)
333
+ assert_kind_of(Numeric, stats.byte_rcv_loss)
334
+ assert_kind_of(Numeric, stats.bytercvloss)
335
+ end
336
+
337
+ it "has number of retransmitted bytes" do
338
+ assert_kind_of(Numeric, stats.byteRetrans)
339
+ assert_kind_of(Numeric, stats.byte_retrans)
340
+ assert_kind_of(Numeric, stats.byteretrans)
341
+ end
342
+
343
+ it "has number of too-late-to-send dropped bytes" do
344
+ assert_kind_of(Numeric, stats.byteSndDrop)
345
+ assert_kind_of(Numeric, stats.byte_snd_drop)
346
+ assert_kind_of(Numeric, stats.bytesnddrop)
347
+ end
348
+
349
+ it "has number of too-late-to play missing bytes (estimate based on average packet size)" do
350
+ assert_kind_of(Numeric, stats.byteRcvDrop)
351
+ assert_kind_of(Numeric, stats.byte_rcv_drop)
352
+ assert_kind_of(Numeric, stats.bytercvdrop)
353
+ end
354
+
355
+ it "has number of undecrypted bytes" do
356
+ assert_kind_of(Numeric, stats.byteRcvUndecrypt)
357
+ assert_kind_of(Numeric, stats.byte_rcv_undecrypt)
358
+ assert_kind_of(Numeric, stats.bytercvundecrypt)
359
+ end
360
+
361
+ it "has packet sending period, in microseconds" do
362
+ assert_kind_of(Numeric, stats.usPktSndPeriod)
363
+ assert_kind_of(Numeric, stats.us_pkt_snd_period)
364
+ assert_kind_of(Numeric, stats.uspktsndperiod)
365
+ end
366
+
367
+ it "has flow window size, in number of packets" do
368
+ assert_kind_of(Numeric, stats.pktFlowWindow)
369
+ assert_kind_of(Numeric, stats.pkt_flow_window)
370
+ assert_kind_of(Numeric, stats.pktflowwindow)
371
+ end
372
+
373
+ it "has congestion window size, in number of packets" do
374
+ assert_kind_of(Numeric, stats.pktCongestionWindow)
375
+ assert_kind_of(Numeric, stats.pkt_congestion_window)
376
+ assert_kind_of(Numeric, stats.pktcongestionwindow)
377
+ end
378
+
379
+ it "has number of packets on flight" do
380
+ assert_kind_of(Numeric, stats.pktFlightSize)
381
+ assert_kind_of(Numeric, stats.pkt_flight_size)
382
+ assert_kind_of(Numeric, stats.pktflightsize)
383
+ end
384
+
385
+ it "has RTT, in milliseconds" do
386
+ assert_kind_of(Numeric, stats.msRTT)
387
+ assert_kind_of(Numeric, stats.ms_rtt)
388
+ assert_kind_of(Numeric, stats.msrtt)
389
+ end
390
+
391
+ it "has estimated bandwidth, in Mb/s" do
392
+ assert_kind_of(Numeric, stats.mbpsBandwidth)
393
+ assert_kind_of(Numeric, stats.mbps_bandwidth)
394
+ assert_kind_of(Numeric, stats.mbpsbandwidth)
395
+ end
396
+
397
+ it "has available UDT sender buffer size" do
398
+ assert_kind_of(Numeric, stats.byteAvailSndBuf)
399
+ assert_kind_of(Numeric, stats.byte_avail_snd_buf)
400
+ assert_kind_of(Numeric, stats.byteavailsndbuf)
401
+ end
402
+
403
+ it "has available UDT receiver buffer size" do
404
+ assert_kind_of(Numeric, stats.byteAvailRcvBuf)
405
+ assert_kind_of(Numeric, stats.byte_avail_rcv_buf)
406
+ assert_kind_of(Numeric, stats.byteavailrcvbuf)
407
+ end
408
+
409
+ it "has Transmit Bandwidth ceiling (Mbps)" do
410
+ assert_kind_of(Numeric, stats.mbpsMaxBW)
411
+ assert_kind_of(Numeric, stats.mbps_max_bw)
412
+ assert_kind_of(Numeric, stats.mbpsmaxbw)
413
+ end
414
+
415
+ it "has MTU" do
416
+ assert_kind_of(Numeric, stats.byteMSS)
417
+ assert_kind_of(Numeric, stats.byte_mss)
418
+ assert_kind_of(Numeric, stats.bytemss)
419
+ end
420
+
421
+ it "has UnACKed packets in UDT sender" do
422
+ assert_kind_of(Numeric, stats.pktSndBuf)
423
+ assert_kind_of(Numeric, stats.pkt_snd_buf)
424
+ assert_kind_of(Numeric, stats.pktsndbuf)
425
+ end
426
+
427
+ it "has UnACKed bytes in UDT sender" do
428
+ assert_kind_of(Numeric, stats.byteSndBuf)
429
+ assert_kind_of(Numeric, stats.byte_snd_buf)
430
+ assert_kind_of(Numeric, stats.bytesndbuf)
431
+ end
432
+
433
+ it "has UnACKed timespan (msec) of UDT sender" do
434
+ assert_kind_of(Numeric, stats.msSndBuf)
435
+ assert_kind_of(Numeric, stats.ms_snd_buf)
436
+ assert_kind_of(Numeric, stats.mssndbuf)
437
+ end
438
+
439
+ it "has Timestamp-based Packet Delivery Delay" do
440
+ assert_kind_of(Numeric, stats.msSndTsbPdDelay)
441
+ assert_kind_of(Numeric, stats.ms_snd_tsb_pd_delay)
442
+ assert_kind_of(Numeric, stats.mssndtsbpddelay)
443
+ end
444
+
445
+ it "has Undelivered packets in UDT receiver" do
446
+ assert_kind_of(Numeric, stats.pktRcvBuf)
447
+ assert_kind_of(Numeric, stats.pkt_rcv_buf)
448
+ assert_kind_of(Numeric, stats.pktrcvbuf)
449
+ end
450
+
451
+ it "has Undelivered bytes of UDT receiver" do
452
+ assert_kind_of(Numeric, stats.byteRcvBuf)
453
+ assert_kind_of(Numeric, stats.byte_rcv_buf)
454
+ assert_kind_of(Numeric, stats.bytercvbuf)
455
+ end
456
+
457
+ it "has Undelivered timespan (msec) of UDT receiver" do
458
+ assert_kind_of(Numeric, stats.msRcvBuf)
459
+ assert_kind_of(Numeric, stats.ms_rcv_buf)
460
+ assert_kind_of(Numeric, stats.msrcvbuf)
461
+ end
462
+
463
+ it "has Timestamp-based Packet Delivery Delay" do
464
+ assert_kind_of(Numeric, stats.msRcvTsbPdDelay)
465
+ assert_kind_of(Numeric, stats.ms_rcv_tsb_pd_delay)
466
+ assert_kind_of(Numeric, stats.msrcvtsbpddelay)
467
+ end
468
+ end
469
+
470
+ describe "clearing vs non-clearing" do
471
+
472
+ it "will not clear stats by default" do
473
+ # initial data
474
+
475
+ @client.write "foobar"
476
+ _ = @remote_client.read
477
+
478
+ stats = SRT::Stats.new(@client)
479
+ byte_sent = stats.byte_sent
480
+ assert(byte_sent > 0, "should have sent bytes")
481
+
482
+
483
+ # same data
484
+
485
+ stats2 = SRT::Stats.new(@client)
486
+ byte_sent_2 = stats2.byte_sent
487
+ assert_equal(byte_sent_2, byte_sent, "should have same bytes")
488
+
489
+ # more data
490
+
491
+ @client.write "baz"
492
+ _ = @remote_client.read
493
+
494
+ stats3 = SRT::Stats.new(@client)
495
+ byte_sent_3 = stats3.byte_sent
496
+ assert(byte_sent_3 > byte_sent, "should have more bytes")
497
+ end
498
+
499
+ it "will not clear stats when :clear => false" do
500
+ # initial data
501
+
502
+ @client.write "foobar"
503
+ _ = @remote_client.read
504
+
505
+ stats = SRT::Stats.new(@client, :clear => false)
506
+ byte_sent = stats.byte_sent
507
+ assert(byte_sent > 0, "should have sent bytes")
508
+
509
+
510
+ # same data
511
+
512
+ stats2 = SRT::Stats.new(@client, :clear => false)
513
+ byte_sent_2 = stats2.byte_sent
514
+ assert_equal(byte_sent_2, byte_sent, "should have same bytes")
515
+
516
+ # more data
517
+
518
+ @client.write "baz"
519
+ _ = @remote_client.read
520
+
521
+ stats3 = SRT::Stats.new(@client, :clear => false)
522
+ byte_sent_3 = stats3.byte_sent
523
+ assert(byte_sent_3 > byte_sent, "should have more bytes")
524
+ end
525
+
526
+ it "will clear stats when :clear => true" do
527
+ # initial data
528
+
529
+ @client.write "foobar"
530
+ _ = @remote_client.read
531
+
532
+ stats = SRT::Stats.new(@client, :clear => true)
533
+ byte_sent = stats.byte_sent
534
+ assert(byte_sent > 0, "should have sent bytes")
535
+
536
+ # more data
537
+
538
+ @client.write "baz"
539
+ _ = @remote_client.read
540
+
541
+ stats3 = SRT::Stats.new(@client, :clear => true)
542
+ byte_sent_3 = stats3.byte_sent
543
+ assert(byte_sent_3 < byte_sent, "should have less bytes")
544
+ end
545
+ end
546
+ end