def main(): net = Network('15.0.0.0/8') # create network nodes that will represent client and server server = net.create_node('server', image='madt/docker_compose', enable_internet=True, privileged=True) clients = net.generate_nodes('client', 6, image='madt/pyget', environment={"SERVER": 'whoami.local'}) with open('docker-compose.yml') as docker_compose_yml_file: server.add_dir('.', '/app') # create a local network that will connect all those nodes routers = net.generate_nodes('router', 3) net.create_subnet('subnet1', (routers[0], *clients[:3])) net.create_subnet('subnet2', (routers[1], *clients[3:])) net.create_subnet('subnet3', routers) net.create_subnet('subnet4', (routers[2], server)) net.create_overlay(Overlay.RIP, 'RIP', routers) # distribute IP addresses net.configure(verbose=True) # pass server IP to the clients for client in clients: client.add_options(extra_hosts={'whoami.local': server.get_ip()}) # save lab net.render('../../labs/compose', verbose=True)
def main(): net = Network('15.0.0.0/8') node1 = net.create_node('Node0', image='lab/mit', entrypoint="sleep infinity", ports={ '8008/tcp': 8008, '9080/tcp': 9080 }, enable_internet=True, privileged=True) node2 = net.create_node('Node1', image='lab/mit', entrypoint="sleep infinity", ports={'8009/tcp': 8009}, enable_internet=True, privileged=True) node3 = net.create_node('Node2', image='lab/mit', entrypoint="sleep infinity", ports={'8010/tcp': 8010}, enable_internet=True, privileged=True) net.create_subnet('net', (node1, node2, node3)) net.configure(verbose=True) net.render('../../labs/kind', verbose=True)
def main(): parser = ArgumentParser() parser.add_argument("lab_path", type=str, help='path to the lab directory') args = parser.parse_args() main_net = Network('15.0.0.0/8') size = 3 core = main_net.generate_nodes('core_', size) nodes = main_net.generate_nodes('n', size * 2, image='kademlia') main_net.create_subnet('core_net', core) for i in range(len(core)): main_net.create_subnet('radial_' + str(i), (core[i], nodes[2 * i], nodes[2 * i + 1])) main_net.create_overlay(Overlay.RIP, 'RIP_1', core) main_net.configure(verbose=True) for node in nodes[1:]: node.add_options(environment={'KADEMLIA_ARGS': nodes[0].get_ip()}) main_net.render(args.lab_path, verbose=True)
def main(): parser = ArgumentParser() parser.add_argument("lab_path", type=str, help='path to the lab directory') args = parser.parse_args() main_net = Network('15.0.0.0/8') core = main_net.generate_nodes('core_', 3) routers = main_net.generate_nodes('r', 2) ospf_routers = main_net.generate_nodes('ospfr', 2) nodes = main_net.generate_nodes('n', 11, image='kademlia') gateway = main_net.create_node('gateway') main_net.make_mesh(core) # WAS IT DEPRECATED? # make subnets connecting each pair of nodes main_net.make_mesh((core[0], *routers)) # WAS IT DEPRECATED? main_net.create_subnet('ospf_1', (ospf_routers[0], core[2])) main_net.create_subnet('ospf_2', (ospf_routers[1], core[2])) main_net.create_subnet('lc1', (*nodes[:2], routers[0])) main_net.create_subnet('lc2', (*nodes[2:4], routers[1], gateway)) main_net.create_subnet('lc3', (*nodes[4:7], core[1])) main_net.create_subnet('lc4', (*nodes[7:9], ospf_routers[0])) main_net.create_subnet('lc5', (*nodes[9:], ospf_routers[1])) main_net.create_overlay(Overlay.RIP, 'RIP_1', (core[0], *routers)) main_net.create_overlay(Overlay.OSPF, 'OSPF_1', (core[2], *ospf_routers)) main_net.create_overlay( Overlay.BGP, 'big_boi', [[*nodes[:4], *routers, gateway, core[0]], [*nodes[4:7], core[1]], [*nodes[7:], *ospf_routers, core[2]]]) local_net = main_net.create_local_network(gateway) local_routers = local_net.generate_nodes('lan_router', 2) local_net.create_subnet('LAN0', (*local_routers, gateway)) for idx, r in enumerate(local_routers): node = local_net.create_node('lan_node' + str(idx + 1), image='kademlia') local_net.create_subnet('LAN' + str(idx + 1), (node, r)) nodes.append(node) local_net.create_overlay(Overlay.RIP, 'RIP_1', local_routers) main_net.configure(verbose=True) for node in nodes[1:]: node.add_options(environment={'KADEMLIA_ARGS': nodes[0].get_ip()}) main_net.render(args.lab_path, verbose=True)
def main(): madt = Network('15.0.0.0/8') # create 20 nodes with names sensor_1, sensor_2 etc. nodes = madt.generate_nodes('sensor_', 20, image='madt/kademlia') # create a local network that will connect all those nodes madt.create_subnet('net', nodes) # distribute IP addresses madt.configure(verbose=True) for n in nodes[1:]: # pass initial connection arguments to kademlia n.add_options(environment={'KADEMLIA_ARGS': nodes[0].get_ip()}) # save lab madt.render('../../labs/kademlia', verbose=True)
def main(): parser = ArgumentParser() parser.add_argument("lab_path", type=str, help='path to the lab directory') args = parser.parse_args() global subnets # Define network net = Network('15.0.0.0/8') # Create initial outer nodes and a subnet outer_nodes = [ *net.generate_nodes('core_', children), ] net.create_subnet('core', outer_nodes) # Iteratively create other nodes for i in range(iterations): new_outer_nodes = [] for node in outer_nodes: idx = outer_nodes.index(node) + 1 new_nodes = net.generate_nodes('L{0}_N{1}_'.format(i, idx), children) net.create_subnet('L{0}_D{1}'.format(i, idx), (node, *new_nodes)) subnets += 1 new_outer_nodes.extend(new_nodes) central_nodes.extend(outer_nodes) outer_nodes = new_outer_nodes # OSPF - Open Shortest Path First net.create_overlay(Overlay.OSPF, 'OSPF', central_nodes) # Setup the node docker image for node in outer_nodes: node.image = 'kademlia' net.configure(verbose=True) for node in outer_nodes[1:]: node.add_options( environment={'KADEMLIA_ARGS': outer_nodes[0].get_ip()}) net.render(args.lab_path, verbose=True) print('NET SIZE: ', len(central_nodes) + len(outer_nodes)) print('SUBNETS: ', subnets)
def main(): net = Network('16.0.0.0/8') node_count = 3 eths = [] for i in range(node_count): num = str(i+2) #create docker image for i-node eth = net.create_node('eth'+num, image='eth', entrypoint='sh -c "distr/setup_account.sh ' + num + '"') eths.append(eth) #create subnet net.create_subnet('net', eths) # distribute IP addresses net.configure(verbose=True) # save lab net.render('../../labs/eth', verbose=True)
def main(): parser = ArgumentParser() parser.add_argument("lab_path", type=str, help='path to the lab directory') args = parser.parse_args() net = Network('15.0.0.0/8') nodes = net.generate_nodes('n', 3, image='kademlia') net.create_subnet('net', nodes) net.configure(verbose=True) for node in nodes[1:]: node.add_options(environment={'KADEMLIA_ARGS': nodes[0].get_ip()}) net.render(args.lab_path, verbose=True)
def main(): net = Network('15.0.0.0/8') # create a local network that will connect all those nodes server = net.create_node('server', image='roastario/notary-and-network-map:4.0',entrypoint='sh -c "/start.sh && while true; do sleep 1000; done"',ports={'10200/tcp': 10200, '8080/tcp': 8080}, privileged=True) client1 = net.create_node('client1', image='party-a', entrypoint='sh -c "/run-corda.sh && while true; do sleep 1000; done"',ports={'2222/tcp': 2221}, privileged=True) client2 = net.create_node('client2', image='party-b', entrypoint='sh -c "/run-corda.sh && while true; do sleep 1000; done"',ports={'2222/tcp': 2222}, privileged=True) client3 = net.create_node('client3', image='party-c', entrypoint='sh -c "/run-corda.sh && while true; do sleep 1000; done"',ports={'2222/tcp': 2223}, privileged=True) net.create_subnet('net_corda54675', (server, client1, client2, client3)) net.configure(verbose=True) server.add_options(environment=['PUBLIC_ADDRESS=notary-and-network-map', 'MY_PUBLIC_ADDRESS=notary-and-network-map']) # save lab net.render('../madt/labs/corda-yo', verbose=True)
def main(): net = Network('15.0.0.0/8') # create network nodes that will represent client and server server = net.create_node('server', image='madt/nginx') client = net.create_node( 'client', image='inutano/wget', entrypoint= 'sh -c "while true; do wget -O - -T 3 $SERVER; sleep 1; done"') # create a local network that will connect all those nodes net.create_subnet('net', (server, client)) # distribute IP addresses net.configure(verbose=True) # pass server IP to the client client.add_options(environment={'SERVER': server.get_ip()}) # save lab net.render('../../labs/basic_tutorial', verbose=True)
def main(): parser = ArgumentParser() parser.add_argument("lab_path", type=str, help='path to the lab directory') args = parser.parse_args() net = Network('15.0.0.0/8') nodes = net.generate_nodes('n', 3) net.create_subnet('net', nodes) local_net = net.create_local_network(nodes[0]) ln = local_net.create_node('l_n1') local_net.create_subnet('LAN', (ln, nodes[0])) net.configure(verbose=True) net.render(args.lab_path, verbose=True)
def main(): net = Network('15.0.0.0/8') # create network nodes node1 = net.create_node('node1', image='env_neo_go_one_image', ports={ '20333/tcp': 20333, '30333/tcp': 30333, '20001/tcp': 20001 }) node2 = net.create_node('node2', image='env_neo_go_two_image', ports={ '20334/tcp': 20334, '30334/tcp': 30334, '20002/tcp': 20002 }) node3 = net.create_node('node3', image='env_neo_go_three_image', ports={ '20335/tcp': 20335, '30335/tcp': 30335, '20003/tcp': 20003 }) node4 = net.create_node('node4', image='env_neo_go_four_image', ports={ '20336/tcp': 20336, '30336/tcp': 30336, '20004/tcp': 20004 }) # create a local network that will connect all those nodes net.create_subnet('net', (node1, node2, node3, node4)) # distribute IP addresses net.configure(verbose=True) # save lab net.render('../../labs/basic_tutorial', verbose=True)
def main(): madt = Network('15.0.0.0/8') # create network nodes that will represent client and server server = madt.create_node('server', image='madt/nginx') clients = madt.generate_nodes('client', 1, image='madt/pyget') # create a local network that will connect all those nodes routers = madt.generate_nodes('ospfr', 2) madt.create_subnet('subnet1', (routers[0], clients[0])) #madt.create_subnet('subnet2', (routers[1], *clients[3:])) madt.create_subnet('subnet3', routers) madt.create_subnet('subnet4', (routers[1], server)) madt.create_overlay(Overlay.OSPF, 'OSPF', routers) # distribute IP addresses madt.configure(verbose=True) # pass server IP to the clients for client in clients: client.add_options(environment={'SERVER': server.get_ip()}) # save lab madt.render('../../labs/monitoring', verbose=True)
def main(): parser = ArgumentParser() parser.add_argument("lab_path", type=str, help='path to the lab directory') args = parser.parse_args() net = Network('15.0.0.0/8') core = net.generate_nodes('core_', 3) routers = net.generate_nodes('r', 2) ospf_routers = net.generate_nodes('ospfr', 2) nodes = net.generate_nodes('n', 11, image='kademlia') net.make_mesh(core) # WAS IT DEPRECATED? # make subnets connecting each pair of nodes net.make_mesh((core[0], *routers)) # WAS IT DEPRECATED? net.create_subnet('ospf_1', (ospf_routers[0], core[2])) net.create_subnet('ospf_2', (ospf_routers[1], core[2])) net.create_subnet('lc1', (*nodes[:2], routers[0])) net.create_subnet('lc2', (*nodes[2:4], routers[1])) net.create_subnet('lc3', (*nodes[4:7], core[1])) net.create_subnet('lc4', (*nodes[7:9], ospf_routers[0])) net.create_subnet('lc5', (*nodes[9:], ospf_routers[1])) net.create_overlay(Overlay.RIP, 'RIP_1', (core[0], *routers)) net.create_overlay(Overlay.OSPF, 'OSPF_1', (core[2], *ospf_routers)) net.create_overlay(Overlay.BGP, 'big_boi', [ [*nodes[:4], *routers, core[0]], [*nodes[4:7], core[1]], [*nodes[7:], *ospf_routers, core[2]] ]) net.configure(verbose=True) for node in nodes[1:]: node.add_options(environment={'KADEMLIA_ARGS': nodes[0].get_ip()}) net.render(args.lab_path, verbose=True)
def main(): madt = Network('15.0.0.0/8') server = madt.create_node('server', image='madt/nginx') clients = madt.generate_nodes( 'client', 6, image='inutano/wget', entrypoint= 'sh -c "while true; do wget -O - -T 3 $SERVER; sleep 1; done"') routers = madt.generate_nodes('router', 3) madt.create_subnet('subnet1', (routers[0], *clients[:3])) madt.create_subnet('subnet2', (routers[1], *clients[3:])) madt.create_subnet('subnet3', routers) madt.create_subnet('subnet4', (routers[2], server)) madt.create_overlay(Overlay.RIP, 'RIP', routers) madt.configure(verbose=True) for client in clients: client.add_options(environment={'SERVER': server.get_ip()}) madt.render('../../labs/dynamic_routing', verbose=True)
def main(): net = Network('15.0.0.0/8') node1 = net.create_node('peer0.org1.example.com', image='hyperledger/fabric-peer:latest', enviroment={"", "", ""}, entrypoint="sleep infinity", ports={'7051/tcp': 7051}, privileged=True) node2 = net.create_node('peer0.org2.example.com', image='hyperledger/fabric-peer:latest', enviroment={"", "", ""}, entrypoint="sleep infinity", ports={'9051/tcp': 7051}, privileged=True) node3 = net.create_node('orderer.example.com', image='hyperledger/fabric-orderer:latest', enviroment={"", "", ""}, entrypoint="sleep infinity", ports={'7050/tcp': 7050}, privileged=True) net.create_subnet('net', (node1, node2, node3)) net.configure(verbose=True) net.render('../../madt/labs/HL_Fabric', verbose=True)
nodes = net.generate_nodes('n', 11, image='kademlia') net.make_mesh(core) # make subnets connecting each pair of nodes net.make_mesh((core[0], *routers)) net.create_subnet('ospf_1', (ospf_routers[0], core[2])) net.create_subnet('ospf_2', (ospf_routers[1], core[2])) net.create_subnet('lc1', (*nodes[:2], routers[0])) net.create_subnet('lc2', (*nodes[2:4], routers[1])) net.create_subnet('lc3', (*nodes[4:7], core[1])) net.create_subnet('lc4', (*nodes[7:9], ospf_routers[0])) net.create_subnet('lc5', (*nodes[9:], ospf_routers[1])) net.create_overlay(Overlay.RIP, 'RIP_1', (core[0], *routers)) net.create_overlay(Overlay.OSPF, 'OSPF_1', (core[2], *ospf_routers)) net.create_overlay(Overlay.BGP, 'big_boi', [[*nodes[:4], *routers, core[0]], [*nodes[4:7], core[1]], [*nodes[7:], *ospf_routers, core[2]]]) net.configure(verbose=True) for n in nodes[1:]: n.add_options(environment={'KADEMLIA_ARGS': nodes[0].get_ip()}) net.render(sys.argv[1], verbose=True)
main_net.create_subnet('lc4', (*nodes[7:9], ospf_routers[0])) main_net.create_subnet('lc5', (*nodes[9:], ospf_routers[1])) main_net.create_overlay(Overlay.RIP, 'RIP_1', (core[0], *routers)) main_net.create_overlay(Overlay.OSPF, 'OSPF_1', (core[2], *ospf_routers)) main_net.create_overlay( Overlay.BGP, 'big_boi', [[*nodes[:4], *routers, gateway, core[0]], [*nodes[4:7], core[1]], [*nodes[7:], *ospf_routers, core[2]]]) local_net = main_net.create_local_network(gateway) local_routers = local_net.generate_nodes('lan_router', 2) local_net.create_subnet('LAN0', (*local_routers, gateway)) for idx, r in enumerate(local_routers): n = local_net.create_node('lan_node' + str(idx + 1), image='kademlia') local_net.create_subnet('LAN' + str(idx + 1), (n, r)) nodes.append(n) local_net.create_overlay(Overlay.RIP, 'RIP_1', local_routers) main_net.configure(verbose=True) for n in nodes[1:]: n.add_options(environment={'KADEMLIA_ARGS': nodes[0].get_ip()}) main_net.render(sys.argv[1], verbose=True)
from madt_lib.network import Network, Overlay kt = Network('15.0.0.0/8') # create network nodes that will represent client and server server = kt.create_node('server', image='madt/nginx') clients = kt.generate_nodes('client', 6, image='madt/pyget') # create a local network that will connect all those nodes routers = kt.generate_nodes('router', 3) kt.create_subnet('subnet1', (routers[0], *clients[:3])) kt.create_subnet('subnet2', (routers[1], *clients[3:])) kt.create_subnet('subnet3', routers) kt.create_subnet('subnet4', (routers[2], server)) kt.create_overlay(Overlay.RIP, 'RIP', routers) # distribute IP addresses kt.configure(verbose=True) # pass server IP to the clients for client in clients: client.add_options(environment={'SERVER': server.get_ip()}) # save lab kt.render('/home/demo/labs/monitoring', verbose=True)
def main(): net = Network('15.0.0.0/8') node_count = 6 thunders = [] # path = 'my:/home/svetlov/Downloads/madt/tutorials/madt_thunder/build/tendermint:Z' # create network nodes that will represent client and server for x in range(1,6): thunders.append(net.create_node('node'+str(x), privileged=True, image="tendermint/validator", ports={'26656/tcp': 26659+2*(x-1), '26657/tcp': 26660+2*(x-1)}, environment={'ID':str(x-1),'LOG':'${LOG:-tendermint.log}'}, )) # create sleep node to simulated adding new nodes for x in range(6,7): thunders.append(net.create_node('node'+str(x), privileged=True, image="tendermint/validator", ports={'26656/tcp': 26659+2*(x-1), '26657/tcp': 26660+2*(x-1)}, environment={'ID':str(x-1),'LOG':'${LOG:-tendermint.log}'}, # entrypoint="sleep "+str(int(x>4)*x*10) entrypoint="sleep 100000", )) x=7 thunders.append(net.create_node('node'+str(x), privileged=True, image="tendermint/nonvalidator", ports={'26656/tcp': 26659+2*(7-1), '26657/tcp': 26660+2*(x-1)}, environment={'ID':str(x-1),'LOG':'${LOG:-tendermint.log}'}, # entrypoint="sleep "+str(int(x>4)*x*10) #entrypoint="sleep 100000", )) # thunder1 = net.create_node('node1', # privileged=True, # image="tendermint/validator", # ports={'26656/tcp': 26656, '26657/tcp': 26657}, # environment={'ID':'0','LOG':'${LOG:-tendermint.log}'}) # thunder2 = net.create_node('node2', # privileged=True, # image="tendermint/validator", # ports={'26656/tcp': 26659, '26657/tcp': 26660}, # environment={'LOG':'${LOG:-tendermint.log}', 'ID':'1'}) # thunder3 = net.create_node('node3', # privileged=True, # image="tendermint/validator", # environment={'LOG':'${LOG:-tendermint.log}', 'ID':'2'}, # ports={'26656/tcp': 26661, '26657/tcp': 26662}, # ) # thunder4 = net.create_node('node4', # privileged=True, # image="tendermint/validator", # environment={'LOG':'${LOG:-tendermint.log}', 'ID':'3'}, # ports={'26656/tcp': 26663, '26657/tcp': 26664}, # ) # thunder5 = net.create_node('node5', # privileged=True, # image="tendermint/nonvalidator", # environment={'LOG':'${LOG:-tendermint.log}', 'ID':'4'}, # ports={'26656/tcp': 26665, '26657/tcp': 26666}, # entrypoint="sleep 10000000", # #volumes=path # ) # create a local network that will connect all those nodes net.create_subnet('net', thunders) # net.create_subnet('net', (thunder1,thunder2,thunder3,thunder4)) # distribute IP addresses net.configure(verbose=True) net.render('../../labs/my', verbose=True)