1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
|
/*
* This file is part of Go Responsiveness.
*
* Go Responsiveness is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software Foundation,
* either version 2 of the License, or (at your option) any later version.
* Go Responsiveness is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with Go Responsiveness. If not, see <https://www.gnu.org/licenses/>.
*/
package rpm
import (
"context"
"crypto/tls"
"fmt"
"io"
"net/http"
"net/http/httptrace"
"os"
"sync"
"time"
"github.com/network-quality/goresponsiveness/constants"
"github.com/network-quality/goresponsiveness/debug"
"github.com/network-quality/goresponsiveness/extendedstats"
"github.com/network-quality/goresponsiveness/lgc"
"github.com/network-quality/goresponsiveness/stats"
"github.com/network-quality/goresponsiveness/traceable"
"github.com/network-quality/goresponsiveness/utilities"
"golang.org/x/net/http2"
)
func addFlows(
ctx context.Context,
toAdd uint64,
lgcc *lgc.LoadGeneratingConnectionCollection,
lgcGenerator func() lgc.LoadGeneratingConnection,
debug debug.DebugLevel,
) {
lgcc.Lock.Lock()
defer lgcc.Lock.Unlock()
for i := uint64(0); i < toAdd; i++ {
*lgcc.LGCs = append(*lgcc.LGCs, lgcGenerator())
if !(*lgcc.LGCs)[len(*lgcc.LGCs)-1].Start(ctx, debug) {
fmt.Printf(
"Error starting lgc with id %d!\n",
(*lgcc.LGCs)[len(*lgcc.LGCs)-1].ClientId(),
)
return
}
}
}
type ProbeConfiguration struct {
URL string
}
type ProbeDataPoint struct {
Time time.Time `Description:"Time of the generation of the data point." Formatter:"Format" FormatterArgument:"01-02-2006-15-04-05.000"`
RoundTripCount uint64 `Description:"The number of round trips measured by this data point."`
Duration time.Duration `Description:"The duration for this measurement." Formatter:"Seconds"`
TCPRtt time.Duration `Description:"The underlying connection's RTT at probe time." Formatter:"Seconds"`
TCPCwnd uint32 `Description:"The underlying connection's congestion window at probe time."`
Type ProbeType `Description:"The type of the probe." Formatter:"Value"`
}
type ThroughputDataPoint struct {
Time time.Time `Description:"Time of the generation of the data point." Formatter:"Format" FormatterArgument:"01-02-2006-15-04-05.000"`
Throughput float64 `Description:"Instantaneous throughput (b/s)."`
Connections int `Description: Number of parallel connections."`
}
type SelfDataCollectionResult struct {
RateBps float64
LGCs []lgc.LoadGeneratingConnection
ProbeDataPoints []ProbeDataPoint
LoggingContinuation func()
}
type ProbeType int64
const (
Self ProbeType = iota
Foreign
)
func (pt ProbeType) Value() string {
if pt == Self {
return "Self"
}
return "Foreign"
}
func Probe(
parentProbeCtx context.Context,
waitGroup *sync.WaitGroup,
client *http.Client,
probeUrl string,
probeType ProbeType,
result *chan ProbeDataPoint,
debugging *debug.DebugWithPrefix,
) error {
if waitGroup != nil {
waitGroup.Add(1)
defer waitGroup.Done()
}
if client == nil {
return fmt.Errorf("cannot start a probe with a nil client")
}
probeId := utilities.GenerateUniqueId()
probeTracer := NewProbeTracer(client, probeType, probeId, debugging)
time_before_probe := time.Now()
probe_req, err := http.NewRequestWithContext(
httptrace.WithClientTrace(parentProbeCtx, probeTracer.trace),
"GET",
probeUrl,
nil,
)
if err != nil {
return err
}
// Used to disable compression
probe_req.Header.Set("Accept-Encoding", "identity")
probe_resp, err := client.Do(probe_req)
if err != nil {
return err
}
// Header.Get returns "" when not set
if probe_resp.Header.Get("Content-Encoding") != "" {
return fmt.Errorf("Content-Encoding header was set (compression not allowed)")
}
// TODO: Make this interruptable somehow by using _ctx_.
_, err = io.ReadAll(probe_resp.Body)
if err != nil {
return err
}
time_after_probe := time.Now()
// Depending on whether we think that Close() requires another RTT (via TCP), we
// may need to move this before/after capturing the after time.
probe_resp.Body.Close()
sanity := time_after_probe.Sub(time_before_probe)
// When the probe is run on a load-generating connection (a self probe) there should
// only be a single round trip that is measured. We will take the accumulation of all these
// values just to be sure, though. Because of how this traced connection was launched, most
// of the values will be 0 (or very small where the time that go takes for delivering callbacks
// and doing context switches pokes through). When it is !isSelfProbe then the values will
// be significant and we want to add them regardless!
totalDelay := probeTracer.GetTLSAndHttpHeaderDelta() + probeTracer.GetHttpDownloadDelta(
time_after_probe,
) + probeTracer.GetTCPDelta()
// We must have reused the connection if we are a self probe!
if probeType == Self && !probeTracer.stats.ConnectionReused {
panic(!probeTracer.stats.ConnectionReused)
}
if debug.IsDebug(debugging.Level) {
fmt.Printf(
"(%s) (%s Probe %v) sanity vs total: %v vs %v\n",
debugging.Prefix,
probeType.Value(),
probeId,
sanity,
totalDelay,
)
}
roundTripCount := uint64(1)
if probeType == Foreign {
roundTripCount = 3
}
// Careful!!! It's possible that this channel has been closed because the Prober that
// started it has been stopped. Writing to a closed channel will cause a panic. It might not
// matter because a panic just stops the go thread containing the paniced code and we are in
// a go thread that executes only this function.
defer func() {
isThreadPanicing := recover()
if isThreadPanicing != nil && debug.IsDebug(debugging.Level) {
fmt.Printf(
"(%s) (%s Probe %v) Probe attempted to write to the result channel after its invoker ended (official reason: %v).\n",
debugging.Prefix,
probeType.Value(),
probeId,
isThreadPanicing,
)
}
}()
tcpRtt := time.Duration(0 * time.Second)
tcpCwnd := uint32(0)
// TODO: Only get the extended stats for a connection if the user has requested them overall.
if extendedstats.ExtendedStatsAvailable() {
tcpInfo, err := extendedstats.GetTCPInfo(probeTracer.stats.ConnInfo.Conn)
if err == nil {
tcpRtt = time.Duration(tcpInfo.Rtt) * time.Microsecond
tcpCwnd = tcpInfo.Snd_cwnd
} else {
fmt.Printf("Warning: Could not fetch the extended stats for a probe: %v\n", err)
}
}
dataPoint := ProbeDataPoint{
Time: time_before_probe,
RoundTripCount: roundTripCount,
Duration: totalDelay,
TCPRtt: tcpRtt,
TCPCwnd: tcpCwnd,
Type: probeType,
}
*result <- dataPoint
return nil
}
func CombinedProber(
proberCtx context.Context,
foreignProbeConfigurationGenerator func() ProbeConfiguration,
selfProbeConfigurationGenerator func() ProbeConfiguration,
selfProbeConnection lgc.LoadGeneratingConnection,
probeInterval time.Duration,
keyLogger io.Writer,
debugging *debug.DebugWithPrefix,
) (dataPoints chan ProbeDataPoint) {
// Make a channel to send back all the generated data points
// when we are probing.
dataPoints = make(chan ProbeDataPoint)
go func() {
wg := sync.WaitGroup{}
probeCount := 0
// As long as our context says that we can continue to probe!
for proberCtx.Err() == nil {
time.Sleep(probeInterval)
foreignProbeConfiguration := foreignProbeConfigurationGenerator()
selfProbeConfiguration := selfProbeConfigurationGenerator()
if debug.IsDebug(debugging.Level) {
fmt.Printf(
"(%s) About to send round %d of probes!\n",
debugging.Prefix,
probeCount+1,
)
}
transport := http2.Transport{}
transport.TLSClientConfig = &tls.Config{}
if !utilities.IsInterfaceNil(keyLogger) {
if debug.IsDebug(debugging.Level) {
fmt.Printf(
"Using an SSL Key Logger for this foreign probe.\n",
)
}
// The presence of a custom TLSClientConfig in a *generic* `transport`
// means that go will default to HTTP/1.1 and cowardly avoid HTTP/2:
// https://github.com/golang/go/blob/7ca6902c171b336d98adbb103d701a013229c806/src/net/http/transport.go#L278
// Also, it would appear that the API's choice of HTTP vs HTTP2 can
// depend on whether the url contains
// https:// or http://:
// https://github.com/golang/go/blob/7ca6902c171b336d98adbb103d701a013229c806/src/net/http/transport.go#L74
transport.TLSClientConfig.KeyLogWriter = keyLogger
}
transport.TLSClientConfig.InsecureSkipVerify = true
foreignProbeClient := &http.Client{Transport: &transport}
probeCount++
go Probe(
proberCtx,
&wg,
foreignProbeClient,
foreignProbeConfiguration.URL,
Foreign,
&dataPoints,
debugging,
)
go Probe(
proberCtx,
&wg,
selfProbeConnection.Client(),
selfProbeConfiguration.URL,
SelfDown,
&dataPoints,
debugging,
)
// Start Upload Connection Prober
go Probe(
proberCtx,
&wg,
selfUpProbeConnection.Client(),
selfProbeConfiguration.URL,
SelfUp,
&dataPoints,
debugging,
)
}
if debug.IsDebug(debugging.Level) {
fmt.Printf(
"(%s) Combined probe driver is going to start waiting for its probes to finish.\n",
debugging.Prefix,
)
}
utilities.OrTimeout(func() { wg.Wait() }, 2*time.Second)
if debug.IsDebug(debugging.Level) {
fmt.Printf(
"(%s) Combined probe driver is done waiting for its probes to finish.\n",
debugging.Prefix,
)
}
close(dataPoints)
}()
return
}
func LoadGenerator(
networkActivityCtx context.Context, // Create all network connections in this context.
loadGeneratorCtx context.Context, // Stop our activity when we no longer need to generate load.
rampupInterval time.Duration,
lgcGenerator func() lgc.LoadGeneratingConnection, // Use this to generate a new load-generating connection.
loadGeneratingConnections *lgc.LoadGeneratingConnectionCollection,
debugging *debug.DebugWithPrefix, // How can we forget debugging?
) (probeConnectionCommunicationChannel chan lgc.LoadGeneratingConnection, // Send back a channel to communicate the connection to be used for self probes.
throughputCalculations chan ThroughputDataPoint, // Send back all the instantaneous throughputs that we generate.
) {
throughputCalculations = make(chan ThroughputDataPoint)
// The channel that we are going to use to send back the connection to use for probing may not immediately
// be read by the caller. We don't want to wait around until they are ready before we start doing our work.
// So, we'll make it buffered.
probeConnectionCommunicationChannel = make(chan lgc.LoadGeneratingConnection, 1)
go func() {
flowsCreated := uint64(0)
addFlows(
networkActivityCtx,
constants.StartingNumberOfLoadGeneratingConnections,
loadGeneratingConnections,
lgcGenerator,
debugging.Level,
)
flowsCreated += constants.StartingNumberOfLoadGeneratingConnections
// We have at least a single load-generating channel. This channel will be the one that
// the self probes use. Let's send it back to the caller so that they can pass it on if they need to.
probeConnectionCommunicationChannel <- (*loadGeneratingConnections.LGCs)[0]
nextSampleStartTime := time.Now().Add(rampupInterval)
for currentInterval := uint64(0); true; currentInterval++ {
// If the loadGeneratorCtx is canceled, then that means our work here is done ...
if loadGeneratorCtx.Err() != nil {
break
}
now := time.Now()
// At each 1-second interval
if nextSampleStartTime.Sub(now) > 0 {
if debug.IsDebug(debugging.Level) {
fmt.Printf(
"%v: Sleeping until %v\n",
debugging,
nextSampleStartTime,
)
}
time.Sleep(nextSampleStartTime.Sub(now))
} else {
fmt.Fprintf(os.Stderr, "Warning: Missed a one-second deadline.\n")
}
nextSampleStartTime = time.Now().Add(time.Second)
// Compute "instantaneous aggregate" goodput which is the number of
// bytes transferred within the last second.
var instantaneousTotalThroughput float64 = 0
allInvalid := true
for i := range *loadGeneratingConnections.LGCs {
if !(*loadGeneratingConnections.LGCs)[i].IsValid() {
if debug.IsDebug(debugging.Level) {
fmt.Printf(
"%v: Load-generating connection with id %d is invalid ... skipping.\n",
debugging,
(*loadGeneratingConnections.LGCs)[i].ClientId(),
)
}
continue
}
allInvalid = false
currentTransferred, currentInterval := (*loadGeneratingConnections.LGCs)[i].TransferredInInterval()
// normalize to a second-long interval!
instantaneousConnectionThroughput := float64(
currentTransferred,
) / float64(
currentInterval.Seconds(),
)
instantaneousTotalThroughput += instantaneousConnectionThroughput
}
// For some reason, all the lgcs are invalid. This likely means that
// the network/server went away.
if allInvalid {
if debug.IsDebug(debugging.Level) {
fmt.Printf(
"%v: All lgcs were invalid. Assuming that network/server went away.\n",
debugging,
)
}
break
}
// We have generated a throughput calculation -- let's send it back to the coordinator
throughputDataPoint := ThroughputDataPoint{time.Now(), instantaneousTotalThroughput, len(*loadGeneratingConnections.LGCs)}
throughputCalculations <- throughputDataPoint
// Just add another constants.AdditiveNumberOfLoadGeneratingConnections flows -- that's our only job now!
addFlows(
networkActivityCtx,
constants.AdditiveNumberOfLoadGeneratingConnections,
loadGeneratingConnections,
lgcGenerator,
debugging.Level,
)
flowsCreated += constants.AdditiveNumberOfLoadGeneratingConnections
}
if debug.IsDebug(debugging.Level) {
fmt.Printf(
"(%s) Stopping a load generator after creating %d flows.\n",
debugging.Prefix, flowsCreated)
}
}()
return
}
type ProbeTracer struct {
client *http.Client
stats *stats.TraceStats
trace *httptrace.ClientTrace
debug debug.DebugLevel
probeid uint64
probeType ProbeType
}
func (p *ProbeTracer) String() string {
return fmt.Sprintf("(Probe %v): stats: %v\n", p.probeid, p.stats)
}
func (p *ProbeTracer) ProbeId() uint64 {
return p.probeid
}
func (p *ProbeTracer) GetTrace() *httptrace.ClientTrace {
return p.trace
}
func (p *ProbeTracer) GetDnsDelta() time.Duration {
if p.stats.ConnectionReused {
return time.Duration(0)
}
delta := p.stats.DnsDoneTime.Sub(p.stats.DnsStartTime)
if debug.IsDebug(p.debug) {
fmt.Printf("(Probe %v): DNS Time: %v\n", p.probeid, delta)
}
return delta
}
func (p *ProbeTracer) GetTCPDelta() time.Duration {
if p.stats.ConnectionReused {
return time.Duration(0)
}
delta := p.stats.ConnectDoneTime.Sub(p.stats.ConnectStartTime)
if debug.IsDebug(p.debug) {
fmt.Printf("(Probe %v): TCP Connection Time: %v\n", p.probeid, delta)
}
return delta
}
func (p *ProbeTracer) GetTLSDelta() time.Duration {
if utilities.IsSome(p.stats.TLSDoneTime) {
panic("There should not be TLS information, but there is.")
}
delta := time.Duration(0)
if debug.IsDebug(p.debug) {
fmt.Printf("(Probe %v): TLS Time: %v\n", p.probeid, delta)
}
return delta
}
func (p *ProbeTracer) GetTLSAndHttpHeaderDelta() time.Duration {
// Because the TLS handshake occurs *after* the TCP connection (ConnectDoneTime)
// and *before* the HTTP transaction, we know that the delta between the time
// that the first HTTP response byte is available and the time that the TCP
// connection was established includes both the time for the HTTP header RTT
// *and* the TLS handshake RTT, whether we can specifically measure the latter
// or not. Eventually when TLS handshake tracing is fixed, we can break these
// into separate buckets, but for now this workaround is reasonable.
before := p.stats.ConnectDoneTime
if p.stats.ConnectionReused {
// When we reuse a connection there will be no time logged for when the
// TCP connection was established (obviously). So, fall back to the time
// when we were notified about reusing a connection (as a close approximation!).
before = p.stats.GetConnectionDoneTime
}
delta := p.stats.HttpResponseReadyTime.Sub(before)
if debug.IsDebug(p.debug) {
fmt.Printf("(Probe %v): Http TLS and Header Time: %v\n", p.probeid, delta)
}
return delta
}
func (p *ProbeTracer) GetHttpHeaderDelta() time.Duration {
panic(
"Unusable until TLS tracing support is enabled! Use GetTLSAndHttpHeaderDelta() instead.\n",
)
delta := p.stats.HttpResponseReadyTime.Sub(utilities.GetSome(p.stats.TLSDoneTime))
if debug.IsDebug(p.debug) {
fmt.Printf("(Probe %v): Http Header Time: %v\n", p.probeid, delta)
}
return delta
}
func (p *ProbeTracer) GetHttpDownloadDelta(httpDoneTime time.Time) time.Duration {
delta := httpDoneTime.Sub(p.stats.HttpResponseReadyTime)
if debug.IsDebug(p.debug) {
fmt.Printf("(Probe %v): Http Download Time: %v\n", p.probeid, delta)
}
return delta
}
func NewProbeTracer(
client *http.Client,
probeType ProbeType,
probeId uint64,
debugging *debug.DebugWithPrefix,
) *ProbeTracer {
probe := &ProbeTracer{
client: client,
stats: &stats.TraceStats{},
trace: nil,
debug: debugging.Level,
probeid: probeId,
probeType: probeType,
}
trace := traceable.GenerateHttpTimingTracer(probe, debugging.Level)
probe.trace = trace
return probe
}
func (probe *ProbeTracer) SetDnsStartTimeInfo(
now time.Time,
dnsStartInfo httptrace.DNSStartInfo,
) {
probe.stats.DnsStartTime = now
probe.stats.DnsStart = dnsStartInfo
if debug.IsDebug(probe.debug) {
fmt.Printf(
"(%s Probe) DNS Start for Probe %v: %v\n",
probe.probeType.Value(),
probe.ProbeId(),
dnsStartInfo,
)
}
}
func (probe *ProbeTracer) SetDnsDoneTimeInfo(
now time.Time,
dnsDoneInfo httptrace.DNSDoneInfo,
) {
probe.stats.DnsDoneTime = now
probe.stats.DnsDone = dnsDoneInfo
if debug.IsDebug(probe.debug) {
fmt.Printf(
"(%s Probe) DNS Done for Probe %v: %v\n",
probe.probeType.Value(),
probe.ProbeId(),
probe.stats.DnsDone,
)
}
}
func (probe *ProbeTracer) SetConnectStartTime(
now time.Time,
) {
probe.stats.ConnectStartTime = now
if debug.IsDebug(probe.debug) {
fmt.Printf(
"(%s Probe) TCP Start for Probe %v at %v\n",
probe.probeType.Value(),
probe.ProbeId(),
probe.stats.ConnectStartTime,
)
}
}
func (probe *ProbeTracer) SetConnectDoneTimeError(
now time.Time,
err error,
) {
probe.stats.ConnectDoneTime = now
probe.stats.ConnectDoneError = err
if debug.IsDebug(probe.debug) {
fmt.Printf(
"(%s Probe) TCP Done for Probe %v (with error %v) @ %v\n",
probe.probeType.Value(),
probe.ProbeId(),
probe.stats.ConnectDoneError,
probe.stats.ConnectDoneTime,
)
}
}
func (probe *ProbeTracer) SetGetConnTime(now time.Time) {
probe.stats.GetConnectionStartTime = now
if debug.IsDebug(probe.debug) {
fmt.Printf(
"(%s Probe) Started getting connection for Probe %v @ %v\n",
probe.probeType.Value(),
probe.ProbeId(),
probe.stats.GetConnectionStartTime,
)
}
}
func (probe *ProbeTracer) SetGotConnTimeInfo(
now time.Time,
gotConnInfo httptrace.GotConnInfo,
) {
probe.stats.GetConnectionDoneTime = now
probe.stats.ConnInfo = gotConnInfo
probe.stats.ConnectionReused = gotConnInfo.Reused
if probe.probeType == Self && !gotConnInfo.Reused {
fmt.Fprintf(
os.Stderr,
"A self probe sent used a new connection!\n",
)
}
if gotConnInfo.Reused {
if debug.IsDebug(probe.debug) {
fmt.Printf(
"(%s Probe) Got a reused connection for Probe %v at %v with info %v\n",
probe.probeType.Value(),
probe.ProbeId(),
probe.stats.GetConnectionDoneTime,
probe.stats.ConnInfo,
)
}
}
}
func (probe *ProbeTracer) SetTLSHandshakeStartTime(
now time.Time,
) {
probe.stats.TLSStartTime = utilities.Some(now)
if debug.IsDebug(probe.debug) {
fmt.Printf(
"(%s Probe) Started TLS Handshake for Probe %v @ %v\n",
probe.probeType.Value(),
probe.ProbeId(),
probe.stats.TLSStartTime,
)
}
}
func (probe *ProbeTracer) SetTLSHandshakeDoneTimeState(
now time.Time,
connectionState tls.ConnectionState,
) {
probe.stats.TLSDoneTime = utilities.Some(now)
probe.stats.TLSConnInfo = connectionState
if debug.IsDebug(probe.debug) {
fmt.Printf(
"(%s Probe) Completed TLS handshake for Probe %v at %v with info %v\n",
probe.probeType.Value(),
probe.ProbeId(),
probe.stats.TLSDoneTime,
probe.stats.TLSConnInfo,
)
}
}
func (probe *ProbeTracer) SetHttpWroteRequestTimeInfo(
now time.Time,
info httptrace.WroteRequestInfo,
) {
probe.stats.HttpWroteRequestTime = now
probe.stats.HttpInfo = info
if debug.IsDebug(probe.debug) {
fmt.Printf(
"(%s Probe) Http finished writing request for Probe %v at %v with info %v\n",
probe.probeType.Value(),
probe.ProbeId(),
probe.stats.HttpWroteRequestTime,
probe.stats.HttpInfo,
)
}
}
func (probe *ProbeTracer) SetHttpResponseReadyTime(
now time.Time,
) {
probe.stats.HttpResponseReadyTime = now
if debug.IsDebug(probe.debug) {
fmt.Printf(
"(%s Probe) Http response is ready for Probe %v at %v\n",
probe.probeType.Value(),
probe.ProbeId(),
probe.stats.HttpResponseReadyTime,
)
}
}
|