Skip to main content

pynetem

PyNetem is a tool that allow the user to limit the bandwidth or simulate weak network. It does so by using iproute's tc command, but greatly simplifies its operation. And provide apis if you need in your work.

Installation

pip install pynetem

How to Use It?

In command mode, type pynetem -h, you will see help information, parameters in this tool is same as 'tc/netem'.

If the host cannot download package from PyPI, you can use PyNetem (>=0.1.2) in your PC (no mater Windows or Linux) with the following parameters in addition:

--host          The host IP, which you will send command to
--usrname       The username of host
--password      The password of host

You can also use original command of tc/netem. For more information about tc/netem, you can click here: netem

It is recommended to use web mode, when you have several hosts to control, or you want to build a web page for easier usage.

Run in web mode: pynetem --web, default port is 8899, you can specify by yourself pynetem --web --port=9090

There are 8 APIs:

[GET] /pynetem/help                                     -- Get demo post data and simple description
[GET] /pynetem/listInterfaces                           -- Get interfaces name of host
[GET] /pynetem/getRules?eth=<interface name>            -- Get qdisc rules by interface
[GET/DELETE] /pynetem/clear?eth=<interface name>        -- Clear all rules
[POST] /pynetem/setRules?eth=<interface name>           -- Set tc qdisc rule

[POST] /pynetem/brctl/addbr                             -- Set bridge, the bridge name is pynetem_bridge by defaut
[GET/DELETE] /pynetem/brctl/delbr                       -- Delete pynetem_bridge
[POST] /pynetem/brctl/addif                             -- Add interface(s) to pynetem_bridge

Post Body, if you set parameter None or '', the parameter will be ignored.

Format for the options is the same as tc-netem's and tc-tbf's.

[POST] /pynetem/setRules?eth=<interface name>

{
    "delay": "100ms 10ms 25%",
    "distribution": "normal",
    "reorder": "25% 50%",
    "loss": "0.3% 25%",
    "duplicate": "1%",
    "corrupt": "0.1%",
    # Bitrate control using Netem 
    "netem_rate": "256kbit",
    "netem_limit": 3000,
    # Bitrate control using TBF
    "rate": "256kbit",
    "buffer": 1600,
    "limit": 3000,
    "dst": "10.10.10.0/24"
}

netem_rate and rate are mutually exclusive.

buffer, limit, and dst can only be used if rate is set.


[POST] /pynetem/brctl/addbr

stp is "on" by default.

{
    "interfaces": ["eth0", "eth1"],
    "stp": "on"
}

[POST] /pynetem/brctl/addif

{
    "interfaces": ["eth2"]
}

ATTENTION!

When you press ctrl + c to stop the web server, ALL qdisc rules in all interfaces AND the pynetem_bridge will be cleared automatically.

Metadata

Release files for pynetem 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pynetem 0.1.5
File Size Uploaded Provenance Actions
pynetem-0.1.5.tar.gz 10.6 kB Without provenance Details for pynetem-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pynetem 0.1.5
File Interpreter ABI Platform Actions
pynetem-0.1.5-py2.py3-none-any.whl Python 2, Python 3 none any Details for pynetem-0.1.5-py2.py3-none-any.whl

Total release size: 22.2 kB

Release files / pynetem-0.1.5.tar.gz

Download URL pynetem-0.1.5.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
095f777edb74ff1ec44449454b8381be0f2881df3974dcba5df46df6727cc542
BLAKE2b-256 checksum
How to use checksums
b05d14be90499a1d314e77131a8438b108d1780ebc14bf771105ef549fd54257
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / pynetem-0.1.5-py2.py3-none-any.whl

Download URL pynetem-0.1.5-py2.py3-none-any.whl
Size 11.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
42901d65c7a82b269df8b0ae36ab0f5154104ae14c0259ad68da0a5152ad9a91
BLAKE2b-256 checksum
How to use checksums
47ad30bc83d2b23f01d4c0c624657b33c23d245b1bb4e3ce602800bd43c1770c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Security for pynetem 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page