Skip to content
This repository has been archived by the owner on Mar 28, 2018. It is now read-only.

Commit

Permalink
Merge pull request #800 from grahamwhaley/20170406_net_metric_fixes
Browse files Browse the repository at this point in the history
20170406 net metric fixes
  • Loading branch information
amshinde authored Apr 7, 2017
2 parents fb2deac + 231f5dd commit cf36dac
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions tests/metrics/network/network-metrics.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Description:
# Test inter (docker<->docker) network bandwidths and jitters
# using iperf2

SCRIPT_PATH=$(dirname "$(readlink -f "$0")")

Expand All @@ -36,62 +40,57 @@ function setup {

# This script will perform all the measurements using a local setup

# Test single TCP docker->docker iperf bandwidth
function bandwidth {
setup
bandwidth_result=$(mktemp)
$DOCKER_EXE run -d --name=iperf-server ${image} bash -c "iperf -p ${port} -s" > /dev/null && \
server_address=`$DOCKER_EXE inspect --format "{{.NetworkSettings.IPAddress}}" $($DOCKER_EXE ps -ql)` && \
server_address=`$DOCKER_EXE inspect --format "{{.NetworkSettings.IPAddress}}" $($DOCKER_EXE ps -ql)` && \
$DOCKER_EXE run -ti --rm --name=iperf-client ${image} bash -c "iperf -c ${server_address} -t ${time}" > "$bandwidth_result"
total_bandwidth=`cat $bandwidth_result | tail -1 | awk '{print $(NF-1), $NF}'`
$DOCKER_EXE rm -f iperf-server > /dev/null
rm -f $bandwidth_result
}

# Test single UDP docker->docker jitter
function jitter {
setup
jitter_result=$(mktemp)
$DOCKER_EXE run -d --name=iperf-server ${image} bash -c "iperf -p ${port} -u -s" > /dev/null && \
server_address=`$DOCKER_EXE inspect --format "{{.NetworkSettings.IPAddress}}" $($DOCKER_EXE ps -ql)` && \
server_address=`$DOCKER_EXE inspect --format "{{.NetworkSettings.IPAddress}}" $($DOCKER_EXE ps -ql)` && \
$DOCKER_EXE run -ti --rm --name=iperf-client ${image} bash -c "iperf -c ${server_address} -u -t ${time}" > "$jitter_result"
total_jitter=`cat $jitter_result | tail -1 | awk '{print $(NF-4), $(NF-3)}'`
total_jitter=`cat $jitter_result | tail -1 | awk '{print $(NF-4), $(NF-3)}'`
$DOCKER_EXE rm -f iperf-server > /dev/null
rm -f $jitter_result
}

# Test TCP docker->docker bandwidth with multiple network connections (parallelism)
function bandwidth_multiple_tcp_connections {
setup
number_tcp_connections=8
multiple_tcp_result=$(mktemp)
$DOCKER_EXE run -d --name=iperf-server ${image} bash -c "iperf -p ${port} -s" > /dev/null && \
server_address=`$DOCKER_EXE inspect --format "{{.NetworkSettings.IPAddress}}" $($DOCKER_EXE ps -ql)` && \
$DOCKER_EXE run -ti --rm --name=iperf-client ${image} bash -c "iperf -c ${server_address} -P ${multiple_tcp_result} -t ${time}" > "$multiple_tcp_result"
server_address=`$DOCKER_EXE inspect --format "{{.NetworkSettings.IPAddress}}" $($DOCKER_EXE ps -ql)` && \
$DOCKER_EXE run -ti --rm --name=iperf-client ${image} bash -c "iperf -c ${server_address} -P ${number_tcp_connections} -t ${time}" > "$multiple_tcp_result"
total_multiple_tcp=`cat $multiple_tcp_result | tail -1 | awk '{print $(NF-1), $NF}'`
$DOCKER_EXE rm -f iperf-server > /dev/null
rm -f $multiple_tcp_result
}

function bidirectional_bandwidth_remote_local {
# Test TCP bandwidth bi-directionally (docker_iperf_server<->docker_iperf_client)
# Extract bandwidth results for both directions from the one test
function bidirectional_bandwidth_server_client {
setup
bidirectional_bandwidth_result=$(mktemp)
$DOCKER_EXE run -d --name=iperf-server ${image} bash -c "iperf -p ${port} -s" > /dev/null && \
server_address=`$DOCKER_EXE inspect --format "{{.NetworkSettings.IPAddress}}" $($DOCKER_EXE ps -ql)` && \
server_address=`$DOCKER_EXE inspect --format "{{.NetworkSettings.IPAddress}}" $($DOCKER_EXE ps -ql)` && \
$DOCKER_EXE run -ti --rm --name=iperf-client ${image} bash -c "iperf -c ${server_address} -d -t ${time}" > "$bidirectional_bandwidth_result"
total_bidirectional_bandwidth=`cat $bidirectional_bandwidth_result | tail -1 | awk '{print $(NF-1), $NF}'`
total_bidirectional_server_bandwidth=`cat $bidirectional_bandwidth_result | tail -1 | awk '{print $(NF-1), $NF}'`
total_bidirectional_client_bandwidth=`cat $bidirectional_bandwidth_result | tail -n 2 | head -1 | awk '{print $(NF-1), $NF}'`
$DOCKER_EXE rm -f iperf-server > /dev/null
rm -f $bidirectional_bandwidth_result
}

function bidirectional_bandwidth_local_remote {
setup
bidirectional_bandwidth_result=$(mktemp)
$DOCKER_EXE run -d --name=iperf-server ${image} bash -c "iperf -p ${port} -s" > /dev/null && \
server_address=`$DOCKER_EXE inspect --format "{{.NetworkSettings.IPAddress}}" $($DOCKER_EXE ps -ql)` && \
$DOCKER_EXE run -ti --rm --name=iperf-client ${image} bash -c "iperf -c ${server_address} -d -t ${time}" > "$bidirectional_bandwidth_result"
total_bidirectional_bandwidth=`cat $bidirectional_bandwidth_result | tail -n 2 | head -1 | awk '{print $(NF-1), $NF}'`
$DOCKER_EXE rm -f iperf-server > /dev/null
rm -f $bidirectional_bandwidth_result
}

bandwidth
echo "Network bandwidth is : $total_bandwidth"

Expand All @@ -101,8 +100,6 @@ echo "Network jitter is : $total_jitter"
bandwidth_multiple_tcp_connections
echo "Network bandwidth for multiple TCP connections is : $total_multiple_tcp"

bidirectional_bandwidth_remote_local
echo "Bi-directional network bandwidth is (remote to local host) : $total_bidirectional_bandwidth"

bidirectional_bandwidth_local_remote
echo "Bi-directional network bandwidth is (local to remote host) : $total_bidirectional_bandwidth"
bidirectional_bandwidth_server_client
echo "Bi-directional network bandwidth is (client to server) : $total_bidirectional_client_bandwidth"
echo "Bi-directional network bandwidth is (server to server) : $total_bidirectional_server_bandwidth"

0 comments on commit cf36dac

Please sign in to comment.