track rtt

This commit is contained in:
2016-04-23 12:43:49 -04:00
parent 22b6914f7e
commit 49e3e1cb4a
+11 -2
View File
@@ -71,7 +71,7 @@ class Conn:
def sendto(self, msg, ID = 'HTB'): # default ID is HearTBeat def sendto(self, msg, ID = 'HTB'): # default ID is HearTBeat
global warned1 global warned1
msg['name'] = iam msg['name'] = shortname(iam)
msg['id'] = self.conId msg['id'] = self.conId
msg['ver'] = VER msg['ver'] = VER
msg['time'] = time.time() msg['time'] = time.time()
@@ -92,6 +92,9 @@ class Conn:
self.lastack = time.time() self.lastack = time.time()
self.lastacksent = float(msgDict.get('time','0')) self.lastacksent = float(msgDict.get('time','0'))
if verbose: print "ack RTT: %0.1f ms" % ((self.lastack - self.lastacksent) * 1000.0) if verbose: print "ack RTT: %0.1f ms" % ((self.lastack - self.lastacksent) * 1000.0)
self.rtts.append(self.lastack - self.lastacksent) * 1000.0)
if len(self.rtts) > 10:
del self.rtts[0]
self.ackcount += 1 self.ackcount += 1
@@ -101,6 +104,11 @@ class Conn:
self.sock = None self.sock = None
def shortname(name):
r = string.split(name, '.')
return r[0]
def dicttos(ID, d, compress=False): def dicttos(ID, d, compress=False):
s = [] s = []
for k in d: for k in d:
@@ -290,7 +298,8 @@ def process():
if not running: if not running:
break break
for conn in conns: for conn in conns:
msg={'interval': interval, 'acks': conns[conn].ackcount} # msg={'interval': interval, 'acks': conns[conn].ackcount, 'rtt': conns[conn].rtts[-1]}
msg={'acks': conns[conn].ackcount, 'rtt': conns[conn].rtts[-1]}
conns[conn].sendto(msg) conns[conn].sendto(msg)
nextReport += interval nextReport += interval