@@ -91,3 +91,167 @@ def repr_runtime(self):
91
91
92
92
#value_type = bool for some 'int' for others
93
93
94
+ class Udp (BaseOptionGroup ):
95
+
96
+ class mem (Option ): # rename total_mem or global_mem ?!
97
+ """!@brief Number of pages allowed for queueing by all UDP sockets.
98
+ udp_mem - vector of 3 INTEGERs: min, pressure, max
99
+
100
+ min: Below this number of pages UDP is not bothered about its
101
+ memory appetite. When amount of memory allocated by UDP exceeds
102
+ this number, UDP starts to moderate memory usage.
103
+ pressure: This value was introduced to follow format of tcp_mem.
104
+ max: Number of pages allowed for queueing by all UDP sockets.
105
+ Default is calculated at boot time from amount of available memory.
106
+ """
107
+ value_type = tuple # (min,pressure,max) or better {'min': 4000, 'max': 32000 } ?!
108
+ @classmethod
109
+ def supportedModes (cls ) -> OptionMode :
110
+ return OptionMode .BUILD_TIME | OptionMode .RUN_TIME
111
+ @classmethod
112
+ def default (cls ):
113
+ # just the values of my laptop
114
+ return (183768 , 245026 , 367536 )
115
+ def __repr__ (self ):
116
+ return f"net.ipv4.udp_mem={ self .value [0 ]} { self .value [1 ]} { self .value [2 ]} "
117
+ def repr_runtime (self ):
118
+ return self .__repr__ ()
119
+ def repr_build_time (self ):
120
+ return self .__repr__ ()
121
+
122
+
123
+ class rmem_min (Option ):
124
+ """!@brief Minimal size of receive buffer used by UDP sockets in moderation.
125
+ udp_rmem_min - INTEGER
126
+
127
+ Each UDP socket is able to use the size for receiving data, even if
128
+ total pages of UDP sockets exceed udp_mem pressure. The unit is byte.
129
+ Default: 4K
130
+ """
131
+ value_type = int
132
+ @classmethod
133
+ def supportedModes (cls ) -> OptionMode :
134
+ return OptionMode .BUILD_TIME | OptionMode .RUN_TIME
135
+ @classmethod
136
+ def default (cls ):
137
+ return 4000
138
+ def __repr__ (self ):
139
+ return f"net.ipv4.udp_rmem_min={ self .value } "
140
+ def repr_runtime (self ):
141
+ return self .__repr__ ()
142
+ def repr_build_time (self ):
143
+ return self .__repr__ ()
144
+
145
+ class wmem_min (Option ):
146
+ """!@brief Minimal size of send buffer used by UDP sockets in moderation.
147
+ udp_wmem_min - INTEGER
148
+ Each UDP socket is able to use the size for sending data, even if
149
+ total pages of UDP sockets exceed udp_mem pressure. The unit is byte.
150
+ Default: 4K
151
+ """
152
+ value_type = int
153
+ @classmethod
154
+ def supportedModes (cls ) -> OptionMode :
155
+ return OptionMode .BUILD_TIME | OptionMode .RUN_TIME
156
+ @classmethod
157
+ def default (cls ):
158
+ return 4000
159
+ def __repr__ (self ):
160
+ return f"net.ipv4.udp_wmem_min={ self .value } "
161
+ def repr_runtime (self ):
162
+ return self .__repr__ ()
163
+ def repr_build_time (self ):
164
+ return self .__repr__ ()
165
+
166
+ class Tcp (BaseOptionGroup ):
167
+
168
+ class mem (Option ):
169
+ """
170
+ tcp_mem - vector of 3 INTEGERs: min, pressure, max
171
+ min: below this number of pages TCP is not bothered about its
172
+ memory appetite.
173
+
174
+ pressure: when amount of memory allocated by TCP exceeds this number
175
+ of pages, TCP moderates its memory consumption and enters memory
176
+ pressure mode, which is exited when memory consumption falls
177
+ under "min".
178
+
179
+ max: number of pages allowed for queueing by all TCP sockets.
180
+
181
+ Defaults are calculated at boot time from amount of available
182
+ memory.
183
+ """
184
+ value_type = tuple # (min,pressure,max) or better {'min': 4000, 'max': 32000 } ?!
185
+ @classmethod
186
+ def supportedModes (cls ) -> OptionMode :
187
+ return OptionMode .BUILD_TIME | OptionMode .RUN_TIME
188
+ @classmethod
189
+ def default (cls ):
190
+ return (91884 , 122513 , 183768 )
191
+ def __repr__ (self ):
192
+ return f"net.ipv4.tcp_mem={ self .value [0 ]} { self .value [1 ]} { self .value [2 ]} "
193
+ def repr_runtime (self ):
194
+ return self .__repr__ ()
195
+ def repr_build_time (self ):
196
+ return self .__repr__ ()
197
+ class rmem (Option ):
198
+ """
199
+ tcp_rmem - vector of 3 INTEGERs: min, default, max
200
+ min: Minimal size of receive buffer used by TCP sockets.
201
+ It is guaranteed to each TCP socket, even under moderate memory
202
+ pressure.
203
+ Default: 4K
204
+
205
+ default: initial size of receive buffer used by TCP sockets.
206
+ This value overrides net.core.rmem_default used by other protocols.
207
+ Default: 87380 bytes. This value results in window of 65535 with
208
+ default setting of tcp_adv_win_scale and tcp_app_win:0 and a bit
209
+ less for default tcp_app_win. See below about these variables.
210
+
211
+ max: maximal size of receive buffer allowed for automatically
212
+ selected receiver buffers for TCP socket. This value does not override
213
+ net.core.rmem_max. Calling setsockopt() with SO_RCVBUF disables
214
+ automatic tuning of that socket's receive buffer size, in which
215
+ case this value is ignored.
216
+ Default: between 87380B and 6MB, depending on RAM size.
217
+ """
218
+ value_type = tuple # (min,default,max)
219
+ @classmethod
220
+ def supportedModes (cls ) -> OptionMode :
221
+ return OptionMode .BUILD_TIME | OptionMode .RUN_TIME
222
+ @classmethod
223
+ def default (cls ):
224
+ # (4096, 87380,)
225
+ return (4096 , 131072 , 6291456 )# again my laptop's values
226
+ def __repr__ (self ):
227
+ return f"net.ipv4.tcp_rmem={ self .value [0 ]} { self .value [1 ]} { self .value [2 ]} "
228
+
229
+ class wmem (Option ):
230
+ """
231
+ tcp_wmem - vector of 3 INTEGERs: min, default, max
232
+ min: Amount of memory reserved for send buffers for TCP sockets.
233
+ Each TCP socket has rights to use it due to fact of its birth.
234
+ Default: 4K
235
+
236
+ default: initial size of send buffer used by TCP sockets. This
237
+ value overrides net.core.wmem_default used by other protocols.
238
+ It is usually lower than net.core.wmem_default.
239
+ Default: 16K
240
+
241
+ max: Maximal amount of memory allowed for automatically tuned
242
+ send buffers for TCP sockets. This value does not override
243
+ net.core.wmem_max. Calling setsockopt() with SO_SNDBUF disables
244
+ automatic tuning of that socket's send buffer size, in which case
245
+ this value is ignored.
246
+ Default: between 64K and 4MB, depending on RAM size.
247
+ """
248
+ value_type = tuple # (min, default, max)
249
+ @classmethod
250
+ def supportedModes (cls ) -> OptionMode :
251
+ return OptionMode .BUILD_TIME | OptionMode .RUN_TIME
252
+ @classmethod
253
+ def default (cls ):
254
+ return (4096 , 16384 , 4194304 )
255
+ def __repr__ (self ):
256
+ return f"net.ipv4.tcp_wmem={ self .value [0 ]} { self .value [1 ]} { self .value [2 ]} "
257
+
0 commit comments