diff --git a/tools/python/tests/benchmark.py b/tools/python/tests/benchmark.py index ac791f39513418cb7fec480912040c9911f3ff0f..cad3a0b70f0b8fb52f3b06e0c242587e25476854 100644 --- a/tools/python/tests/benchmark.py +++ b/tools/python/tests/benchmark.py @@ -37,7 +37,7 @@ procs = [None for _ in range(clusters)] try: for i in range(clusters): - procs[i] = NSPopen('node'+str(i), ["python3", "dhtnetwork.py", "-n", str(node_per_loc), "-b", bootstrap.ip4+':4000', '-I', args.ifname+str(i)+'.1']) + procs[i] = NSPopen('node'+str(i), ["python3", "dhtnetwork.py", "-n", str(node_per_loc), "-b", bootstrap.ip4, "-b6", bootstrap.ip6, '-I', args.ifname+str(i)+'.1']) plt.pause(2) plt.ion() @@ -86,7 +86,7 @@ try: procs[n].release() except: pass - procs[n] = NSPopen('node'+str(n), ["python3", "dhtnetwork.py", "-n", str(node_per_loc), "-b", bootstrap.ip4+':4000', '-I', args.ifname+str(n)+'.1']) + procs[n] = NSPopen('node'+str(n), ["python3", "dhtnetwork.py", "-n", str(node_per_loc), "-b", bootstrap.ip4, "-b6", bootstrap.ip6, '-I', args.ifname+str(n)+'.1']) plt.pause(5) @@ -98,7 +98,7 @@ try: #nnodes = (n+1)*args.node_num #net.resize(nnodes) #time.sleep(2.5) - #replace_cluster() + replace_cluster() print("Getting 10 random hashes succesively.") for i in range(50): #net.replace_node() diff --git a/tools/python/tests/dhtnetwork.py b/tools/python/tests/dhtnetwork.py index f767a3f0a1ae665458960fb7683a30aad0fcc718..3e07cf373421e00cbfca2b248692ac5bc92e5ffc 100644 --- a/tools/python/tests/dhtnetwork.py +++ b/tools/python/tests/dhtnetwork.py @@ -49,8 +49,6 @@ class DhtNetwork(object): self.ip6 = ip6 if ip6 else ips[1] self.bootstrap = bootstrap #print(self.ip4, self.ip6, self.port) - #self.bootstrap_node = DhtNetwork.run_node(self.ip4, self.ip6, self.port+1, [(self.ip4, str(self.port))])[1] - #self.port += 1 def front(self): if len(self.nodes) == 0: @@ -111,11 +109,16 @@ if __name__ == '__main__': parser.add_argument('-I', '--iface', help='local interface to bind', default='any') parser.add_argument('-p', '--port', help='start of port range (port, port+node_num)', type=int, default=4000) parser.add_argument('-b', '--bootstrap', help='bootstrap address') + parser.add_argument('-b6', '--bootstrap6', help='bootstrap address (IPv6)') args = parser.parse_args() - #ips = find_ip(args.iface) + bs = [] + if args.bootstrap: + bs.append((args.bootstrap, str(4000))) + if args.bootstrap6: + bs.append((args.bootstrap6, str(4000))) - net = DhtNetwork(iface=args.iface, port=args.port, bootstrap=[args.bootstrap.split(':')] if args.bootstrap else []) + net = DhtNetwork(iface=args.iface, port=args.port, bootstrap=bs if args.bootstrap else []) net.resize(args.node_num) with lock: diff --git a/tools/python/tests/dummy_if.py b/tools/python/tests/dummy_if.py index 9c41b9d88600b0e32d13b2ced244b4687b3a2b63..5c718859a9c27117a71415d9fa9f8b971c44a90b 100755 --- a/tools/python/tests/dummy_if.py +++ b/tools/python/tests/dummy_if.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 +import argparse, subprocess + from pyroute2 import IPDB, NetNS from pyroute2.netns.process.proxy import NSPopen -import argparse, subprocess parser = argparse.ArgumentParser(description='Create a dummy network interface for testing') parser.add_argument('-i', '--ifname', help='interface name', default='ethdht') @@ -49,7 +50,8 @@ try: iface = args.ifname+str(ifn) i.add_port(ip.interfaces[iface]) i.add_port(ip.interfaces['tap'+args.ifname]) - i.add_ip('10.0.42.1/24') # the same as i.add_ip('10.0.0.1', 24) + i.add_ip(local_addr4+'1/24') # the same as i.add_ip('10.0.0.1', 24) + i.add_ip(local_addr6+'1/24') i.up() with ip.interfaces['tap'+args.ifname] as tap: @@ -72,7 +74,7 @@ try: lo.up() with ip_ns.interfaces[iface1] as i: i.add_ip(local_addr4+str(ifn+8)+'/24') - #i.add_ip(local_addr6+str(ifn+8)+'/8') + i.add_ip(local_addr6+str(ifn+8)+'/64') i.up() finally: ip_ns.release() @@ -83,6 +85,9 @@ try: nsp.wait() nsp.release() + subprocess.call(["sysctl", "-w", "net.ipv4.conf."+brige_name+".forwarding=1"]) + subprocess.call(["sysctl", "-w", "net.ipv6.conf."+brige_name+".forwarding=1"]) + except Exception as e: print('Error',e) finally: