control: add measure_peer_response_time(), to estimate RTT for the mesh

This commit is contained in:
Brian Warner 2007-09-26 12:21:15 -07:00
parent c10da1e1ef
commit c301b41f50
3 changed files with 29 additions and 0 deletions

View File

@ -56,6 +56,24 @@ class ControlServer(Referenceable, service.Service, testutil.PollMixin):
def remote_get_memory_usage(self):
return get_memory_usage()
def remote_measure_peer_response_time(self):
results = {}
everyone = list(self.parent.introducer_client.get_all_peers())
d = self._do_one_ping(None, everyone, results)
return d
def _do_one_ping(self, res, everyone_left, results):
if not everyone_left:
return results
peerid, connection = everyone_left.pop(0)
start = time.time()
d = connection.callRemote("get_nodeid")
def _done(ignored):
stop = time.time()
results[peerid] = stop - start
d.addCallback(_done)
d.addCallback(self._do_one_ping, everyone_left, results)
return d
class SpeedTest:
def __init__(self, parent, count, size):
self.parent = parent

View File

@ -1062,3 +1062,13 @@ class RIControlClient(RemoteInterface):
Returns a tuple of (upload_time, download_time).
"""
return (float, float)
def measure_peer_response_time():
"""Send a short message to each connected peer, and measure the time
it takes for them to respond to it. This is a rough measure of the
application-level round trip time.
@return: a dictionary mapping peerid to a float (RTT time in seconds)
"""
return DictOf(Nodeid, float)

View File

@ -687,5 +687,6 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase):
d.addCallback(lambda res: rref.callRemote("speed_test", 1, 200))
if sys.platform == "linux2":
d.addCallback(lambda res: rref.callRemote("get_memory_usage"))
d.addCallback(lambda res: rref.callRemote("measure_peer_response_time"))
return d