.. contents:: **tcconfig**
:backlinks: top
:depth: 2
Summary
=========
`tcconfig <https://github.com/thombashi/tcconfig>`__ is a tc command wrapper. Make it easy to set up traffic control of network bandwidth/latency/packet-loss/packet-corruption/etc. to a network-interface/Docker-container(veth).
|PyPI pkg ver| |Supported Python ver| |CI status| |CodeQL|
.. |PyPI pkg ver| image:: https://badge.fury.io/py/tcconfig.svg
:target: https://badge.fury.io/py/tcconfig
:alt: PyPI package version
.. |Supported Python ver| image:: https://img.shields.io/pypi/pyversions/tcconfig.svg
:target: https://pypi.org/project/tcconfig
:alt: Supported Python versions
.. |CI status| image:: https://github.com/thombashi/tcconfig/actions/workflows/ci.yml/badge.svg
:target: https://github.com/thombashi/tcconfig/actions/workflows/ci.yml
:alt: Test CI status
.. |CodeQL| image:: https://github.com/thombashi/tcconfig/actions/workflows/build_and_release.yml/badge.svg
:target: https://github.com/thombashi/tcconfig/actions/workflows/build_and_release.yml
:alt: Build CI status
Traffic control
------------------------
Setup traffic shaping rules
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Easy to apply traffic shaping rules to specific networks:
- Outgoing/Incoming packets
- Source/Destination IP-address/network (IPv4/IPv6)
- Source/Destination ports
Available Parameters
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The following parameters can be set to network interfaces:
- Network bandwidth rate ``[G/M/K bps]``
- Network latency ``[microseconds/milliseconds/seconds/minutes]``
- Packet loss rate ``[%]``
- Packet corruption rate ``[%]``
- Packet duplicate rate ``[%]``
- Packet reordering rate ``[%]``
- Packet limit count ``[COUNT]``
Targets
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Network interfaces: e.g. ``eth0``
- Docker container (``veth`` corresponding with a container)
.. image:: docs/gif/tcset_example.gif
Usage
=======
Set traffic control (``tcset`` command)
-----------------------------------------
``tcset`` is a command to add a traffic control rule to a network interface (device).
e.g. Set a limit on bandwidth up to 100Kbps
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: console
# tcset eth0 --rate 100Kbps
e.g. Set network latency
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can use time units (such as us/sec/min/etc.) to designate delay time.
Set 100 milliseconds of network latency
'''''''''''''''''''''''''''''''''''''''''''''''''''
.. code-block:: console
# tcset eth0 --delay 100ms
Set 10 seconds of network latency
'''''''''''''''''''''''''''''''''''''''''''''''''''
.. code-block:: console
# tcset eth0 --delay 10sec
Set 0.5 minutes (30 seconds) network latency
'''''''''''''''''''''''''''''''''''''''''''''''''''
.. code-block:: console
# tcset eth0 --delay 0.5min
You can also use the following time units:
.. table::
+------------+----------------------------------------------------------+
| Unit | Available specifiers (str) |
+============+==========================================================+
|hours |``h``/``hour``/``hours`` |
+------------+----------------------------------------------------------+
|minutes |``m``/``min``/``mins``/``minute``/``minutes`` |
+------------+----------------------------------------------------------+
|seconds |``s``/``sec``/``secs``/``second``/``seconds`` |
+------------+----------------------------------------------------------+
|milliseconds|``ms``/``msec``/``msecs``/``millisecond``/``milliseconds``|
+------------+----------------------------------------------------------+
|microseconds|``us``/``usec``/``usecs``/``microsecond``/``microseconds``|
+------------+----------------------------------------------------------+
e.g. Set 0.1% packet loss
^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: console
# tcset eth0 --loss 0.1%
e.g. All of the above settings at once
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: console
# tcset eth0 --rate 100Kbps --delay 100ms --loss 0.1%
e.g. Specify the IP address of the traffic control
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: console
# tcset eth0 --delay 100ms --network 192.168.0.10
e.g. Specify the IP network and port of traffic control
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: console
# tcset eth0 --delay 100ms --network 192.168.0.0/24 --port 80
Set traffic control to a docker container
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Execute ``tcconfig`` with ``--docker`` option on a Docker host:
.. code-block:: console
# tcset <container name or ID> --docker ...
You could use ``--src-container``/``--dst-container`` options to specify the source/destination container.
Set traffic control within a docker container
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You need to run a container with ``--cap-add NET_ADMIN`` option
if you would like to set a tc rule within a container:
.. code-block:: console
docker run -d --cap-add NET_ADMIN -t <docker image>
A container image that builtin tcconfig can be available at https://hub.docker.com/r/thombashi/tcconfig/
Delete traffic control (``tcdel`` command)
------------------------------------------
``tcdel`` is a command to delete traffic shaping rules from a network interface (device).
e.g. Delete traffic control of ``eth0``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can delete all of the shaping rules for the ``eth0`` with ``-a``/``--all`` option:
.. code-block:: console
# tcdel eth0 --all
Display traffic control configurations (``tcshow`` command)
-----------------------------------------------------------
``tcshow`` is a command to display the current traffic control settings for network interface(s).
Example
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: console
# tcset eth0 --delay 10ms --delay-distro 2 --loss 0.01% --rate 0.25Mbps --network 192.168.0.10 --port 8080
# tcset eth0 --delay 1ms --loss 0.02% --rate 500Kbps --direction incoming
# tcshow eth0
{
"eth0": {
"outgoing": {
"dst-network=192.168.0.10/32, dst-port=8080, protocol=ip": {
"filter_id": "800::800",
"delay": "10.0ms",
"delay-distro": "2.0ms",
"loss": "0.01%",
"rate": "250Kbps"
}
},
"incoming": {
"protocol=ip": {
"filter_id": "800::800",
"delay": "1.0ms",
"loss": "0.02%",
"rate": "500Kbps"
}
}
}
}
For more information
----------------------
More examples are available at
https://tcconfig.rtfd.io/en/latest/pages/usage/index.html
Installation
============
Installation: pip
------------------------------
``tcconfig`` can be installed from `PyPI <https://pypi.python.org/pypi>`__ via
`pip <https://pip.pypa.io/en/stable/installing/>`__ (Python package manager) command.
.. code:: console
sudo pip install tcconfig
Installation: dpkg (Debian/Ubuntu)
--------------------------------------------
.. code:: console
curl -sSL https://raw.githubusercontent.com/thombashi/tcconfig/master/scripts/installer.sh | sudo bash
Dependencies
============
- Python 3.7+
- `Python package dependencies (automatically installed) <https://github.com/thombashi/tcconfig/network/dependencies>`__
Linux packages
--------------
- mandatory: required for ``tc`` command:
- `Ubuntu`/`Debian`: ``iproute2``
- `Fedora`/`RHEL`: ``iproute-tc``
- optional: required when you use the ``--iptables`` option:
- ``iptables``
Linux kernel module
----------------------------
- ``sch_netem``
Optional Python packages
----------------------------
- `Pygments <http://pygments.org/>`__
Documentation
===============
https://tcconfig.rtfd.io/
Troubleshooting
=================
https://tcconfig.rtfd.io/en/latest/pages/troubleshooting.html
Docker image
==============
https://hub.docker.com/r/thombashi/tcconfig/
Sponsors
====================================
|chasbecker| |shiguredo| |b4tman| |Arturi0| |github|
.. |chasbecker| image:: https://avatars.githubusercontent.com/u/44389260?s=48&u=6da7176e51ae2654bcfd22564772ef8a3bb22318&v=4
:target: https://github.com/chasbecker
:alt: ex-sponsor: Charles Becker (chasbecker)
.. |shiguredo| image:: https://avatars.githubusercontent.com/u/2549434?s=48&v=4
:target: https://github.com/shiguredo
:alt: ex-sponsor: 時雨堂 (shiguredo)
.. |b4tman| image:: https://avatars.githubusercontent.com/u/3658062?s=48&v=4
:target: https://github.com/b4tman
:alt: onetime: Dmitry Belyaev (b4tman)
.. |Arturi0| image:: https://avatars.githubusercontent.com/u/46711571?s=48&u=57687c0e02d5d6e8eeaf9177f7b7af4c9f275eb5&v=4
:target: https://github.com/Arturi0
:alt: onetime: Arturi0
.. |github| image:: https://avatars.githubusercontent.com/u/9919?s=48&v=4
:target: https://github.com/github
:alt: onetime: GitHub (github)
`Become a sponsor <https://github.com/sponsors/thombashi>`__
Raw data
{
"_id": null,
"home_page": "https://github.com/thombashi/tcconfig",
"name": "tcconfig",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "network, traffic control, tc, traffic shaping, docker",
"author": "Tsuyoshi Hombashi",
"author_email": "tsuyoshi.hombashi@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/a9/5d/29e0cc998580b39222b43e955be104fd2c0b5f8d3c8c04fe83aea58da7ed/tcconfig-0.29.1.tar.gz",
"platform": null,
"description": ".. contents:: **tcconfig**\n :backlinks: top\n :depth: 2\n\nSummary\n=========\n`tcconfig <https://github.com/thombashi/tcconfig>`__ is a tc command wrapper. Make it easy to set up traffic control of network bandwidth/latency/packet-loss/packet-corruption/etc. to a network-interface/Docker-container(veth).\n\n|PyPI pkg ver| |Supported Python ver| |CI status| |CodeQL|\n\n.. |PyPI pkg ver| image:: https://badge.fury.io/py/tcconfig.svg\n :target: https://badge.fury.io/py/tcconfig\n :alt: PyPI package version\n\n.. |Supported Python ver| image:: https://img.shields.io/pypi/pyversions/tcconfig.svg\n :target: https://pypi.org/project/tcconfig\n :alt: Supported Python versions\n\n.. |CI status| image:: https://github.com/thombashi/tcconfig/actions/workflows/ci.yml/badge.svg\n :target: https://github.com/thombashi/tcconfig/actions/workflows/ci.yml\n :alt: Test CI status\n\n.. |CodeQL| image:: https://github.com/thombashi/tcconfig/actions/workflows/build_and_release.yml/badge.svg\n :target: https://github.com/thombashi/tcconfig/actions/workflows/build_and_release.yml\n :alt: Build CI status\n\nTraffic control\n------------------------\n\nSetup traffic shaping rules\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nEasy to apply traffic shaping rules to specific networks:\n\n- Outgoing/Incoming packets\n- Source/Destination IP-address/network (IPv4/IPv6)\n- Source/Destination ports\n\nAvailable Parameters\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nThe following parameters can be set to network interfaces:\n\n- Network bandwidth rate ``[G/M/K bps]``\n- Network latency ``[microseconds/milliseconds/seconds/minutes]``\n- Packet loss rate ``[%]``\n- Packet corruption rate ``[%]``\n- Packet duplicate rate ``[%]``\n- Packet reordering rate ``[%]``\n- Packet limit count ``[COUNT]``\n\nTargets\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n- Network interfaces: e.g. ``eth0``\n- Docker container (``veth`` corresponding with a container)\n\n.. image:: docs/gif/tcset_example.gif\n\nUsage\n=======\nSet traffic control (``tcset`` command)\n-----------------------------------------\n``tcset`` is a command to add a traffic control rule to a network interface (device).\n\ne.g. Set a limit on bandwidth up to 100Kbps\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n.. code-block:: console\n\n # tcset eth0 --rate 100Kbps\n\ne.g. Set network latency\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nYou can use time units (such as us/sec/min/etc.) to designate delay time.\n\nSet 100 milliseconds of network latency\n'''''''''''''''''''''''''''''''''''''''''''''''''''\n.. code-block:: console\n\n # tcset eth0 --delay 100ms\n\n\nSet 10 seconds of network latency\n'''''''''''''''''''''''''''''''''''''''''''''''''''\n.. code-block:: console\n\n # tcset eth0 --delay 10sec\n\nSet 0.5 minutes (30 seconds) network latency\n'''''''''''''''''''''''''''''''''''''''''''''''''''\n.. code-block:: console\n\n # tcset eth0 --delay 0.5min\n\nYou can also use the following time units:\n\n.. table::\n\n +------------+----------------------------------------------------------+\n | Unit | Available specifiers (str) |\n +============+==========================================================+\n |hours |``h``/``hour``/``hours`` |\n +------------+----------------------------------------------------------+\n |minutes |``m``/``min``/``mins``/``minute``/``minutes`` |\n +------------+----------------------------------------------------------+\n |seconds |``s``/``sec``/``secs``/``second``/``seconds`` |\n +------------+----------------------------------------------------------+\n |milliseconds|``ms``/``msec``/``msecs``/``millisecond``/``milliseconds``|\n +------------+----------------------------------------------------------+\n |microseconds|``us``/``usec``/``usecs``/``microsecond``/``microseconds``|\n +------------+----------------------------------------------------------+\n\ne.g. Set 0.1% packet loss\n^^^^^^^^^^^^^^^^^^^^^^^^^\n.. code-block:: console\n\n # tcset eth0 --loss 0.1%\n\ne.g. All of the above settings at once\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n.. code-block:: console\n\n # tcset eth0 --rate 100Kbps --delay 100ms --loss 0.1%\n\ne.g. Specify the IP address of the traffic control\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n.. code-block:: console\n\n # tcset eth0 --delay 100ms --network 192.168.0.10\n\ne.g. Specify the IP network and port of traffic control\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n.. code-block:: console\n\n # tcset eth0 --delay 100ms --network 192.168.0.0/24 --port 80\n\nSet traffic control to a docker container\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nExecute ``tcconfig`` with ``--docker`` option on a Docker host:\n\n.. code-block:: console\n\n # tcset <container name or ID> --docker ...\n\nYou could use ``--src-container``/``--dst-container`` options to specify the source/destination container.\n\n\nSet traffic control within a docker container\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nYou need to run a container with ``--cap-add NET_ADMIN`` option\nif you would like to set a tc rule within a container:\n\n.. code-block:: console\n\n docker run -d --cap-add NET_ADMIN -t <docker image>\n\nA container image that builtin tcconfig can be available at https://hub.docker.com/r/thombashi/tcconfig/\n\nDelete traffic control (``tcdel`` command)\n------------------------------------------\n``tcdel`` is a command to delete traffic shaping rules from a network interface (device).\n\ne.g. Delete traffic control of ``eth0``\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nYou can delete all of the shaping rules for the ``eth0`` with ``-a``/``--all`` option:\n\n.. code-block:: console\n\n # tcdel eth0 --all\n\nDisplay traffic control configurations (``tcshow`` command)\n-----------------------------------------------------------\n``tcshow`` is a command to display the current traffic control settings for network interface(s).\n\nExample\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: console\n\n # tcset eth0 --delay 10ms --delay-distro 2 --loss 0.01% --rate 0.25Mbps --network 192.168.0.10 --port 8080\n # tcset eth0 --delay 1ms --loss 0.02% --rate 500Kbps --direction incoming\n # tcshow eth0\n {\n \"eth0\": {\n \"outgoing\": {\n \"dst-network=192.168.0.10/32, dst-port=8080, protocol=ip\": {\n \"filter_id\": \"800::800\",\n \"delay\": \"10.0ms\",\n \"delay-distro\": \"2.0ms\",\n \"loss\": \"0.01%\",\n \"rate\": \"250Kbps\"\n }\n },\n \"incoming\": {\n \"protocol=ip\": {\n \"filter_id\": \"800::800\",\n \"delay\": \"1.0ms\",\n \"loss\": \"0.02%\",\n \"rate\": \"500Kbps\"\n }\n }\n }\n }\n\nFor more information\n----------------------\nMore examples are available at \nhttps://tcconfig.rtfd.io/en/latest/pages/usage/index.html\n\n\n\nInstallation\n============\nInstallation: pip\n------------------------------\n``tcconfig`` can be installed from `PyPI <https://pypi.python.org/pypi>`__ via\n`pip <https://pip.pypa.io/en/stable/installing/>`__ (Python package manager) command.\n\n.. code:: console\n\n sudo pip install tcconfig\n\n\nInstallation: dpkg (Debian/Ubuntu)\n--------------------------------------------\n.. code:: console\n\n curl -sSL https://raw.githubusercontent.com/thombashi/tcconfig/master/scripts/installer.sh | sudo bash\n\n\nDependencies\n============\n- Python 3.7+\n- `Python package dependencies (automatically installed) <https://github.com/thombashi/tcconfig/network/dependencies>`__\n\nLinux packages\n--------------\n- mandatory: required for ``tc`` command:\n - `Ubuntu`/`Debian`: ``iproute2``\n - `Fedora`/`RHEL`: ``iproute-tc``\n- optional: required when you use the ``--iptables`` option:\n - ``iptables``\n\nLinux kernel module\n----------------------------\n- ``sch_netem``\n\nOptional Python packages\n----------------------------\n- `Pygments <http://pygments.org/>`__\n\nDocumentation\n===============\nhttps://tcconfig.rtfd.io/\n\nTroubleshooting\n=================\nhttps://tcconfig.rtfd.io/en/latest/pages/troubleshooting.html\n\nDocker image\n==============\nhttps://hub.docker.com/r/thombashi/tcconfig/\n\nSponsors\n====================================\n|chasbecker| |shiguredo| |b4tman| |Arturi0| |github|\n\n.. |chasbecker| image:: https://avatars.githubusercontent.com/u/44389260?s=48&u=6da7176e51ae2654bcfd22564772ef8a3bb22318&v=4\n :target: https://github.com/chasbecker\n :alt: ex-sponsor: Charles Becker (chasbecker)\n.. |shiguredo| image:: https://avatars.githubusercontent.com/u/2549434?s=48&v=4\n :target: https://github.com/shiguredo\n :alt: ex-sponsor: \u6642\u96e8\u5802 (shiguredo)\n.. |b4tman| image:: https://avatars.githubusercontent.com/u/3658062?s=48&v=4\n :target: https://github.com/b4tman\n :alt: onetime: Dmitry Belyaev (b4tman)\n.. |Arturi0| image:: https://avatars.githubusercontent.com/u/46711571?s=48&u=57687c0e02d5d6e8eeaf9177f7b7af4c9f275eb5&v=4\n :target: https://github.com/Arturi0\n :alt: onetime: Arturi0\n.. |github| image:: https://avatars.githubusercontent.com/u/9919?s=48&v=4\n :target: https://github.com/github\n :alt: onetime: GitHub (github)\n\n`Become a sponsor <https://github.com/sponsors/thombashi>`__\n\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "tcconfig is a tc command wrapper. Make it easy to set up traffic control of network bandwidth/latency/packet-loss/packet-corruption/etc. to a network-interface/Docker-container(veth).",
"version": "0.29.1",
"project_urls": {
"Changelog": "https://github.com/thombashi/tcconfig/blob/master/CHANGELOG.md",
"Documentation": "https://tcconfig.rtfd.io/",
"Homepage": "https://github.com/thombashi/tcconfig",
"Source": "https://github.com/thombashi/tcconfig",
"Tracker": "https://github.com/thombashi/tcconfig/issues"
},
"split_keywords": [
"network",
" traffic control",
" tc",
" traffic shaping",
" docker"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d204070d5ea8cf1ebd372d116b45ec6dbb9c1d66aed4fb079289dd8eebe425fd",
"md5": "7135a889121cb06c92f9aace17bf58df",
"sha256": "d6dd2dd15d37f8f57793d7835a6a0b4106d8b2c2841efffea2a3c90b5e70c2bb"
},
"downloads": -1,
"filename": "tcconfig-0.29.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7135a889121cb06c92f9aace17bf58df",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 52606,
"upload_time": "2024-07-28T14:00:07",
"upload_time_iso_8601": "2024-07-28T14:00:07.301396Z",
"url": "https://files.pythonhosted.org/packages/d2/04/070d5ea8cf1ebd372d116b45ec6dbb9c1d66aed4fb079289dd8eebe425fd/tcconfig-0.29.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a95d29e0cc998580b39222b43e955be104fd2c0b5f8d3c8c04fe83aea58da7ed",
"md5": "fd701050a3098fb22522d96bc526e064",
"sha256": "3221eceee5ce2cbfbb2e29ed26b4111ec6af25866d78b3750c72b54313ec609b"
},
"downloads": -1,
"filename": "tcconfig-0.29.1.tar.gz",
"has_sig": false,
"md5_digest": "fd701050a3098fb22522d96bc526e064",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 189894,
"upload_time": "2024-07-28T14:00:09",
"upload_time_iso_8601": "2024-07-28T14:00:09.944931Z",
"url": "https://files.pythonhosted.org/packages/a9/5d/29e0cc998580b39222b43e955be104fd2c0b5f8d3c8c04fe83aea58da7ed/tcconfig-0.29.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-28 14:00:09",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thombashi",
"github_project": "tcconfig",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "tcconfig"
}