Skip to content

Commit

Permalink
Adding additional metric for UDP Protocol
Browse files Browse the repository at this point in the history
a) Loss of packet in percentage added
b) Percentile calculation corrected
  • Loading branch information
Hanamantagoud committed Jul 5, 2021
1 parent fc14f0c commit dac7002
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@ func (npm *networkPerformanceMeasurement) calculateMetricDataValue(dataElem *mea
case manyToMany:
for _, metricResponse = range npm.metricVal {
if len(metricResponse) > 0 {
// Sometimes iperf gives negative values for latency. As short-term fix
// we are considering them as zero.
if metricIndex == udpLatencyAverage && metricResponse[metricIndex] < 0 {
aggregatePodPairMetrics = append(aggregatePodPairMetrics, 0)
continue
}
aggregatePodPairMetrics = append(aggregatePodPairMetrics, metricResponse[metricIndex])
}
}
Expand All @@ -379,6 +385,7 @@ func (npm *networkPerformanceMeasurement) createResultSummary() testResultSummar
npm.getMetricData(&resultSummary, udpPacketPerSecond, packetPerSecond)
npm.getMetricData(&resultSummary, udpJitter, jitter)
npm.getMetricData(&resultSummary, udpLatencyAverage, latency)
npm.getMetricData(&resultSummary, udpLostPacketsPercentage, lostPackets)
resultSummary.protocol = protocolUDP
case protocolHTTP:
npm.getMetricData(&resultSummary, httpResponseTime, responseTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"math"
"sort"

"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
Expand Down Expand Up @@ -111,6 +112,7 @@ func getPercentile(values float64Slice) metricPercentiles {
if length == 0 {
return metricPercentiles{0, 0, 0}
}
sort.Float64s(values)
perc05 := values[int(math.Ceil(float64(length*05)/100))-1]
perc50 := values[int(math.Ceil(float64(length*50)/100))-1]
perc95 := values[int(math.Ceil(float64(length*95)/100))-1]
Expand Down
9 changes: 6 additions & 3 deletions clusterloader2/pkg/measurement/common/network/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ const (
// UDP result array Index mapping
// Other unused metrics are not included
const (
udpJitter = 2
udpLatencyAverage = 6
udpPacketPerSecond = 10
udpJitter = 2
udpLostPacketsPercentage = 5
udpLatencyAverage = 6
udpPacketPerSecond = 10
)

// HTTP result array Index mapping
Expand Down Expand Up @@ -65,6 +66,7 @@ const (
throughput = "Throughput"
latency = "Latency"
jitter = "Jitter"
lostPackets = "Lost_Packets"
packetPerSecond = "Packet_Per_Second"
responseTime = "Response_Time"
)
Expand All @@ -73,6 +75,7 @@ var metricUnitMap = map[string]string{
throughput: "kbytes/sec",
latency: "ms",
jitter: "ms",
lostPackets: "percentage",
packetPerSecond: "pps",
responseTime: "seconds",
}
Expand Down

0 comments on commit dac7002

Please sign in to comment.