Skip to content
Snippets Groups Projects
Commit 925be39a authored by Adrien Béraud's avatar Adrien Béraud
Browse files

python benchmark: add ipv6, ip forwarding

parent a10ba600
Branches
Tags
No related merge requests found
...@@ -37,7 +37,7 @@ procs = [None for _ in range(clusters)] ...@@ -37,7 +37,7 @@ procs = [None for _ in range(clusters)]
try: try:
for i in range(clusters): 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.pause(2)
plt.ion() plt.ion()
...@@ -86,7 +86,7 @@ try: ...@@ -86,7 +86,7 @@ try:
procs[n].release() procs[n].release()
except: except:
pass 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) plt.pause(5)
...@@ -98,7 +98,7 @@ try: ...@@ -98,7 +98,7 @@ try:
#nnodes = (n+1)*args.node_num #nnodes = (n+1)*args.node_num
#net.resize(nnodes) #net.resize(nnodes)
#time.sleep(2.5) #time.sleep(2.5)
#replace_cluster() replace_cluster()
print("Getting 10 random hashes succesively.") print("Getting 10 random hashes succesively.")
for i in range(50): for i in range(50):
#net.replace_node() #net.replace_node()
......
...@@ -49,8 +49,6 @@ class DhtNetwork(object): ...@@ -49,8 +49,6 @@ class DhtNetwork(object):
self.ip6 = ip6 if ip6 else ips[1] self.ip6 = ip6 if ip6 else ips[1]
self.bootstrap = bootstrap self.bootstrap = bootstrap
#print(self.ip4, self.ip6, self.port) #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): def front(self):
if len(self.nodes) == 0: if len(self.nodes) == 0:
...@@ -111,11 +109,16 @@ if __name__ == '__main__': ...@@ -111,11 +109,16 @@ if __name__ == '__main__':
parser.add_argument('-I', '--iface', help='local interface to bind', default='any') 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('-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('-b', '--bootstrap', help='bootstrap address')
parser.add_argument('-b6', '--bootstrap6', help='bootstrap address (IPv6)')
args = parser.parse_args() 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) net.resize(args.node_num)
with lock: with lock:
......
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse, subprocess
from pyroute2 import IPDB, NetNS from pyroute2 import IPDB, NetNS
from pyroute2.netns.process.proxy import NSPopen from pyroute2.netns.process.proxy import NSPopen
import argparse, subprocess
parser = argparse.ArgumentParser(description='Create a dummy network interface for testing') parser = argparse.ArgumentParser(description='Create a dummy network interface for testing')
parser.add_argument('-i', '--ifname', help='interface name', default='ethdht') parser.add_argument('-i', '--ifname', help='interface name', default='ethdht')
...@@ -49,7 +50,8 @@ try: ...@@ -49,7 +50,8 @@ try:
iface = args.ifname+str(ifn) iface = args.ifname+str(ifn)
i.add_port(ip.interfaces[iface]) i.add_port(ip.interfaces[iface])
i.add_port(ip.interfaces['tap'+args.ifname]) 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() i.up()
with ip.interfaces['tap'+args.ifname] as tap: with ip.interfaces['tap'+args.ifname] as tap:
...@@ -72,7 +74,7 @@ try: ...@@ -72,7 +74,7 @@ try:
lo.up() lo.up()
with ip_ns.interfaces[iface1] as i: with ip_ns.interfaces[iface1] as i:
i.add_ip(local_addr4+str(ifn+8)+'/24') 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() i.up()
finally: finally:
ip_ns.release() ip_ns.release()
...@@ -83,6 +85,9 @@ try: ...@@ -83,6 +85,9 @@ try:
nsp.wait() nsp.wait()
nsp.release() 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: except Exception as e:
print('Error',e) print('Error',e)
finally: finally:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment