A dedicated kernel for multi-threading applications.

Wednesday, January 04, 2017

HTTP server by using socket multiplexing

Hi folks!
In this post I will show you part of the last experiments on sockets multiplexing. This has been added in Toro a couple or years ago, however, only now I could make an example that works. This is a simple example, i.e., a simple http server that prints a welcome message. To make it works, I spent the last month fixing bugs in the networking. Also, I fixed an important bug in the memory manager. In the following, I will show how socket multiplexing is used in the case of a http server. The code of the example can be found in tests/ToroHttp.pas. In this post, I am not going into details about how socket multiplexing works. I will try only to give a big picture.
Let's first discuss the code of ToroHttp.pas (see Figure 1). This is the main program. It defines the network handler, i.e., HttpHandler. Then, it sets the right methods, e.g., DoInit(), DoAccept().

Figure 1.

After that, the handler is registered by using SysRegisterNetworkService(). The kernel will execute the different methods. For example, the first method invoked will be HttpInit().


Figure 2.
The method creates a new socket that listens on local port 80. Then, when a new connection arrives, the kernel will invoke HttpAccept().


This method prints something and waits for new data from the remote host. When some data is received, the kernel executes HttpReceive().

Figure 3.
We implemented a simple Receiv method. It only reads all the data from the remote host, then it sends a welcome message, and finally it closes the connection. To tray the server, we use telnet to the IP of the guest. In the telnet client, we get:


In the Qemu VM, we see that the connection is received and then closed:


As I said before, I only explained some details about socket multiplexing. I used the http server as a running example. The whole example is hosted in toro repo so please fell free to clone it.

Matias Vara


Sunday, December 11, 2016

Full Ping Implementation in Toro

Hi folks!,
last weekend I spent some time on Toro. My weekend project was to make Toro sends and receives ICMP packets. I started by coding a new test named ToroPing.pas which first sends an ICMP packet, and then waits for the response. At the beginning, this was not working. But, after fixing several bugs in the Network.pas and ne2000.pas, I have the test working quite well. I already pushed all the code and the test. If you try, you will get something like the next picture:





Basically, ToroPing just sends an ICMP packet to a fixed IP, i.e., 192.100.200.10. When the host responds, ToroPing informs that the ping has been responded and sends a new packet. This is done every 2 second. 
The example is very simple, however, it shows that the network stack is working better.

Matias 

    

Thursday, December 08, 2016

Pong from Toro

Hi folks, last days I have been spending some time in the network stack of Toro. It is a piece of code that I am scare to touch because most the time it does not work and I cannot figure out why. So I spent some time getting the good environment for testing and a lot of patient. As a result, I fixed a bug in the ne2000 driver and in the network stack so at least I have toro kernel answering pings. I will continue in this way doing more testing on the network stack. The code is there I just have to get so time to make it work. Enjoy the screenshots! ;)


Figure 1. Toro on QEMU detecting the network stack
Figure 2. I improved the serial console debug. Now it shows more interested info.

Figure 3. TORO VM answering pings


Sunday, October 30, 2016

CloudIt!

Hi folks, I committed the new script CloudIt.sh which is meant to unify the way than an application is compile within Toro and then run in a VM. The script accepts one parameter which is the name of a fpc application. For example, the following figure shows the use of the script to compile and run the ToroHello.pas

Figure 1
The script compiles the application within the Toro kernel (see Figure 2), and then, it generates a .img that can be run in a Qemu VM (see Figure 3).

Figure 2

Figure 3
To get the needed parameters to create the Qemu instance, the script looks for a .qemu which is named with the same name than the application, e.g., ToroHello.qemu. Such a file only contains the needed parameters to pass to qemu.  

The idea in ClouidIt.sh is to show Toro as a unikernel, in this case, for the fpc compiler. It enables a fpc programmer to compile an application within the kernel and then run it in a VM instance. To go further with this approach, Toro should be able to run in an hypervirsor like Xen. This remains a very interesting future work! :)