Skip to content

Commit 23516eb

Browse files
drjbarkerbrianmay
authored andcommitted
Add option for latency control buffer size
This commit resolves sshuttle#297, allowing the buffers used in the latency control to be changed with a command line option ‘--latency-buffer-size’. We do this by changing a module variable in ssnet.py (similar to the MAX_CHANNEL variable) which seems to be the simplest code change without extensive hacking. Documentation is also updated.
1 parent c69b9d6 commit 23516eb

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

docs/manpage.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,13 @@ Options
189189
control feature, maximizing bandwidth usage. Use at
190190
your own risk.
191191

192+
.. option:: --latency-buffer-size
193+
194+
Set the size of the buffer used in latency control. The
195+
default is ``32768``. Changing this option allows a compromise
196+
to be made between latency and bandwidth without completely
197+
disabling latency control (with :option:`--no-latency-control`).
198+
192199
.. option:: -D, --daemon
193200

194201
Automatically fork into the background after connecting

sshuttle/cmdline.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ def main():
1717
if opt.wrap:
1818
import sshuttle.ssnet as ssnet
1919
ssnet.MAX_CHANNEL = opt.wrap
20+
if opt.latency_buffer_size:
21+
import sshuttle.ssnet as ssnet
22+
ssnet.LATENCY_BUFFER_SIZE = opt.latency_buffer_size
2023
helpers.verbose = opt.verbose
2124

2225
try:

sshuttle/options.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ def __call__(self, parser, namespace, values, option_string=None):
243243
sacrifice latency to improve bandwidth benchmarks
244244
"""
245245
)
246+
parser.add_argument(
247+
"--latency-buffer-size",
248+
metavar="SIZE",
249+
type=int,
250+
default=32768,
251+
dest="latency_buffer_size",
252+
help="""
253+
size of latency control buffer
254+
"""
255+
)
246256
parser.add_argument(
247257
"--wrap",
248258
metavar="NUM",

sshuttle/ssnet.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from sshuttle.helpers import b, binary_type, log, debug1, debug2, debug3, Fatal
99

1010
MAX_CHANNEL = 65535
11+
LATENCY_BUFFER_SIZE = 32768
1112

1213
# these don't exist in the socket module in python 2.3!
1314
SHUT_RD = 0
@@ -368,7 +369,7 @@ def amount_queued(self):
368369
return total
369370

370371
def check_fullness(self):
371-
if self.fullness > 32768:
372+
if self.fullness > LATENCY_BUFFER_SIZE:
372373
if not self.too_full:
373374
self.send(0, CMD_PING, b('rttest'))
374375
self.too_full = True
@@ -448,7 +449,7 @@ def flush(self):
448449
def fill(self):
449450
self.rsock.setblocking(False)
450451
try:
451-
read = _nb_clean(os.read, self.rsock.fileno(), 32768)
452+
read = _nb_clean(os.read, self.rsock.fileno(), LATENCY_BUFFER_SIZE)
452453
except OSError:
453454
_, e = sys.exc_info()[:2]
454455
raise Fatal('other end: %r' % e)

0 commit comments

Comments
 (0)