All Projects → thombashi → Tcconfig

thombashi / Tcconfig

Licence: mit
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).

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Tcconfig

Pentestkit
Useful tools and scripts during Penetration Testing engagements
Stars: ✭ 463 (-9.22%)
Mutual labels:  network
Gofamily
🔥 大厂 BAT 面试高频知识点,后端技术体系。包含了 C GO Python, 网络,Redis ,MySQL ,消息队列 ,高并发,微服务,缓存,操作系统,算法,LeetCode 刷题等知识
Stars: ✭ 474 (-7.06%)
Mutual labels:  network
Imgui Go
Go wrapper library for "Dear ImGui" (https://github.com/ocornut/imgui)
Stars: ✭ 499 (-2.16%)
Mutual labels:  wrapper
Awesome Local Global Descriptor
My personal note about local and global descriptor
Stars: ✭ 466 (-8.63%)
Mutual labels:  network
One Nio
Unconventional I/O library for Java
Stars: ✭ 469 (-8.04%)
Mutual labels:  network
Gns3 Server
GNS3 server
Stars: ✭ 477 (-6.47%)
Mutual labels:  network
Alfred
alfred-py: A deep learning utility library for **human**, more detail about the usage of lib to: https://zhuanlan.zhihu.com/p/341446046
Stars: ✭ 460 (-9.8%)
Mutual labels:  network
Materialdrawerkt
A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library.
Stars: ✭ 508 (-0.39%)
Mutual labels:  wrapper
Flapigen Rs
Tool for connecting programs or libraries written in Rust with other languages
Stars: ✭ 473 (-7.25%)
Mutual labels:  wrapper
Qtexamples
Qt 的 GUI 控件使用和网络;DTK 重绘控件方式的框架架构解析;Qt 原理/运行机制理解;QtCrator 使用和一些小技巧;系列文章教程
Stars: ✭ 494 (-3.14%)
Mutual labels:  network
Seq2seqchatbots
A wrapper around tensor2tensor to flexibly train, interact, and generate data for neural chatbots.
Stars: ✭ 466 (-8.63%)
Mutual labels:  wrapper
Goffmpeg
FFMPEG wrapper written in GO
Stars: ✭ 469 (-8.04%)
Mutual labels:  wrapper
Turbo
Turbo is a framework built for LuaJIT 2 to simplify the task of building fast and scalable network applications. It uses a event-driven, non-blocking, no thread design to deliver excellent performance and minimal footprint to high-load applications while also providing excellent support for embedded uses.
Stars: ✭ 480 (-5.88%)
Mutual labels:  network
Netcat
NetCat for Windows
Stars: ✭ 463 (-9.22%)
Mutual labels:  network
React Adaptive Hooks
Deliver experiences best suited to a user's device and network constraints
Stars: ✭ 4,750 (+831.37%)
Mutual labels:  network
Dxwrapper
Fixes compatibility issues with older games running on Windows 10 by wrapping DirectX dlls. Also allows loading custom libraries with the file extension .asi into game processes.
Stars: ✭ 460 (-9.8%)
Mutual labels:  wrapper
Rust Sloth
A 3D software rasterizer... for the terminal!
Stars: ✭ 478 (-6.27%)
Mutual labels:  cli-app
Rxfirebase
Rxjava 2.0 wrapper on Google's Android Firebase library.
Stars: ✭ 509 (-0.2%)
Mutual labels:  wrapper
Katanaframework
The New Hacking Framework
Stars: ✭ 502 (-1.57%)
Mutual labels:  network
Fatt
FATT /fingerprintAllTheThings - a pyshark based script for extracting network metadata and fingerprints from pcap files and live network traffic
Stars: ✭ 490 (-3.92%)
Mutual labels:  network

.. 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).

.. image:: https://badge.fury.io/py/tcconfig.svg :target: https://badge.fury.io/py/tcconfig :alt: PyPI package version

.. image:: https://img.shields.io/pypi/pyversions/tcconfig.svg :target: https://pypi.org/project/tcconfig :alt: Supported Python versions

.. image:: https://travis-ci.org/thombashi/tcconfig.svg?branch=master :target: https://travis-ci.org/thombashi/tcconfig :alt: Linux CI status

.. image:: https://img.shields.io/github/stars/thombashi/tcconfig.svg?style=social&label=Star :target: https://github.com/thombashi/tcconfig :alt: GitHub stars

Traffic control

Setup traffic shaping rules ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Easy to apply traffic shaping rules to specific network:

  • 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 [%]

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 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 network latency ''''''''''''''''''''''''''''''''''''''''''''''''''' .. code-block:: console

# tcset eth0 --delay 100ms

Set 10 seconds 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 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 source/destination container.

Set traffic control within a docker container ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You need to run a container with --cap-add NET_ADMIN option if you 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.5+
  • 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 to when you use --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

.. image:: https://avatars0.githubusercontent.com/u/44389260?s=48&u=6da7176e51ae2654bcfd22564772ef8a3bb22318&v=4 :target: https://github.com/chasbecker :alt: Charles Becker (chasbecker)

Become a sponsor <https://github.com/sponsors/thombashi>__

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].