Closed zwri closed 8 years ago
Pushed to new branch wrightt:topic/ipfw_script commit https://github.com/wrightt/webpagetest/commit/b82f7020e7b3250b2aac086d003c73e31254fae9 Code review is on https://codereview.appspot.com/38470044/
Some changes re: original design:
Added "--arg" after start/stop command, e.g.:
myScript -s myDeviceId start --arg 1.2.3.4 --bwIn ...
Added "_arg" to stdout pattern, e.g.
stop_arg=foo_1.2.3.4
Done
The agent's traffic_shaper.js is currently hard-coded to use ipfw. Instead, the ipfw-specific details should be factored out into a user-modifiable script.
Current impl:
deviceAddr=1.2.3.4
, gets job with"bwIn":5000,"bwOut":1000,"latency":28,"plr":0
ipfw add 42 pipe 42 ip from any to 1.2.3.4 in
ipfw pipe 42 config bw 5000Kbit/s delay 14ms
, ...ipfw list
thenifw deiete
any rules/pipes that match our deviceAddrThe proposed solution is similar to our existing video_hdmi.js + "capture" script, but with more flexibility to support custom start/stop values:
--trafficShaper PATH
arg with default value "lib/traffic_shaper/ipfw.sh"--deviceAddr 1.2.3.4
to optional--trafficShaperArg 1.2.3.4
, where the value must match"^[^-\s]\S*$"
.-s myDeviceId start 1.2.3.4 --bwIn 5000 --bwOut 1000 --latency 28 --plr 0
, read and skip lines except an option line matching"^stop=([^-\s]\S*)$"
(e.g.stop=foo_1.2.3.4
), and return when it reads a line matching"^(.*\s)?started\."
(or EOF or timeout after 10 seconds).-s myDeviceId stop foo_1.2.3.4
, return when it reads a line matching"^(.*\s)?stopped\."
(or EOF or timeout after 10 seconds).One awkward issue is recreating the dynamic, unique pipeId assignment in Bash. At worst we can loop on
r=$RANDOM; nc -l -k $r
. I'll have to think about this a bit...