Skip to main content

Simple Docker based Network Simulator

Project description

L3 Network Simulator repository

With the aid of Python scripts, this library may be used to describe and manage virtual networks running inside Docker containers.

Installation

  1. L3NS requires Docker (https://docs.docker.com/engine/install/)
  2. Without sudo, further configuration is required for Docker and L3NS (https://docs.docker.com/engine/install/linux-postinstall/)
  3. pip3 install l3ns-dev

First look

Examples of how to use the library can be found in the examples subdirectory. The best option is to use [this example](examples/simple/basic docker lab.py) to obtain a general understanding of the library and api docs.

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)

The script can be executed by typing "python3".

    # python3 basic_docker_lab.py
    10.0.0.1
    10.0.0.2 

Docker will build two containers (named "test1" and "test2") from the "alpine" docker image as the script executes, and these containers will execute the "tail -f /dev/null" command. This command has no effect and lets the container keep running until manually terminating it. The IP addresses of both containers will be shown during the script and they will both be linked to the same subnet. By executing "ping" on any of the containers, you can verify this:

    docker exec -it node1 ping 10.0.0.2

IP packets are allowed to flow between nodes if you see a response.

Introduction

The three categories of objects that make up the operation of L3NS are "Node" (the emulated network's node), "Subnet" (the network's IP subnet), and "Network" (a separate emulated network, local - LAN, or global - WAN). The same network encompasses all subnets, and nodes might be a part of both one global and many local networks.

L3NS offers a variety of node implementations, subnets, and networks with various scopes but the same API. The l3ns.base submodule contains the abstract classes that describe the overall API. L3NS now offers l3ns.ldc (Local Docker Container) and l3ns.cluster as its two implementations.

API Reference

The API REFERENCE.md file contains comprehensive documentation of L3NS modules. It is created using the command pydoc-markdown (you must install the package with the same name from PyPI), and it is based on the documentation provided in the source code.

Writing your own simulation script

There are numerous fundamental steps that go up describing a virtual network model using l3ns:

  1. Building the network's central hub, which will have many routers that will transfer traffic between its various nodes. This phase may be done multiple times for networks with a high level of complexity.
  2. Establishing subnets across routers. The simplest method is to add all routers to the same subnet, although this may restrict your ability to manage the dynamic network state while testing. In this situation, there is no need to update the routing overlays; you may need to divide some routers into separate subnets.
  3. Configuring routers using dynamic routing protocols. Of course, the protocol used depends on the objectives set, but if you're unsure or have no idea which protocol to pick, utilize OSPF.
  4. Establishing end subnets connected to routers and populating them with payload nodes—aspects of the application being tested.
  5. The network's test launch. It can be beneficial to confirm that the network is configured appropriately before moving on to test the application.

The simplest method to accomplish this is to, as shown in [some examples](examples/sto_k/ping scalable.py), replace the entrypoint/cmd nodes with the logic application that is being tested. Ping will terminate if it is unable to deliver packets to the target node, such as when routing is wrongly setup or there is no network path between hosts, such as when a subnet is forgotten. The debugging of l3ns models is made a great deal simpler by this method. 6. Use the completed network.

When distant resources are required for modeling and the submodule l3ns.cluster is used, a preparatory stage is added: the preliminary configuration of cluster nodes. Examples (examples/simple/basic swarm lab.py) show how it appears.

Litrature on L3NS:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

l3ns-dev-0.0.2.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

l3ns_dev-0.0.2-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file l3ns-dev-0.0.2.tar.gz.

File metadata

  • Download URL: l3ns-dev-0.0.2.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for l3ns-dev-0.0.2.tar.gz
Algorithm Hash digest
SHA256 037c5e999b770141fb100dbf8c8dbedc758edcdc8dfa0edd01e06f90592e0c6c
MD5 08e6b05cb96f64d4863154c51b7f125c
BLAKE2b-256 7c5d6668acf8d56f1306a8ff8317281235d13a036cc8beb9256246c665fc402f

See more details on using hashes here.

File details

Details for the file l3ns_dev-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: l3ns_dev-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 27.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for l3ns_dev-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 340fe52b7e9cfeae95db2e7faa1d826b7613ad969b3829120638283273f73fe5
MD5 3f4e97e1e2e882410c024a95e80cf221
BLAKE2b-256 0f6ccf9cfd18cc224cd198918d432ac5cceacc870e850424b702aa81c8c102d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page