
내 이해는 netfilter의 hashlimit 모듈이 누출 버킷 알고리즘을 구현해야 한다는 것입니다... 저는 아래 iptables 구성을 사용하고 있습니다
iptables -A INPUT -s 207.[...] -m hashlimit --hashlimit-above 34722b/s \
--hashlimit-burst 600m --hashlimit-name hashlimitTable1 \
--hashlimit-htable-expire 604800000 -j DROP
이는 700MB의 단일 대규모 다운로드에 완벽하게 작동하지만 다운로드가 완료된 후 3시간을 기다린 다음 다른 다운로드를 수행하면 규칙은 여전히 즉시 일치하고(버스트 없음) 대역폭을 ~34kB/s로 제한합니다.
cat /proc/net/ipt_hashlimit/hashlimitTable1
첫 번째 대용량 다운로드 후 프로그램을 검토합니다.
This seems to represent the burst "bucket" size
and it does go down and reach 0 after 600 MB
have been downloaded, but it never increases
no matter how long I wait.
|
|
604555 0.0.0.0:0->0.0.0.0:0 4194304000 0 1931967
hashlimit는 "leaky bucket" 알고리즘을 구현하지 않습니까? 아니면 내 구성이 잘못되었나요?
~에서man 8 iptables-extensions|grep -e 'hashlimit-burst amount' -A 7
--hashlimit-burst amount
Maximum initial number of packets to match: this number gets
recharged by one every time the limit specified above is not
reached, up to this number; the default is 5. When byte-based
rate matching is requested, this option specifies the amount of
bytes that can exceed the given rate. This option should be
used with caution -- if the entry expires, the burst value is
reset too.
이는 예상되는 동작이 정확하다는 것을 의미하지만 반대 관점에서 규칙이 일치하는지 확인해야 할 수도 있습니다.
iptables -A INPUT -s 207.[...] -m hashlimit --hashlimit-upto 34722b/s \
--hashlimit-burst 600m --hashlimit-name hashlimitTable1 \
--hashlimit-htable-expire 604800000 -j ACCEPT;
iptables -A INPUT -s 207.[...] -j DROP;
불행하게도 이로 인해 19분 이상 1KiBps의 터무니없이 낮은 속도로 다운로드하는 경우에도 정확히 동일한 관찰된 동작이 발생 wget --limit-rate=1024 http://207.[...]/testFile.bin
하지만 최대 토큰 수는 0 이상으로 증가하지 않으며 다운로드 없이 추가 시간을 기다린 후에도 대역폭은 여전히 제한됩니다. ~34KBps로...
만료 시간, 가비지 수집 간격, htable-size, htable-max 등은 문제에 아무런 영향을 미치지 않는 것으로 확인되었습니다. 만료 시간을 10초처럼 매우 짧게 설정하면 당연히 버스트가 재설정되지만 결과적으로 평균 대역폭을 위반하게 됩니다.