diff --git a/pkt7.go b/pkt7.go index 7699b8a..e4788f3 100644 --- a/pkt7.go +++ b/pkt7.go @@ -8,6 +8,9 @@ import ( "time" ) +// This is sent every 100ms by the server, but as this seems to be only a ping-line packet, +// it is also fine to send it in a longer interval. +const pkt7SendInterval = 3 * time.Second const pkt7TimeoutDuration = 3 * time.Second type pkt7Type struct { @@ -145,7 +148,7 @@ func (p *pkt7Type) startPeriodicSend(s *streamCommon, firstSeqNo uint16, checkPi p.innerSendSeq = 0x8304 // p.lastConfirmedSeq = p.sendSeq - 1 - p.sendTicker = time.NewTicker(100 * time.Millisecond) + p.sendTicker = time.NewTicker(pkt7SendInterval) if checkPingTimeout { p.timeoutTimer = time.NewTimer(pkt7TimeoutDuration) } diff --git a/statuslog.go b/statuslog.go index 480ae79..73057b1 100644 --- a/statuslog.go +++ b/statuslog.go @@ -19,8 +19,8 @@ type statusLogData struct { mode string filter string - startTime time.Time - rttLatency time.Duration + startTime time.Time + rttStr string } type statusLogStruct struct { @@ -53,7 +53,7 @@ func (s *statusLogStruct) reportRTTLatency(l time.Duration) { if s.data == nil { return } - s.data.rttLatency = l + s.data.rttStr = fmt.Sprint(l.Milliseconds()) } func (s *statusLogStruct) reportFrequency(f float64) { @@ -144,7 +144,7 @@ func (s *statusLogStruct) update() { } s.data.line2 = fmt.Sprint("up ", time.Since(s.data.startTime).Round(time.Second), - " rtt ", s.data.rttLatency.Milliseconds(), "ms up ", + " rtt ", s.data.rttStr, "ms up ", netstat.formatByteCount(up), "/s down ", netstat.formatByteCount(down), "/s retx ", retransmitsStr, "/1m lost ", lostStr, "/1m\r") @@ -195,6 +195,7 @@ func (s *statusLogStruct) startPeriodicPrint() { s.data = &statusLogData{ stateStr: s.preGenerated.stateStr.unknown, startTime: time.Now(), + rttStr: "?", } s.stopChan = make(chan bool)