Skip to main content

A tool for creating dummy networks using network namespaces.

Project description

PyPi Waf Python Tests Black Flake8 Pip Install

dummynet-python is a tool for working with dummy-networks in python on Linux machines. By dummy-networks we refer to setups with network namespaces, virtual ethernets, etc.

The Dummynet class is a python wrapper for the linux ‘ip netns’ and ‘ip link’ tools. The methods of the class parse args directly to the command-line in your linux OS.

So far, Ubuntu and Debian are supported, but please make sure, that you have the iproute2 linux-package installed with:

apt-get install iproute2

Other Linux operating systems have not been tested, but feel free to open an issue if support is needed.

Installation

To install dummynet-python:

pip install dummynet-python

Usage

import dummynet

def main():

    with dummynet.host() as shell:

        demo0 = shell.netns_add(name="namespace1")
        demo1 = shell.netns_add(name="namespace2")

        shell.link_veth_add(p1_name="peer1", p2_name="peer2")

For a complete example of a local network setup see the test in ‘test/test_dummynet.py’.

You can try playing around with the class methods in dummynet.py and call the commands in self.shell.run(cmd) from the command-line. This can give a better idea of the functionality.

Release new version

  1. Edit NEWS.rst and wscript (set correct VERSION)

  2. Run

    ./waf upload

Source code

The main functionality is found in src/dummy_net.py and the corresponding unit test is in test/test_dummynet.py if you want to play/modify/fix the code this would, in most cases, be the place to start.

Developer Notes

We try to make our projects as independent as possible of a local system setup. For example with our native code (C/C++) we compile as much as possible from source, since this makes us independent of what is currently installed (libraries etc.) on a specific machine.

To “fetch” sources we use Waf (https://waf.io/) augmented with dependency resolution capabilities: https://github.com/steinwurf/waf

The goal is to enable a work-flow where running:

./waf configure
./waf build --run_tests

Configures, builds and runs any available tests for a given project, such that you as a developer can start hacking at the code.

For Python project this is a bit unconventional, but we think it works well.

Tests

The tests will run automatically by passing --run_tests to waf:

./waf --run_tests

This follows what seems to be “best practice” advise, namely to install the package in editable mode in a virtualenv.

Notes

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

dummynet-1.0.1-py2.py3-none-any.whl (9.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dummynet-1.0.1-py2.py3-none-any.whl.

File metadata

  • Download URL: dummynet-1.0.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.9.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for dummynet-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7ea2df091e99a8aee2f12bbdb482838ccbb1cf85b0d9cda05bd526899c4169f9
MD5 98d99368680536ef21f8f2462374ce6d
BLAKE2b-256 a64ea025186d660c2b7beb38b93539b02776f57f583446f8dacc6ff964e81fad

See more details on using hashes here.

Supported by

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