From: Razvan Deaconescu Date: Mon, 28 Feb 2011 15:22:04 +0000 (+0200) Subject: Utils-eurocon: inactive timespan for session X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=55495e9b4cfaacd2516cde9af6bc00a3269f7513;p=p2p-testing-infrastructure.git Utils-eurocon: inactive timespan for session check download/upload speed evolution --- diff --git a/Utils/test-socket-signal/test/process/get_inactive_timespan b/Utils/test-socket-signal/test/process/get_inactive_timespan new file mode 100755 index 0000000..0d7a55c --- /dev/null +++ b/Utils/test-socket-signal/test/process/get_inactive_timespan @@ -0,0 +1,52 @@ +#!/usr/bin/awk -f + +# +# find timespan of inactivity +# +# provide evolution of speed in a column at standard input +# +# start point is when speed is lower with MAX_SPEED/RATE than maximum speed +# that far; stop point is when download speed is higher with MAX_SPEED/RATE +# than minimium speed that far +# + +BEGIN { + MAX_SPEED = 100.0; + RATE = 0.15; + THRESHOLD = MAX_SPEED * RATE; + STATE_NO_STATE = 0; + STATE_GET_INACTIVITY = 1; + STATE_GET_ACTIVITY = 2; + + state = STATE_GET_INACTIVITY; + max_speed_so_far = 0; + min_speed_so_far = MAX_SPEED; + counter = 0; + start_time = 0; + stop_time = 0; +} + +{ + curr_speed = $1; + if (state == STATE_GET_INACTIVITY) { + if (curr_speed > max_speed_so_far) + max_speed_so_far = curr_speed; + else if (curr_speed < max_speed_so_far - THRESHOLD) { + start = counter; + state = STATE_GET_ACTIVITY; + } + } + else if (state == STATE_GET_ACTIVITY) { + if (curr_speed < min_speed_so_far) + min_speed_so_far = curr_speed; + else if (curr_speed > min_speed_so_far + THRESHOLD) { + stop = counter; + state = STATE_NOSTATE; + } + } + counter++; +} + +END { + printf "start: %d, stop: %d, diff: %d\n", start, stop, stop - start; +}