2012-01-13

Telneting to HelenOS

Not that long ago TCP rewrite was merged into HelenOS mainline branch. As a proof of its functionality, webserver was improved recently. That encouraged me to implement "remote console" offering posibility to run applications on HelenOS remotely over the network...

The screenshot below displays HelenOS running in Qemu with GNOME terminal in front with Telnet session to it.

If you want to try it, grab the branch lp:~vojtech-horky/helenos/remote-console and compile it. Then start HelenOS and run remcons from the console. If the networking is okay, the program shall display HelenOS remote console service and wait for incoming connection. The program listens on port 2223 and you can connect to it with following command:

telnet hostname 2223
Do not forget to add port redirection when running in Qemu:
qemu ... -redir tcp:2223::2223

A few notes to the implementation. The program behaves as a console-protocol service and on accepting new network connection, it creates a virtual terminal and runs getterm on it (with bdsh). It then translates the incoming traffic to console events and writing to console to outgoing packets.

Despite the title of this post, the server is far from being a standard-compliant Telnet server. It only sends Telnet commands for switching into character mode (for better interactivity) and then it sends only printable characters. It is also able to skip incoming Telnet commands but that is about all related with the protocol.

The service is not able to handle special keys (the most special keys it handles more or less okay are backspace and tab) and also has no support for drawing. So, no playing Tetris remotely. And national characters are passed through in a very ostrich way ;-).

The biggest flaw of the server is caused by limitations of current TCP implementation in HelenOS. The problem is that when a fibril waits for recv(), no other operation on any socket can occur because all network-related functions hold one global lock. That effectively means that you cannot have two remote sessions.

Apart from the fun of it, this service can be useful for simpler copying of textual data between HelenOS (running in some simulator) and host system. It seems to me easier than mounting virtual harddisks and copying the data off-line.

And that's all. I hope you like this new HelenOS toy ;-).

Žádné komentáře:

Okomentovat