mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 12:28:42 +00:00
python benchmark: add ipv6, ip forwarding
This commit is contained in:
1 parent
a10ba60086
commit
925be39aa1
3 files changed
+18
-10
No files matched your search
@@ -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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user