From b2ea60582c753719c3c7ba9e7ec83843ace4fb4f Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Mon, 27 Sep 2021 21:25:00 +0200 Subject: [PATCH 1/2] feat(ndt7): save application-level pings --- ndt7/model/archivaldata.go | 10 ++++++++++ ndt7/receiver/receiver.go | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/ndt7/model/archivaldata.go b/ndt7/model/archivaldata.go index 7d09525e..67fcd0c5 100644 --- a/ndt7/model/archivaldata.go +++ b/ndt7/model/archivaldata.go @@ -16,6 +16,16 @@ type ArchivalData struct { ServerMeasurements []Measurement ClientMeasurements []Measurement ClientMetadata []metadata.NameValue `json:",omitempty"` + PingMeasurements []PingMeasurement +} + +// PingMeasurement is a ping measurement. +type PingMeasurement struct { + // RTT is the app-level RTT in millisecond. + RTT float64 + + // ElapsedTime is the elapsed time in microseconds. + ElapsedTime int64 } // The Measurement struct contains measurement results. This structure is diff --git a/ndt7/receiver/receiver.go b/ndt7/receiver/receiver.go index 7a586fcb..c5fa7518 100644 --- a/ndt7/receiver/receiver.go +++ b/ndt7/receiver/receiver.go @@ -26,6 +26,8 @@ func start( ctx context.Context, conn *websocket.Conn, kind receiverKind, data *model.ArchivalData, ) { + // TODO(bassosimone): use a uniform definition of "beginning of time" + begin := time.Time() logging.Logger.Debug("receiver: start") proto := ndt7metrics.ConnLabel(conn) defer logging.Logger.Debug("receiver: stop") @@ -44,6 +46,10 @@ func start( if err == nil { rtt /= int64(time.Millisecond) logging.Logger.Debugf("receiver: ApplicationLevel RTT: %d ms", rtt) + data.PingMeasurements = append(data.PingMeasurements, &model.PingMeasurement{ + RTT: rtt, + ElapsedTime: time.Since(begin) / time.Microsecond, + }) } else { ndt7metrics.ClientReceiverErrors.WithLabelValues( proto, string(kind), "ping-parse-ticks").Inc() From faf2c69c59c93da6af5ff1a1726831a6571df657 Mon Sep 17 00:00:00 2001 From: Simone Basso Date: Mon, 27 Sep 2021 21:45:23 +0200 Subject: [PATCH 2/2] fix: build was broken --- ndt7/model/archivaldata.go | 2 +- ndt7/receiver/receiver.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ndt7/model/archivaldata.go b/ndt7/model/archivaldata.go index 67fcd0c5..01b96998 100644 --- a/ndt7/model/archivaldata.go +++ b/ndt7/model/archivaldata.go @@ -22,7 +22,7 @@ type ArchivalData struct { // PingMeasurement is a ping measurement. type PingMeasurement struct { // RTT is the app-level RTT in millisecond. - RTT float64 + RTT int64 // ElapsedTime is the elapsed time in microseconds. ElapsedTime int64 diff --git a/ndt7/receiver/receiver.go b/ndt7/receiver/receiver.go index c5fa7518..7c48e3b9 100644 --- a/ndt7/receiver/receiver.go +++ b/ndt7/receiver/receiver.go @@ -27,7 +27,7 @@ func start( data *model.ArchivalData, ) { // TODO(bassosimone): use a uniform definition of "beginning of time" - begin := time.Time() + begin := time.Now() logging.Logger.Debug("receiver: start") proto := ndt7metrics.ConnLabel(conn) defer logging.Logger.Debug("receiver: stop") @@ -46,9 +46,9 @@ func start( if err == nil { rtt /= int64(time.Millisecond) logging.Logger.Debugf("receiver: ApplicationLevel RTT: %d ms", rtt) - data.PingMeasurements = append(data.PingMeasurements, &model.PingMeasurement{ + data.PingMeasurements = append(data.PingMeasurements, model.PingMeasurement{ RTT: rtt, - ElapsedTime: time.Since(begin) / time.Microsecond, + ElapsedTime: int64(time.Since(begin) / time.Microsecond), }) } else { ndt7metrics.ClientReceiverErrors.WithLabelValues(