[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] Implement TCP and UDP multi port traceroute test
commit 665267dc7f431f28e8f1017e9ebdce4740f92d1d
Author: Arturo Filastò <art@xxxxxxxxx>
Date: Sat Nov 10 18:00:03 2012 +0100
Implement TCP and UDP multi port traceroute test
---
nettests/core/traceroute.py | 19 +++++++++----------
ooni/templates/scapyt.py | 2 +-
2 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/nettests/core/traceroute.py b/nettests/core/traceroute.py
index d29a0fd..b14e013 100644
--- a/nettests/core/traceroute.py
+++ b/nettests/core/traceroute.py
@@ -4,6 +4,7 @@
# :licence: see LICENSE
from twisted.python import usage
+from twisted.internet import defer
from ooni.utils import log
from ooni.templates import scapyt
@@ -12,7 +13,8 @@ from scapy.all import *
class UsageOptions(usage.Options):
optParameters = [
- ['backend', 'b', '8.8.8.8', 'Test backend to use']
+ ['backend', 'b', '8.8.8.8', 'Test backend to use'],
+ ['timeout', 't', 5, 'The timeout for the traceroute test']
]
class TracerouteTest(scapyt.BaseScapyTest):
@@ -26,26 +28,25 @@ class TracerouteTest(scapyt.BaseScapyTest):
def test_tcp_traceroute(self):
def finished(packets, port):
- log.debug("Finished tcp")
+ log.debug("Finished tcp %s" % port)
answered, unanswered = packets
self.report['hops_'+str(port)] = []
for snd, rcv in answered:
report = {'ttl': snd.ttl, 'address': rcv.src}
log.debug("Writing %s" % report)
self.report['hops_'+str(port)].append(report)
- return
dl = []
for port in self.dst_ports:
packets = IP(dst=self.localOptions['backend'],
- ttl=(4,25),id=RandShort())/TCP(flags=0x2, dport=port)
- d = self.sr(packets, timeout=2)
+ ttl=(1,25),id=RandShort())/TCP(flags=0x2, dport=port)
+ d = self.sr(packets, timeout=5)
d.addCallback(finished, port)
dl.append(d)
return defer.DeferredList(dl)
def test_udp_traceroute(self):
- def finished(packets):
+ def finished(packets, port):
log.debug("Finished udp")
answered, unanswered = packets
self.report['hops_'+str(port)].append(report)
@@ -53,13 +54,11 @@ class TracerouteTest(scapyt.BaseScapyTest):
report = {'ttl': snd.ttl, 'address': rcv.src}
log.debug("Writing %s" % report)
self.report['hops_'+str(port)].append(report)
- return
-
dl = []
for port in self.dst_ports:
packets = IP(dst=self.localOptions['backend'],
- ttl=(4,25),id=RandShort())/UDP(dport=port)
- d = self.sr(packets, timeout=2)
+ ttl=(1,25),id=RandShort())/UDP(dport=port)
+ d = self.sr(packets, timeout=5)
d.addCallback(finished, port)
dl.append(d)
return defer.DeferredList(dl)
diff --git a/ooni/templates/scapyt.py b/ooni/templates/scapyt.py
index 3087ac7..c443610 100644
--- a/ooni/templates/scapyt.py
+++ b/ooni/templates/scapyt.py
@@ -53,7 +53,7 @@ class BaseScapyTest(NetTestCase):
self.report['answered_packets'] = []
self.report['sent_packets'] = []
for snd, rcv in answered:
- log.debug("Writing report %s")
+ log.debug("Writing report %s" % snd)
pkt_report_r = createPacketReport(rcv)
pkt_report_s = createPacketReport(snd)
self.report['answered_packets'].append(pkt_report_r)
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits