Debian Codegraph @

src/setsctp

raw
1 #!/bin/sh
2 #
3 # Network Performance Meter
4 # Copyright (C) 2009-2024 by Thomas Dreibholz
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #
19 # Contact: [email protected]
20 #
21
22 if [ $# -lt 1 ] ; then
23 echo >&2 "Usage: $0 [cmt off|normal|rp] [dac on|off] [nrsack on|off] [bufferSplitting none|senderOnly|reeiverOnly|bothSides] [initialCwnd SIZE_IN_MTU] [cwndMaxBurst on|off"
24 exit 1
25 fi
26
27
28 # ====== Get parameters =====================================================
29 CMT=0
30 DAC=0
31 NRSACK=0
32 BUFFERSPLITTING=0
33 INITIAL_CWND=3
34 CWND_MAXBURST=0
35
36 while [ "$1" != "" ] ; do
37 if [ "$1" = "cmt" ] ; then
38 if [ "$2" = "off" ] ; then
39 CMT=0
40 elif [ "$2" = "cmt" -o "$2" = "normal" ] ; then
41 CMT=1
42 elif [ "$2" = "cmtrpv1" -o "$2" = "rp" ] ; then
43 CMT=2
44 elif [ "$2" = "cmtrpv2" ] ; then
45 CMT=3
46 elif [ "$2" = "like-mptcp" -o "$2" = "mptcp-like" -o "$2" = "mptcp" ] ; then
47 CMT=4
48 elif [ $2 -ge 2 -o $2 -lt 256 ] ; then
49 CMT=$2
50 else
51 echo >&2 "ERROR: Bad setting for cmt!"
52 exit 1
53 fi
54 shift ; shift
55
56 elif [ "$1" = "dac" ] ; then
57 if [ "$2" = "on" -o "$2" = "true" ] ; then
58 DAC=1
59 elif [ "$2" = "off" -o "$2" = "false" ] ; then
60 DAC=0
61 else
62 echo >&2 "ERROR: Bad setting for dac!"
63 exit 1
64 fi
65 shift ; shift
66
67 elif [ "$1" = "nrsack" ] ; then
68 if [ "$2" = "on" -o "$2" = "true" ] ; then
69 NRSACK=1
70 elif [ "$2" = "off" -o "$2" = "false" ] ; then
71 NRSACK=0
72 else
73 echo >&2 "ERROR: Bad setting for nrsack!"
74 exit 1
75 fi
76 shift ; shift
77
78 elif [ "$1" = "cwndMaxBurst" ] ; then
79 if [ "$2" = "on" -o "$2" = "true" ] ; then
80 CWND_MAXBURST=1
81 elif [ "$2" = "off" -o "$2" = "false" ] ; then
82 CWND_MAXBURST=0
83 else
84 echo >&2 "ERROR: Bad setting for cwndMaxBurst!"
85 exit 1
86 fi
87 shift ; shift
88
89 elif [ "$1" = "bufferSplitting" ] ; then
90 if [ "$2" = "none" ] ; then
91 BUFFERSPLITTING=0
92 elif [ "$2" = "senderOnly" ] ; then
93 BUFFERSPLITTING=1
94 elif [ "$2" = "receiverOnly" ] ; then
95 BUFFERSPLITTING=2
96 elif [ "$2" = "bothSides" ] ; then
97 BUFFERSPLITTING=3
98 else
99 echo >&2 "ERROR: Bad setting for bufferSplitting!"
100 exit 1
101 fi
102 shift ; shift
103
104 elif [ "$1" = "initialCwnd" ] ; then
105 INITIAL_CWND=$2
106 shift ; shift
107
108 else
109 echo >&2 "ERROR: Unknown setting $1!"
110 exit 1
111 fi
112 done
113
114
115 echo "SCTP Configuration:"
116 echo " - CMT: $CMT"
117 echo " - DAC: $DAC"
118 echo " - NRSACK: $NRSACK"
119 echo " - BUFFERSPLITTING: $BUFFERSPLITTING"
120 echo " - CWND_MAXBURST: $CWND_MAXBURST"
121
122
123 success=1
124 SYSTEM=`uname`
125 # ====== FreeBSD QoS setup ==================================================
126 if [ "$SYSTEM" = "FreeBSD" ] ; then
127 /sbin/sysctl net.inet.sctp.cmt_on_off=$CMT >/dev/null || success=0
128 /sbin/sysctl net.inet.sctp.cmt_use_dac=$DAC >/dev/null || success=0
129 /sbin/sysctl net.inet.sctp.nr_sack_on_off=$NRSACK >/dev/null || success=0
130 /sbin/sysctl net.inet.sctp.buffer_splitting=$BUFFERSPLITTING >/dev/null || success=0
131 /sbin/sysctl net.inet.sctp.initial_cwnd=$INITIAL_CWND >/dev/null || success=0
132 /sbin/sysctl net.inet.sctp.cwnd_maxburst=$CWND_MAXBURST >/dev/null || success=0
133 /sbin/sysctl kern.ipc.maxsockbuf=1000050000 >/dev/null || success=0 # This is the absolute socket buffer limit!
134 # /sbin/sysctl net.inet.sctp.sendspace=10000000 >/dev/null || success=0 # SCTP limit, seems to need full pages!
135 # /sbin/sysctl net.inet.sctp.recvspace=10000000 >/dev/null || success=0 # SCTP limit, seems to need full pages!
136
137 # ====== Linux ==============================================================
138 elif [ "$SYSTEM" = "Linux" ] ; then
139 # echo >&2 "###### WARNING! setsctp does not usefully support Linux yet ######"
140
141 modprobe sctp
142
143 # /sbin/sysctl net.sctp.auth_enable=1
144 # /sbin/sysctl net.sctp.addip_enable=1
145
146 # ====== Other systems ======================================================
147 else
148 echo >&2 "ERROR: Unsupported system $SYSTEM!"
149 exit 1
150 fi
151
152
153 # ====== Check whether SCTP configuration has been successful ===============
154 if [ $success -ne 1 ] ; then
155 echo >&2 "ERROR: setsctp has failed to configure sysctl settings!"
156 echo >&2 "Command on `hostname`: $0 $@"
157 exit 1
158 fi