Exemple #1
0
from l3ns.base.network import Network, NetworkConcurrent
from l3ns import defaults

import sys

if sys.argv[2] == 'c':
    defaults.network = NetworkConcurrent('15.2.0.0/16', max_workers=8)
else:
    defaults.network = Network('15.2.0.0/16')

N = int(sys.argv[1])

s = DockerSubnet(name='polygon', size=N+10)

nodes = [
    DockerNode(
        'l3ns_node_1',
        image='l3ns/kademlia')]

s.add_node(nodes[0])

for i in range(N-1):
    n = DockerNode(
        'l3ns_node_' + str(i + 2),
        image='l3ns/kademlia',
        command=nodes[int(i/10)].get_ip())
    nodes.append(n)
    s.add_node(n)

defaults.network.start(interactive=True)
Exemple #2
0
from l3ns.ldc import DockerNode, DockerSubnet
from l3ns.base.network import Network, NetworkConcurrent
from l3ns import defaults

defaults.network = Network('16.0.0.0/8')
dockers = []
nodes = 3
s = DockerSubnet(name='polygon', size=10)
for i in range(nodes):
    node = DockerNode('node' + str(i + 2),
                      image='eth',
                      command='sh -c "distr/setup_account.sh ' + str(i + 2) +
                      '"')
    dockers.append(node)
    s.add_node(node)

for node in dockers:
    print(node.get_ip())

defaults.network.start(interactive=True)
Exemple #3
0
from l3ns.ldc import DockerNode, DockerSubnet
from l3ns import defaults, net
from l3ns.overlays.ospf import OspfOverlay

defaults.subnet_class = DockerSubnet

routers = DockerNode.generate_routers('router', 2)
router_net = net.create_subnet('router_net', routers, size=4)

overlay = OspfOverlay(routers)

nodes = DockerNode.generate_nodes('node', 2, image='alpine', command='tail -f /dev/null')


for n, r in zip(nodes, routers):
    n.connect_to(r)

net.start(interactive=True)

#                         ports={'20335/tcp': 20335, '30335/tcp': 30335, '20003/tcp': 20003},
#                         volumes={os.getcwd()+'/config/protocol.privnet.docker.one.yml':{'bind':'/config/protocol.privnet.docker.yml', 'mode':'ro'}, os.getcwd()+'/config/wallet1.json':{'bind':'/wallet3.json', 'mode':'ro'}}, command='/usr/bin/privnet-entrypoint.sh node --config-path /config --privnet')
# node4 = DockerNode('node4', image='env_neo_go_image',
#                         ports={'20336/tcp': 20336, '30336/tcp': 30336, '20004/tcp': 20004},
#                         volumes={os.getcwd()+'/config/protocol.privnet.docker.one.yml':{'bind':'/config/protocol.privnet.docker.yml', 'mode':'ro'}, os.getcwd()+'/config/wallet1.json':{'bind':'/wallet4.json', 'mode':'ro'}}, command='/usr/bin/privnet-entrypoint.sh node --config-path /config --privnet')

node1 = DockerNode(
    'node1',
    image='env_neo_go_image',
    ports={
        '20333/tcp': 20333,
        '30333/tcp': 30333,
        '20001/tcp': 20001
    },
    volumes={
        os.getcwd() + '/config/protocol.privnet.docker.one.yml': {
            'bind': '/config/protocol.privnet.yml',
            'mode': 'ro'
        },
        os.getcwd() + '/.docker/wallets/wallet1.json': {
            'bind': '/wallet1.json',
            'mode': 'rw'
        }
    },
    command=
    '/usr/bin/privnet-entrypoint.sh node --config-path /config --privnet')
node2 = DockerNode(
    'node2',
    image='env_neo_go_image',
    ports={
        '20334/tcp': 20334,
        '30334/tcp': 30334,
Exemple #5
0
from l3ns.ldc import DockerNode
from l3ns import defaults

n1 = DockerNode('test1', image='alpine', command='tail -f /dev/null')
n2 = DockerNode('test2', image='alpine', command='tail -f /dev/null')

n1.connect_to(n2)

print(n1.get_ip())
print(n2.get_ip())

defaults.network.start(interactive=True)
Exemple #6
0
from l3ns.ldc import DockerNode, DockerSubnet
from l3ns import defaults

subnet = DockerSubnet('l3ns_kademlia')

n1 = DockerNode('kademlia1', image='l3ns/kademlia')
subnet.add_node(n1)
n2 = DockerNode('kademlia2', image='l3ns/kademlia', command=n1.get_ip())
subnet.add_node(n2)

defaults.network.start(interactive=True)
Exemple #7
0
from l3ns.ldc import DockerNode, DockerSubnet
from l3ns.base.network import Network, NetworkConcurrent
from l3ns import defaults

import sys

if sys.argv[2] == 'c':
    defaults.network = NetworkConcurrent('15.0.0.0/16', max_workers=8)
else:
    defaults.network = Network('15.0.0.0/16')

N = int(sys.argv[1])

s = DockerSubnet(name='polygon', size=N + 10)

nodes = []

for i in range(N):
    n = DockerNode('l3ns_node_' + str(i + 1),
                   image='l3ns/ts_ping',
                   command='tail -f /dev/null' if not len(nodes) else
                   'ping {} | ts "[%H:%M:%S]"'.format(nodes[int(i /
                                                                10)].get_ip()))
    nodes.append(n)
    s.add_node(n)

defaults.network.start(interactive=True)
Exemple #8
0
inteerconnect = 10

m = N // 500 + 1  # количество подсетей

N = N // m  # количество контейнеров в подсети

print(m, N, m * N)
routers = []
router_net = DockerSubnet('router_net', [], size=m * inteerconnect + 10)
lans = []

for i in range(m):
    lan_nodes = []
    lans.append(lan_nodes)

    lan_routers = DockerNode.generate_routers(f'router{i}_', inteerconnect)
    routers += lan_routers
    for r in lan_routers:
        router_net.add_node(r)
    lan_nodes.extend(lan_routers)

    lan_nodes.extend([
        DockerNode(
            f'node_{i}_{j+1}',
            image='alpine',
            command=f'ping {random.choice(random.choice(lans)).get_ip()}')
        for j in range(N)
    ])

    lan_net = DockerSubnet(f'net_{i}', lan_nodes)
Exemple #9
0
if sys.argv[2] == 'c':
    defaults.network = NetworkConcurrent('15.0.0.0/16', max_workers=2)
else:
    defaults.network = Network('15.0.0.0/16')

N = int(sys.argv[1])
nodes = []
N1 = int(N / 2)

s1 = DockerSubnet(name='polygon1', size=N1 + 10)
s2 = DockerSubnet(name='polygon2', size=N1 + 10)

for i in range(N1):
    n = DockerNode(image='alpine',
                   command='tail -f /dev/null'
                   if not len(nodes) else 'ping {}'.format(nodes[-1].get_ip()),
                   name='l3ns_node_' + str(i + 1))
    nodes.append(n)
    s1.add_node(n)

for i in range(N - N1):
    n = DockerNode(image='alpine',
                   command='tail -f /dev/null' if len(nodes) == N1 else
                   'ping {}'.format(nodes[N1].get_ip()),
                   name='l3ns_node_' + str(N1 + i + 1))
    nodes.append(n)
    s2.add_node(n)

defaults.network.start(interactive=True)