
غلاف لأمر 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 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
إعداد قواعد تشكيل حركة المرور ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ تطبيق قواعد تشكيل حركة المرور على شبكات محددة بسهولة:
المعلمات المتاحة ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ يمكن ضبط المعلمات التالية على واجهات الشبكة:
[G/M/K bps][ميكروثانية / ميلي ثانية / ثوانٍ / دقائق][%][%][%][%][COUNT]الأهداف ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
eth0veth المقابلة لحاوية).. image:: docs/gif/tcset_example.gif
tcset)tcset هو أمر لإضافة قاعدة تحكم في حركة المرور إلى واجهة شبكة (جهاز).
مثال: تعيين حد لعرض النطاق الترددي يصل إلى 100 كيلوبت في الثانية ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. 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
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
قم بتنفيذ tcconfig مع الخيار --docker على مضيف Docker:
.. code-block:: console
# tcset <اسم الحاوية أو المعرف> --docker ...
يمكنك استخدام الخيارين --src-container / --dst-container لتحديد حاوية المصدر / الوجهة.
تعيين التحكم في حركة المرور داخل حاوية Docker
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
تحتاج إلى تشغيل حاوية مع الخيار --cap-add NET_ADMIN
إذا كنت ترغب في تعيين قاعدة tc داخل حاوية:
.. code-block:: console
docker run -d --cap-add NET_ADMIN -t <صورة Docker>
يمكن الحصول على صورة حاوية تتضمن tcconfig مدمجًا من https://hub.docker.com/r/thombashi/tcconfig/
tcdel)tcdel هو أمر لحذف قواعد تشكيل حركة المرور من واجهة شبكة (جهاز).
مثال: حذف التحكم في حركة المرور لـ eth0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
يمكنك حذف جميع قواعد التشكيل لـ eth0 باستخدام الخيار -a / --all:
.. 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: 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)
كن راعياً <https://github.com/sponsors/thombashi>__