h-phil / i2pd-testnet-kubernetes

i2pd test network in kubernetes
MIT License
1 stars 1 forks source link

Traffic Control & Queuing Disciplines #4

Closed h-phil closed 8 months ago

h-phil commented 8 months ago

Extend the documentation to include traffic control options that for example allow the simulation of network latency and packet drop.

h-phil commented 8 months ago

Before (trafficControl.enabled: false)

$ kubectl -n i2pd exec -ti i2pd-1-i2pd-chart-7b569f77b6-xzpbm -- /bin/sh
/ $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
3: eth0@if797: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1450 qdisc noqueue state UP qlen 1000
    link/ether 3e:43:38:b7:26:3e brd ff:ff:ff:ff:ff:ff
    inet 123.8.0.2/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::3c43:38ff:feb7:263e/64 scope link
       valid_lft forever preferred_lft forever

/ $ ping 123.8.0.3
PING 123.8.0.3 (123.8.0.3): 56 data bytes
64 bytes from 123.8.0.3: seq=0 ttl=42 time=0.162 ms
64 bytes from 123.8.0.3: seq=1 ttl=42 time=0.083 ms
64 bytes from 123.8.0.3: seq=2 ttl=42 time=0.142 ms
64 bytes from 123.8.0.3: seq=3 ttl=42 time=0.090 ms
64 bytes from 123.8.0.3: seq=4 ttl=42 time=0.088 ms
64 bytes from 123.8.0.3: seq=5 ttl=42 time=0.097 ms
64 bytes from 123.8.0.3: seq=6 ttl=42 time=0.082 ms
64 bytes from 123.8.0.3: seq=7 ttl=42 time=0.095 ms
64 bytes from 123.8.0.3: seq=8 ttl=42 time=0.094 ms
^C
--- 123.8.0.3 ping statistics ---
9 packets transmitted, 9 packets received, 0% packet loss
round-trip min/avg/max = 0.082/0.103/0.162 ms

After (trafficControl.enabled: true)

With the following values:

trafficControl:
  enabled: true
  image:
    # see https://github.com/h-phil/alpine-iproute2
    repository: hphil/alpine-iproute2
    tag: latest
  init: |
    #!/bin/sh
    set -ex
    # delay of 40+-20ms (normal distribution) per pod
    # 0.1% loss with higher successive probablity (packet burst lossess)
    tc qdisc add dev eth0 root netem delay 40ms 20ms distribution normal loss 0.1% 25%

Before every i2pd container there should have been a tc init container that changed the traffic control options:

kubectl -n i2pd logs i2pd-1-i2pd-chart-6c54c454d9-9qnw9 tc
+ tc qdisc add dev eth0 root netem delay 40ms 20ms distribution normal loss '0.1%' '25%'

The ping latency increased:

kubectl -n i2pd exec -ti i2pd-1-i2pd-chart-6c54c454d9-9qnw9 -- /bin/sh
Defaulted container "i2pd-chart" out of: i2pd-chart, tc (init)
/ $ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
3: eth0@if1463: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1450 qdisc netem state UP qlen 1000
    link/ether c2:06:12:45:15:4a brd ff:ff:ff:ff:ff:ff
    inet 123.8.0.2/32 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::c006:12ff:fe45:154a/64 scope link
       valid_lft forever preferred_lft forever

/ $ ping 123.8.0.3
PING 123.8.0.3 (123.8.0.3): 56 data bytes
64 bytes from 123.8.0.3: seq=0 ttl=42 time=53.711 ms
64 bytes from 123.8.0.3: seq=1 ttl=42 time=101.795 ms
64 bytes from 123.8.0.3: seq=2 ttl=42 time=113.479 ms
64 bytes from 123.8.0.3: seq=3 ttl=42 time=98.451 ms
64 bytes from 123.8.0.3: seq=4 ttl=42 time=72.133 ms
64 bytes from 123.8.0.3: seq=5 ttl=42 time=50.813 ms
64 bytes from 123.8.0.3: seq=6 ttl=42 time=119.052 ms
64 bytes from 123.8.0.3: seq=7 ttl=42 time=57.723 ms
64 bytes from 123.8.0.3: seq=8 ttl=42 time=108.878 ms
64 bytes from 123.8.0.3: seq=9 ttl=42 time=80.346 ms
64 bytes from 123.8.0.3: seq=10 ttl=42 time=85.890 ms
64 bytes from 123.8.0.3: seq=11 ttl=42 time=71.723 ms
64 bytes from 123.8.0.3: seq=12 ttl=42 time=102.190 ms
64 bytes from 123.8.0.3: seq=13 ttl=42 time=97.972 ms
64 bytes from 123.8.0.3: seq=14 ttl=42 time=120.178 ms
64 bytes from 123.8.0.3: seq=15 ttl=42 time=65.768 ms
^C
--- 123.8.0.3 ping statistics ---
16 packets transmitted, 16 packets received, 0% packet loss
round-trip min/avg/max = 50.813/87.506/120.178 ms

Note

After this change I have also seen (for the first time) a tunnel creation success rate below 100%.