Skip to content

Commit

Permalink
remove obsolete main code
Browse files Browse the repository at this point in the history
  • Loading branch information
gubser committed May 27, 2015
1 parent 17a697d commit aedfb44
Showing 1 changed file with 0 additions and 85 deletions.
85 changes: 0 additions & 85 deletions ecnspider2/ecnspider.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,88 +315,3 @@ def config_one(self):
subprocess.check_call(['sudo', '-n', '/usr/sbin/sysctl', '-w', 'net.inet.tcp.ecn_initiate_out=1'],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

def main():
qofspider.log_to_console(logging.DEBUG)
ipfix.ie.use_iana_default()
ipfix.ie.use_5103_default()
ipfix.ie.use_specfile("qof.iespec")

dht = torrent.BtDhtSpider()

results = []

ecn = EcnSpider2(result_sink=results.append,
worker_count=50, conn_timeout=5,
interface_uri='int:wlan0',
qof_port=54739)

ecn.run()

ips = set()
count = 0
for addr in dht:
if addr[0] not in ips:
ips.add(addr[0])
if count > 100:
break
ecn.add_job(Job(ip_address(addr[0]), addr[0], addr[1]))
count += 1

ecn.stop() # note that stop will wait for every queue to empty
# perhaps it should be call "finish"

success_both = 0
success_on_only = 0
success_off_only = 0
success_none = 0
total = 0

keyfunc = lambda x: str(x.ip)
result_by_ip = itertools.groupby(sorted(results, key=keyfunc), key=keyfunc)

for key, endpoint in result_by_ip:
endpoint = list(endpoint)
if len(endpoint) != 2:
try:
print("Wrong number of entries per ip", str(endpoint[0].ip), endpoint)
except:
pass
continue

ecn_on_success = None
ecn_off_success = None
for test in endpoint:
if test.ecnstate == 0:
ecn_off_success = test.connstate
elif test.ecnstate == 1:
ecn_on_success = test.connstate
else:
print("Wrong ecnstate", test)

if ecn_on_success and ecn_off_success:
success_both += 1
elif ecn_on_success and not ecn_off_success:
success_on_only += 1
elif not ecn_on_success and ecn_off_success:
success_off_only += 1
else:
success_none += 1

total += 1

print(total)
print("both: {} ({:0.0%}), on_only: {} ({:0.0%}), off_only: {} ({:0.0%}), none: {} ({:0.0%})".format(
success_both, success_both / total,
success_on_only, success_on_only / total,
success_off_only, success_off_only / total,
success_none, success_none / total
))

def log_to_console(verbosity):
handler = qofspider.log_to_console(verbosity)
logging.getLogger('ecnspider').addHandler(handler)
logging.getLogger('torrent-dht').addHandler(handler)
return handler

if __name__ == "__main__":
main()

0 comments on commit aedfb44

Please sign in to comment.