dctcp01.sh revision 8d61a03c86ab73f98ef4cb54d33e0b55fb8b3462
1#!/bin/sh 2# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 3# 4# This program is free software; you can redistribute it and/or 5# modify it under the terms of the GNU General Public License as 6# published by the Free Software Foundation; either version 2 of 7# the License, or (at your option) any later version. 8# 9# This program is distributed in the hope that it would be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU General Public License for more details. 13# 14# You should have received a copy of the GNU General Public License 15# along with this program. If not, see <http://www.gnu.org/licenses/>. 16# 17# Author: Alexey Kodanev <alexey.kodanev@oracle.com> 18 19TCID=dctcp01 20TST_TOTAL=1 21TST_CLEANUP="cleanup" 22def_alg="cubic" 23prev_alg= 24 25. test_net.sh 26 27set_cong_alg() 28{ 29 local alg=$1 30 tst_resm TINFO "setting $alg" 31 32 ROD sysctl -q -w net.ipv4.tcp_congestion_control=$alg 33 tst_rhost_run -s -c "sysctl -q -w net.ipv4.tcp_congestion_control=$alg" 34} 35 36cleanup() 37{ 38 if [ "$prev_cong_ctl" ]; then 39 sysctl -q -w net.ipv4.tcp_congestion_control=$prev_alg 40 tst_rhost_run -c \ 41 "sysctl -q -w net.ipv4.tcp_congestion_control=$prev_alg" 42 fi 43 tst_rmdir 44 tc qdisc del dev $(tst_iface) root netem loss 0.03% ecn 45} 46 47setup() 48{ 49 if tst_kvcmp -lt "3.18"; then 50 tst_brkm TCONF "test requires kernel 3.18 or newer" 51 fi 52 53 tst_require_root 54 tst_check_cmds ip sysctl tc 55 56 tst_resm TINFO "emulate congestion with packet loss 0.03% and ECN" 57 tc qdisc add dev $(tst_iface) root netem loss 0.03% ecn > /dev/null 2>&1 58 if [ $? -ne 0 ]; then 59 tst_brkm TCONF "netem doesn't support ECN" 60 fi 61 62 tst_tmpdir 63 64 prev_alg="$(cat /proc/sys/net/ipv4/tcp_congestion_control)" 65} 66 67test_run() 68{ 69 tst_resm TINFO "compare '$def_alg' and 'dctcp' congestion alg. results" 70 71 set_cong_alg "$def_alg" 72 73 tst_netload $(tst_ipaddr rhost) tfo_res TFO 74 if [ $? -ne 0 ]; then 75 tst_resm TFAIL "test with '$def_alg' has failed" 76 return 77 fi 78 local res0="$(cat tfo_res)" 79 tst_resm TINFO "$def_alg time '$res0' ms" 80 81 set_cong_alg "dctcp" 82 83 tst_netload $(tst_ipaddr rhost) tfo_res TFO 84 if [ $? -ne 0 ]; then 85 tst_resm TFAIL "test with 'dctcp' has failed" 86 return 87 fi 88 local res1="$(cat tfo_res)" 89 tst_resm TINFO "dctcp time '$res1' ms" 90 91 local per=$(( $res0 * 100 / $res1 - 100 )) 92 93 if [ "$per" -lt "10" ]; then 94 tst_resm TFAIL "dctcp performance $per %" 95 else 96 tst_resm TPASS "dctcp performance $per %" 97 fi 98} 99 100setup 101 102test_run 103 104tst_exit 105