
tc 명령어 래퍼입니다. 네트워크 인터페이스/도커 컨테이너(veth)에 대한 네트워크 대역폭, 지연 시간, 패킷 손실, 패킷 손상 등의 트래픽 제어를 쉽게 설정할 수 있습니다.
.. contents:: tcconfig :backlinks: top :depth: 2
tcconfig <https://github.com/thombashi/tcconfig>__ 는 tc 명령어의 래퍼입니다. 네트워크 인터페이스/Docker 컨테이너(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 패키지 버전
.. |Supported Python ver| image:: https://img.shields.io/pypi/pyversions/tcconfig.svg :target: https://pypi.org/project/tcconfig :alt: 지원되는 Python 버전
.. |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: 테스트 CI 상태
.. |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: 빌드 CI 상태
트래픽 셰이핑 규칙 설정 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 특정 네트워크에 트래픽 셰이핑 규칙을 쉽게 적용할 수 있습니다:
사용 가능한 매개변수 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 네트워크 인터페이스에 다음 매개변수를 설정할 수 있습니다:
[G/M/K bps][마이크로초/밀리초/초/분][%][%][%][%][COUNT]대상 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
eth0veth).. image:: docs/gif/tcset_example.gif
tcset 명령어)tcset 은 네트워크 인터페이스(장치)에 트래픽 제어 규칙을 추가하는 명령어입니다.
예: 대역폭을 최대 100Kbps로 제한 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: console
# tcset eth0 --rate 100Kbps
예: 네트워크 지연 설정 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 지연 시간을 지정하려면 시간 단위(예: us/sec/min 등)를 사용할 수 있습니다.
네트워크 지연 100밀리초 설정 ''''''''''''''''''''''''''''''''''''''''''''''''''' .. code-block:: console
# tcset eth0 --delay 100ms
네트워크 지연 10초 설정 ''''''''''''''''''''''''''''''''''''''''''''''''''' .. code-block:: console
# tcset eth0 --delay 10sec
네트워크 지연 0.5분(30초) 설정 ''''''''''''''''''''''''''''''''''''''''''''''''''' .. code-block:: console
# tcset eth0 --delay 0.5min
다음과 같은 시간 단위도 사용할 수 있습니다:
.. table::
+------------+----------------------------------------------------------+
| 단위 | 사용 가능한 지정자 (문자열) |
+============+==========================================================+
|시간 |``h``/``hour``/``hours`` |
+------------+----------------------------------------------------------+
|분 |``m``/``min``/``mins``/``minute``/``minutes`` |
+------------+----------------------------------------------------------+
|초 |``s``/``sec``/``secs``/``second``/``seconds`` |
+------------+----------------------------------------------------------+
|밀리초 |``ms``/``msec``/``msecs``/``millisecond``/``milliseconds``|
+------------+----------------------------------------------------------+
|마이크로초 |``us``/``usec``/``usecs``/``microsecond``/``microseconds``|
+------------+----------------------------------------------------------+
예: 0.1% 패킷 손실 설정 ^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: console
# tcset eth0 --loss 0.1%
예: 위의 모든 설정을 한 번에 적용 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: console
# tcset eth0 --rate 100Kbps --delay 100ms --loss 0.1%
예: 트래픽 제어 IP 주소 지정 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: console
# tcset eth0 --delay 100ms --network 192.168.0.10
예: 트래픽 제어의 IP 네트워크 및 포트 지정 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. code-block:: console
# tcset eth0 --delay 100ms --network 192.168.0.0/24 --port 80
Docker 컨테이너에 트래픽 제어 설정
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Docker 호스트에서 --docker 옵션과 함께 tcconfig 를 실행하세요:
.. code-block:: console
# tcset <컨테이너 이름 또는 ID> --docker ...
--src-container/--dst-container 옵션을 사용하여 발신/수신 컨테이너를 지정할 수 있습니다.
Docker 컨테이너 내부에서 트래픽 제어 설정
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
컨테이너 내부에서 tc 규칙을 설정하려면 --cap-add NET_ADMIN 옵션을 사용하여 컨테이너를 실행해야 합니다:
.. code-block:: console
docker run -d --cap-add NET_ADMIN -t <도커 이미지>
tcconfig가 내장된 컨테이너 이미지는 https://hub.docker.com/r/thombashi/tcconfig/ 에서 사용할 수 있습니다.
tcdel 명령어)tcdel 은 네트워크 인터페이스(장치)에서 트래픽 셰이핑 규칙을 삭제하는 명령어입니다.
예: eth0 의 트래픽 제어 삭제
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-a/--all 옵션을 사용하여 eth0 의 모든 셰이핑 규칙을 삭제할 수 있습니다:
.. code-block:: console
# tcdel eth0 --all
tcshow 명령어)tcshow 는 네트워크 인터페이스의 현재 트래픽 제어 설정을 표시하는 명령어입니다.
예 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. 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"
}
}
}
}
더 많은 예제는 다음에서 확인할 수 있습니다: https://tcconfig.rtfd.io/en/latest/pages/usage/index.html
tcconfig 는 PyPI <https://pypi.python.org/pypi>__ 에서
pip <https://pip.pypa.io/en/stable/installing/>__ (Python 패키지 관리자) 명령어로 설치할 수 있습니다.
.. code:: console
sudo pip install tcconfig
.. code:: console
curl -sSL https://raw.githubusercontent.com/thombashi/tcconfig/master/scripts/installer.sh | sudo bash
Python 패키지 의존성 (자동 설치됨) <https://github.com/thombashi/tcconfig/network/dependencies>__tc 명령어에 필요:
Ubuntu/Debian: iproute2Fedora/RHEL: iproute-tc--iptables 옵션을 사용할 때 필요:
iptablessch_netemPygments <http://pygments.org/>__https://tcconfig.rtfd.io/en/latest/pages/troubleshooting.html
https://hub.docker.com/r/thombashi/tcconfig/
|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: 전 후원자: Charles Becker (chasbecker) .. |shiguredo| image:: https://avatars.githubusercontent.com/u/2549434?s=48&v=4 :target: https://github.com/shiguredo :alt: 전 후원자: 時雨堂 (shiguredo) .. |b4tman| image:: https://avatars.githubusercontent.com/u/3658062?s=48&v=4 :target: https://github.com/b4tman :alt: 일회성: Dmitry Belyaev (b4tman) .. |Arturi0| image:: https://avatars.githubusercontent.com/u/46711571?s=48&u=57687c0e02d5d6e8eeaf9177f7b7af4c9f275eb5&v=4 :target: https://github.com/Arturi0 :alt: 일회성: Arturi0 .. |github| image:: https://avatars.githubusercontent.com/u/9919?s=48&v=4 :target: https://github.com/github :alt: 일회성: GitHub (github)
후원자가 되기 <https://github.com/sponsors/thombashi>__