N. Albert via plug on 27 Sep 2024 03:18:26 -0700 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] Slow Down an ssh Session |
On 9/27/2024 6:03 AM, Casey Bralla via plug wrote:
In the "good old days", I used a DEC PDP-8 with a hulking noisy teletype. To relive my youth, I bought a PiDP-8, which is just the front panel of the PDP-8, run by a Raspberry Pi.The Pi, of course, is waaay faster than the PDP-8, so I set some parameters in the simulator software to slow it down to the speed of an actual PDP-8 from the early 70's.Since I don't have a real teletype (I actually had one and gave it away years ago. Ugh! I wish I kept it!) I'm using an ssh session on an old laptop as a terminal.But this means the effective terminal baud rate is like warp speed compared to the teletype.I'd like to mimic the original 110 baud teletype. Other than actually connecting via 110 baud serial connection, is there a way to throttle the effective baud rate of ssh?
If you're using a serial connection, it's relatively straightforward, something like:
struct termios slow; tcgetattr(STDOUT_FILENO, &slow); cfsetispeed(&slow, B300); cfsetospeed(&slow, B1200); tcsetattr(STDOUT_FILENO, TCSANOW, &slow); For that, you'd need a serial monitor, as you said. To do this for an IP connection like SSH, it's a lot more complicated.I wrote a "feature" that does in my BBS software, that throttles the output speed for the entire session, regardless of the actual speed of the connection, primarily for effect for BBS users connecting via IP.
The way I do this is simply by adding the appropriate delay in the pseudoterminal layer, i.e. between reading data from the slave and writing it to the master. I wouldn't say it's the most *efficient* way to do this, from a CPU perspective, since the number of system calls is linear in the number of characters, but for very slow speeds, like 110/300/1200/2400, etc. it works very well, and the CPU overhead isn't enormous per se, either, and any program that gets launched, like a shell, is blissfully unaware that anything funky is going on.
I remember looking for a way to do this in the kernel, just using a constant number of system calls, but I don't think I ever found anything that would help me. Maybe it would make a good project for a kernel mod.
The one thing you can NOT do is the same thing you would with a serial connection, using cfsetispeed/cfsetospeed. Those only work for serial connections. Otherwise, they are basically no-ops.
Another way you could do this without modifying the system is just dial into it using a modem. Using a modem on your PC + softmodem on the server + telnet to proxy from the modem to IP, it's pretty easy to just dial in at 300 using your computer's terminal software. HyperTerminal even supports 110 but I've never actually used that speed, your modem might have to support it. My USR modem seems a little cranky when I try using that.
___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug