Take the line rate as a constant so nothing has to be plugged in, and drop the config box
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
@@ -18,12 +17,11 @@ import (
|
||||
const wireOverhead = 24
|
||||
|
||||
type endpoint struct {
|
||||
name string
|
||||
tag string
|
||||
idx int
|
||||
mac [6]byte
|
||||
mtu int
|
||||
speed float64
|
||||
name string
|
||||
tag string
|
||||
idx int
|
||||
mac [6]byte
|
||||
mtu int
|
||||
}
|
||||
|
||||
func (e endpoint) macString() string {
|
||||
@@ -185,14 +183,7 @@ func lookupEndpoint(name string) (endpoint, error) {
|
||||
}
|
||||
var mac [6]byte
|
||||
copy(mac[:], ifi.HardwareAddr)
|
||||
// The rate columns are graded against this, so a guessed speed would silently
|
||||
// grade every reading against the wrong target.
|
||||
v, ok := readUint("/sys/class/net/" + name + "/speed")
|
||||
if !ok || v == 0 {
|
||||
return endpoint{}, fmt.Errorf("%s: cannot read link speed", name)
|
||||
}
|
||||
return endpoint{name: name, idx: ifi.Index, mac: mac, mtu: ifi.MTU,
|
||||
speed: float64(v) / 1000}, nil
|
||||
return endpoint{name: name, idx: ifi.Index, mac: mac, mtu: ifi.MTU}, nil
|
||||
}
|
||||
|
||||
func (d *direction) snapshot() sample {
|
||||
@@ -517,6 +508,10 @@ const (
|
||||
batchSize = 64
|
||||
|
||||
probeEther uint16 = etherBase + numStreams
|
||||
|
||||
// A constant rather than the negotiated speed, since this has to come up
|
||||
// with no cable in the port and nothing to negotiate.
|
||||
linkSpeed = 10.0
|
||||
)
|
||||
|
||||
var frameSizes = []int{64, 128, 256, 512, 1024, 1280, 1514}
|
||||
@@ -617,33 +612,16 @@ func run(aName, bName string, nsPerM float64) error {
|
||||
for _, e := range []endpoint{a, b} {
|
||||
linkRows = append(linkRows, []string{
|
||||
paint(e.tag, cCyan), e.name, e.macString(),
|
||||
fmt.Sprintf("%.0f Gb/s", e.speed), fmt.Sprintf("%d", e.mtu),
|
||||
fmt.Sprintf("%.0f Gb/s", linkSpeed), fmt.Sprintf("%d", e.mtu),
|
||||
})
|
||||
}
|
||||
fmt.Println(renderBox("LINKS",
|
||||
[]string{"TAG", "INTERFACE", "MAC", "SPEED", "MTU"},
|
||||
[]bool{false, false, false, true, true}, linkRows))
|
||||
fmt.Println()
|
||||
|
||||
// One row carries both directions, so line rate is both links at once.
|
||||
target := a.speed * float64(len(dirs))
|
||||
sizeStrs := make([]string, len(frameSizes))
|
||||
for i, s := range frameSizes {
|
||||
sizeStrs[i] = fmt.Sprintf("%d", s)
|
||||
}
|
||||
fmt.Println(renderBox("CONFIG",
|
||||
[]string{"SETTING", "VALUE"},
|
||||
[]bool{false, false}, [][]string{
|
||||
{"frame sizes", strings.Join(sizeStrs, " ")},
|
||||
{"streams", fmt.Sprintf("%d per direction, ethertypes 0x%04x-0x%04x",
|
||||
numStreams, ethertypes[0], ethertypes[len(ethertypes)-1])},
|
||||
{"probe", fmt.Sprintf("ethertype 0x%04x every %s", probeEther, probeInterval)},
|
||||
{"batch", fmt.Sprintf("%d frames per syscall", batchSize)},
|
||||
{"calibration", fmt.Sprintf("%g ns/m, zero taken from the shortest delay seen so far", nsPerM)},
|
||||
{"buffers", fmt.Sprintf("sndbuf %sB, rcvbuf %sB",
|
||||
scaleCount(uint64(sockBufSize(dirs[0].txFDs[0], unix.SO_SNDBUF))),
|
||||
scaleCount(uint64(sockBufSize(dirs[0].rxFDs[0], unix.SO_RCVBUF))))},
|
||||
}))
|
||||
fmt.Println()
|
||||
target := linkSpeed * float64(len(dirs))
|
||||
|
||||
var doneTx, doneRx atomic.Bool
|
||||
var wg sync.WaitGroup
|
||||
|
||||
Reference in New Issue
Block a user