Permalink
Browse files

Return to old-style speedtest

The reason for this back out is that the new-style speedtest does
not account for the time required to empty the pipe between the client
and the server.  When this time is high, the transmission test spans
much more seconds that expected.  In other words, easier to control the
duration of the test using the size rather than the application-level
duration.

The algorithm to control the transmission time is the following:

1. we start with a small value for the number of bytes to transmit;

2. we monitor the elapsed time since the beginning of transmission;

3. we continuously adjust the number of bytes to transmit;

4. the adjustment factor is TARGET/elapsed, where TARGET is the time
   we would like the transmission to take;

5. when elapsed is less than LO_THRESH, we adjust the number of bytes
   and then we repeat the transmission;

6. when elapsed is less than LO_THRESH/3, we adjust the number of bytes
   using a factor of 2 and then we repeat the transmission.

The rationale for 5. is that we don't want to save the result of a
transmission.  The rationale for 6. is that we cannot trust the outcome
of a very short transmission to calibrate the number of bytes.
  • Loading branch information...
bassosimone committed May 1, 2011
1 parent 3877704 commit 1eb7f19fbb46666ff1f04c7e2cd28e8bc9701d6b
Showing with 387 additions and 423 deletions.
  1. +19 −0 neubot/arcfour.py
  2. +5 −8 neubot/database/table_speedtest.py
  3. +7 −415 neubot/speedtest/__init__.py
  4. +356 −0 neubot/speedtest/client.py
View
@@ -55,6 +55,25 @@ def arcfour_new(key=None):
key = "neubot"
return ARCFOUR(key)
+class RandomBody(object):
+ def __init__(self, total):
+ self.total = int(total)
+ self.encoder = arcfour_new(str(ticks()))
+
+ def read(self, n):
+ if self.total:
+ amt = min(n, self.total)
+ data = self.encoder.encrypt("A" * amt)
+ self.total -= amt
+ else:
+ data = ""
+ return data
+
+ def seek(self, offset=0, whence=0):
+ pass
+
+ def tell(self):
+ return self.total
class RandomData(object):
@@ -33,25 +33,22 @@
#
# FIXME The following function glues the speedtest code and
# the database code. The speedtest code passes downstream a
-# an object with at least two problems:
+# an object with the following problems:
#
# 1. the timestamp _might_ be a floating because old
# neubot clients have this bug;
#
-# 2. some fields are vectors instead of scalars and this
-# is very clumsy as well.
-#
def obj_to_dict(obj):
dictionary = {
"uuid": obj.client,
"timestamp": int(float(obj.timestamp)), #XXX
"internal_address": obj.internalAddress,
"real_address": obj.realAddress,
"remote_address": obj.remoteAddress,
- "connect_time": obj.connectTime[0],
- "latency": obj.latency[0],
- "download_speed": obj.downloadSpeed[0],
- "upload_speed": obj.uploadSpeed[0],
+ "connect_time": obj.connectTime,
+ "latency": obj.latency,
+ "download_speed": obj.downloadSpeed,
+ "upload_speed": obj.uploadSpeed,
"privacy_informed": obj.privacy_informed,
"privacy_can_collect": obj.privacy_can_collect,
"privacy_can_share": obj.privacy_can_share,
Oops, something went wrong.

0 comments on commit 1eb7f19

Please sign in to comment.