+ All Categories
Home > Documents > Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL...

Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL...

Date post: 31-Jul-2020
Category:
Upload: others
View: 9 times
Download: 0 times
Share this document with a friend
29
Mosh An Interactive Remote Shell for Mobile Clients Keith Winstein and Hari Balakrishnan M.I.T. CSAIL June 14, 2012 http://mosh.mit.edu
Transcript
Page 1: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

MoshAn Interactive Remote Shell for Mobile Clients

Keith Winstein and Hari Balakrishnan

M.I.T. CSAIL

June 14, 2012

http://mosh.mit.edu

Page 2: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Secure Shell, 1995

I Uses TCP.

I Sends:

I user keystrokes → serverI octet stream (coded screen updates) → client terminal

I All UI comes from server.I . . . including keystroke echoes.

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 3: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Problems with SSH

I Can’t roam:

I . . . across Wi-Fi networks.I . . . from Wi-Fi to cell or vice versa.

I Can’t sleep and wake up (usually).

I Responds poorly to packet loss.

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 4: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

More problems with SSH

I Octet stream is wrong layer of abstraction.

I Client wants latest screen.I After interruption, don’t want to replay megabytes.I But SSH doesn’t understand data, so must send everything.I TCP fills buffers, so Control-C takes forever.

I Typing and editing on high-latency path is frustrating.

I Unloaded cellular wireless (50 ms to 500 ms)I Intercontinental (250 ms)I Loaded “4G LTE” (5,000 to 40,000 ms!)

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 5: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

What we built

1. Protocol for low-latency object synchronization

I with roamingI through suspend/resumeI over lossy network paths

2. Mobile shell application to replace SSH

I with “predictive” local echo

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 6: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

State Synchronization Protocol

I Runs over UDP.

I Instead of sending octet streams, synchronize objects.I Object must support:

I diff: make vector from state A→ BI patch: apply vector to A to make B

I Object implementation, not protocol, defines synchronizationsemantics.

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 7: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

TCP

RSA + AES

Application (e.g., emacs)

Pseudo-terminal

TCP

RSA + AES

Terminal emulator (e.g., xterm)

Pseudo-terminal

SSH Server SSH Client

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 8: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

UDP

AES-OCB

SSP

Screen

sender receiver

Keystrokes

Application (e.g., emacs)

Pseudo-terminal

UDP

AES-OCB

SSP

Keystrokes

sender receiver

Screen

Terminal emulator (e.g., xterm)

Pseudo-terminal

Mosh Server Mosh Client

Syncedobjects

Mosh terminal emulator

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 9: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

State Synchronization Protocol (cont.)

I Protected by AES-OCB (Krovetz 2011)I Integrity and confidentiality with one key.

I Key exchange happens out of band.I Uses SSH to bootstrap.I Runs mosh-server on remote side.I No privileged code, no daemons.

I Roaming is easy:I Source address of latest authentic packet from client⇒ server’s new target

I Client may not even know it has roamed.

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 10: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

State Synchronization Protocol (cont.)

I Flow control: adapt frame rate to network conditions.

I Don’t fill up buffers!

I Can skip over states.

I Tricks to balance robustness vs. throughput.

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 11: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Predictive Local Echo and Editing

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 12: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

UDP

AES-OCB

SSP

Screen

sender receiver

Keystrokes

Application (e.g., emacs)

Pseudo-terminal

UDP

AES-OCB

SSP

Keystrokes

sender receiver

Screen

Terminal emulator (e.g., xterm)

Pseudo-terminal

Mosh Server Mosh Client

Syncedobjects

Mosh terminal emulator

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 13: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

UDP

AES-OCB

SSP

Screen

sender receiver

Keystrokes

Application (e.g., emacs)

Pseudo-terminal

UDP

AES-OCB

SSP

Keystrokes

sender receiver

Screen

Terminal emulator (e.g., xterm)

Pseudo-terminal

Mosh Server Mosh Client

Syncedobjects

Mosh terminal emulator Predictivelocal echo

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 14: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Predictive Local Echo and Editing

I Client anticipates server response.

I Runs predictive model in the background.

I Make predictions in epochs.

I If any from epoch n is confirmed, show whole epoch.

I If user does something difficult to handle, become tentative:increment epoch.

I Carriage returnI EscapeI Up/down arrowI Control char

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 15: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Demo

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 16: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Evaluation

I Tested Mosh with 10,000 keystrokes collected from six users.

I 70% of user keystrokes displayed instantly.

I Good performance on lossy links vs. SSH.

I Full results in paper.

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 17: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Unicode on Unix is still full of bugs.

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 18: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Deployment

I In Debian, Ubuntu, Fedora, Gentoo, Arch, Slackware.

I Available for Red Hat, CentOS, Oracle Linux.

I In MacPorts, Homebrew, FreeBSD ports collection.

I Works on Cygwin and Solaris, (very raw) on Android.

I Stories in April on Hacker News, Reddit, The Register,Twitter, Slashdot, Barrapunto.

I Top repository of the month on GitHub.

I 200,000+ page views, 70,000+ downloads, 1,200+ followersof version control repo.

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 19: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Reception

@xlfe: “one of those times you don’t realize something is brokenuntil you see it fixed”

@adamhjk: “the user experience really is dreamy.”

@esmolanka: “mosh is awesome. Tested it for two weeks and itreally made my life easier: faster feedback and no morereconnects(!)”

@andyd: “Using mosh on the train rather than plain ssh, and itdoes actually make a huge difference!”

USENIX review: “ISO 2022 locking escape sequences oh flyingspaghetti monster please kill me now.”

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 20: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

State Sync Protocol for all?

I SSP may be appropriate for many network problems.

I Android Gmail, Google Chat, Skype cannot roam.

I June 13, 2012:

I Neither can Gmail (Web site).

I These problems can be expressed as state synchronization.

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 21: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Summary

I SSP is a secure datagram protocol that synchronizes abstractobjects across a roaming IP connection.

I Mosh uses SSP to synchronize a terminal emulator withpredictive local echo.

I We think SSP will be useful for other applications as well.

I http://mosh.mit.edu

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 22: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 23: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 24: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Evaluation

I Collected 40 hours of terminal usage from six users.

I Covers 10,000 keystrokes using shell, e-mail, text editor(emacs and vi), chat, Web browser.

I Replayed over:

1. Sprint 1xEV-DO (3G)2. Verizon LTE (4G)3. MIT-Singapore4. 50% loss path

I Result: 70% of keystrokes predicted instantly.

I Prediction errors < 1%

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 25: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Sprint 1xEV-DO cumulative keystroke response distribution

0

10

20

30

40

50

60

70

80

90

100

0 0.2 0.4 0.6 0.8 1

Percentage

Keystroke response time (seconds)

Mosh

median: 5 ms

mean: 173 ms

median: 503 ms

mean: 515 ms

SSH

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 26: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Evaluation (cont.)

Verizon LTE service in Cambridge, Mass., running oneconcurrent TCP download:

Median latency Mean σSSH 5.36 s 5.03 s 2.14 sMosh < 0.005 s 1.70 s 2.60 s

MIT-Singapore Internet path (to Amazon EC2 data center):

Median latency Mean σSSH 273 ms 272 ms 9 msMosh < 5 ms 86 ms 132 ms

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 27: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

SSP with high packet loss

Synthetic link with 100 ms RTT, 50% round-tripi.i.d. packet loss:

Median Mean σSSH 0.416 s 16.8 s 52.2 s

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 28: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

P·retransmissions shield against possible future loss.

SSP has options in choosing which diff to send:

1. Last ack was for state #3. Then state changes to #4.

2. Host sends diff from 3→ 4.

3. Object changes to state #5.

4. If no timeout yet, make next diff as 4→ 5.

5. Also make diff from 3→ 5: the prophylactic retransmission.

6. If p·retransmission is shorter or not much longer, send itinstead.

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients

Page 29: Keith Winstein and Hari Balakrishnan€¦ · Keith Winstein and Hari Balakrishnan M.I.T. CSAIL Mosh: An Interactive Remote Shell for Mobile Clients. What we built 1.Protocol for low-latency

Keith Winstein and Hari Balakrishnan M.I.T. CSAIL

Mosh: An Interactive Remote Shell for Mobile Clients


Recommended