ArticleslgStudy

computer science

Mosh (software)

Mosh (software) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Mosh (software) rather than just read about it. In short: In computing, Mosh (mobile shell) is a tool used to connect from a client computer to a server over the Internet, to run a remote terminal. Mosh is similar to SSH, with additional features meant to improve usability for mobile users.

Mosh (software) — main illustration
Mosh (software) — illustration

Key takeaways

  • Mosh (software) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Mosh (software) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Mosh (software) from memory before moving on to harder problems.

Reference excerpt

In computing, Mosh (mobile shell) is a tool used to connect from a client computer to a server over the Internet, to run a remote terminal. Mosh is similar to SSH, with additional features meant to improve usability for mobile users. The major features are:

Mosh maintains its session even when it "roams" (when the client endpoint changes to different IP addresses), for example by moving to a different Wi-Fi network or when changing from Wi-Fi to 3G. Mosh maintains the terminal session (not "connection" in the TCP-sense because Mosh uses UDP) even when a user loses their Internet connection or puts their client to "sleep". In comparison, SSH can lose its connection in such cases because TCP times out. A Mosh client attempts to be responsive to keyboard events (typing, erasing characters with the delete key, and so on) without waiting for network lag. It uses an adaptive system that predicts whether the application running on the server will decide to echo the user's keystrokes or deletions. The main drawbacks of Mosh are additional prerequisites to the server, that it lacks some special features of SSH (such as connection forwarding) and the lack of a native Windows client. An alternative for Linux servers (that still require installation on the server) is to use GNU Screen on top of a regular SSH connection.

Design Mosh works at a different layer from SSH. Whereas SSH transmits a stream of bytes in each direction (from server to client or client to server) using TCP, Mosh runs a terminal emulator at the server to figure out what should be on the screen. The server then transmits this screen to the client at a varying frame rate, depending on the speed of the network. This allows Mosh to save on network traffic on slow or intermittent connections.

Supported platforms Mosh is available for most Linux distributions, macOS, FreeBSD, NetBSD, and OpenBSD, Android, Solaris, Cygwin, and as a Chrome App. The iOS program Termius includes an independent implementation of the Mosh protocol.

Performance

Roaming Mosh is built on the State-Synchronization Protocol (SSP), which supports single-packet roaming. After the client has switched to a new IP address, a single packet that successfully reaches the server is enough to "roam" the connection. The client does not need to know it has roamed. (The client may be on a network with network address translation (NAT) when the NAT router roams.)

Packet loss In the Mosh research paper, the creators tested SSP on a link with 29% packet loss, and found that SSP reduced the average response time by a factor of 50 (from 16.8 seconds to 0.33 seconds) compared with SSH, which uses TCP. A different study, by students at Stanford University, found that SSP reduced the average response time by a factor of 30 (from 5.9 seconds to 0.19 seconds).

Local echo According to Mosh's developers, the program was found to be able to predict and immediately display 70% of user keystrokes, reducing the median response time to a keystroke to less than 5 milliseconds (masking the latency of the network). A different study, by students at Stanford University, found that Mosh was able to quickly echo 55% of user keystrokes.

Drawbacks Compared to the more popular SSH, Mosh has the following drawbacks:

Prerequisites on the server The major drawback of Mosh is that it requires the server to fulfill additional prerequisites which are not needed by ssh itself. Due to its design, Mosh needs the server to allow direct connections via UDP. Servers not fulfilling these prerequisites cannot be used by Mosh. Examples of such systems include servers behind firewalls which restrict connections to the ssh-port via TCP. Also problematic are servers which are only indirectly reachable. The latter is usually accommodated by ssh via the 'ProxyCommand' option, but this is not supported by Mosh.

One port per connection By default, the server tries to allocate the first free UDP port in the range 60001–61000, per connection. This dynamic port allocation is considered an extra burden and risk for firewall maintenance. A significant part of the firewall-filtering happens through connection tracking, so called stateful filtering, this is based on the SYN/ACK flags in TCP segments, UDP packets don't have such flags. Mitigation:

The UDP port on the server can be set per Mosh connection, so that only a limited number of ports need to be opened Deep packet inspection firewalls and application firewalls can handle this better by looking at content of the packet and associate it to the initial connection

Output drops and lack of terminal scrollback

Scrollback is not supported in the current release of Mosh, and when using it in a terminal emulator with scrollbars they disappear, but is planned for the 1.3 release. This functionality is a trade-off for garbage cleaning, as binary output is wiped away. One way to mitigate this is by using Mosh in combination with a terminal multiplexer like screen or tmux.

Lack of ssh-agent forwarding ssh-agent forwarding is not currently supported.

Lack of X11 forwarding X11 forwarding is not yet supported.

See also Block-oriented terminal Command-line interface

References

Illustrations

Mosh (software) illustration

Worked examples

Example 1 — a first encounter with Mosh (software)

Start with the simplest possible case. Write down what Mosh (software) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Mosh (software) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Mosh (software) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Mosh (software)

In research
Mosh (software) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Mosh (software) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Mosh (software) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Application layer protocols, Unix software, so understanding it makes those chapters shorter.
In everyday life
Look for Mosh (software) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Mosh (software)” →

How to study Mosh (software) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Mosh (software) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Mosh (software) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Mosh (software) in simple terms?

In computing, Mosh (mobile shell) is a tool used to connect from a client computer to a server over the Internet, to run a remote terminal. Mosh is similar to SSH, with additional features meant to improve usability for mobile users.

Why does Mosh (software) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Mosh (software)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Mosh (software).

Tags

  • Application layer protocols
  • Unix software

Keep exploring