Output UDT metrics in the "probe file transfer" command

This commit is contained in:
Kleissner
2022-03-14 06:18:32 +01:00
parent 4c3ad74611
commit 4b19419626
3 changed files with 24 additions and 5 deletions

View File

@@ -137,10 +137,11 @@ func transferCompareFile(peer *core.PeerInfo, fileHash []byte, output io.Writer)
if totalRead != int(fileSizeLocal) { if totalRead != int(fileSizeLocal) {
fmt.Fprintf(output, "Error transferred data %d mismatch with reported file size %d\n", totalRead, fileSize) fmt.Fprintf(output, "Error transferred data %d mismatch with reported file size %d\n", totalRead, fileSize)
return } else {
fmt.Fprintf(output, "Finished reading total of %d bytes. Expected %d bytes.\n", totalRead, fileSize)
} }
fmt.Fprintf(output, "Finished reading total of %d bytes. Expected %d bytes.\n", totalRead, fileSize) outputUDTMetrics(udtConn.Metrics, output)
} }
func translateTerminateReason(reason int) string { func translateTerminateReason(reason int) string {
@@ -177,6 +178,24 @@ func translateTerminateReason(reason int) string {
} }
} }
func outputUDTMetrics(metrics *udt.Metrics, output io.Writer) {
fmt.Fprintf(output, "---- UDT Metrics ----\nPacket Type Sent Received\n")
fmt.Fprintf(output, "HandShake %-8d %-8d\n", metrics.PktSendHandShake, metrics.PktRecvHandShake)
fmt.Fprintf(output, "ACK %-8d %-8d\n", metrics.PktSentACK, metrics.PktRecvACK)
fmt.Fprintf(output, "NAK %-8d %-8d\n", metrics.PktSentNAK, metrics.PktRecvNAK)
fmt.Fprintf(output, "Shutdown %-8d %-8d\n", metrics.PktSentShutdown, metrics.PktRecvShutdown)
fmt.Fprintf(output, "ACK2 %-8d %-8d\n", metrics.PktSentACK2, metrics.PktRecvACK2)
fmt.Fprintf(output, "Data %-8d %-8d\n", metrics.PktSentData, metrics.PktRecvData)
// No need to output stats on packets that are not used in the current implementation.
//fmt.Fprintf(output, "keep-alive %-8d %-8d\n", metrics.PktSendKeepAlive, metrics.PktRecvKeepAlive)
//fmt.Fprintf(output, "Msg-drop %-8d %-8d\n", metrics.PktSendMessageDrop, metrics.PktRecvMessageDrop)
//fmt.Fprintf(output, "Congestion %-8d %-8d\n", metrics.PktSentCongestion, metrics.PktRecvCongestion)
//fmt.Fprintf(output, "Error %-8d %-8d\n", metrics.PktSendError, metrics.PktRecvError)
//fmt.Fprintf(output, "User-defined %-8d %-8d\n", metrics.PktSendUserDefined, metrics.PktRecvUserDefined)
//fmt.Fprintf(output, "Other %-8d %-8d\n", metrics.PktSentOther, metrics.PktRecvOther)
}
/* /*
// downloadFile downloads the file from the target peer // downloadFile downloads the file from the target peer
func downloadFile(output io.Writer, publicKey *btcec.PublicKey, hash []byte) (data []byte, err error) { func downloadFile(output io.Writer, publicKey *btcec.PublicKey, hash []byte) (data []byte, err error) {

2
go.mod
View File

@@ -3,7 +3,7 @@ module github.com/PeernetOfficial/Cmd
go 1.16 go 1.16
require ( require (
github.com/PeernetOfficial/core v0.0.0-20220227031159-c9158cb15f87 github.com/PeernetOfficial/core v0.0.0-20220314051352-e2cda5b5657a
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
github.com/gorilla/websocket v1.5.0 github.com/gorilla/websocket v1.5.0
) )

4
go.sum
View File

@@ -1,7 +1,7 @@
github.com/IncSW/geoip2 v0.1.2 h1:v7iAyDiNZjHES45P1JPM3SMvkw0VNeJtz0XSVxkRwOY= github.com/IncSW/geoip2 v0.1.2 h1:v7iAyDiNZjHES45P1JPM3SMvkw0VNeJtz0XSVxkRwOY=
github.com/IncSW/geoip2 v0.1.2/go.mod h1:adcasR40vXiUBjtzdaTTKL/6wSf+fgO4M8Gve/XzPUk= github.com/IncSW/geoip2 v0.1.2/go.mod h1:adcasR40vXiUBjtzdaTTKL/6wSf+fgO4M8Gve/XzPUk=
github.com/PeernetOfficial/core v0.0.0-20220227031159-c9158cb15f87 h1:OKU1DFERIeDiygO13HOpjZ/CKQ/sGYuhkdnValoChk8= github.com/PeernetOfficial/core v0.0.0-20220314051352-e2cda5b5657a h1:pNB2sUXEKt9+kTNB/CWYeDhFXMdKzs2XCz9dn8Cugbg=
github.com/PeernetOfficial/core v0.0.0-20220227031159-c9158cb15f87/go.mod h1:nP1xfYJ0CTSlLp6GfMOMxPnw7NmzwoGeZiFQ4kfhd0o= github.com/PeernetOfficial/core v0.0.0-20220314051352-e2cda5b5657a/go.mod h1:nP1xfYJ0CTSlLp6GfMOMxPnw7NmzwoGeZiFQ4kfhd0o=
github.com/akrylysov/pogreb v0.10.1 h1:FqlR8VR7uCbJdfUob916tPM+idpKgeESDXOA1K0DK4w= github.com/akrylysov/pogreb v0.10.1 h1:FqlR8VR7uCbJdfUob916tPM+idpKgeESDXOA1K0DK4w=
github.com/akrylysov/pogreb v0.10.1/go.mod h1:pNs6QmpQ1UlTJKDezuRWmaqkgUE2TuU0YTWyqJZ7+lI= github.com/akrylysov/pogreb v0.10.1/go.mod h1:pNs6QmpQ1UlTJKDezuRWmaqkgUE2TuU0YTWyqJZ7+lI=
github.com/enfipy/locker v1.1.0 h1:2zVJ0ky7cS1Vjs0x6OQWFiT2dSEiHrI5/O2KCz1fgGc= github.com/enfipy/locker v1.1.0 h1:2zVJ0ky7cS1Vjs0x6OQWFiT2dSEiHrI5/O2KCz1fgGc=