Silence does not mean stagnation

It's been over a year since I last wrote something on this blog. At the end of 2016, when I returned from the Recurse Center, I told myself I will be blogging about all new things I learn or experiment with - cause that's a good way to organize ones thoughts. Anyway, good habits require at least 2 things: will and time. I wouldn't say I don't have any of those but in the end I did not write anything for a whole year!

One of the major factors that kept me silent was my new job. At the end of October in 2017 I started working with MaidSafe on a peer-to-peer privacy and security oriented data network. The peer-to-peer technology was totally new to me as a programmer. Also, most of our code is written in Rust which I didn't have professional experience with. On top of that, I started working remotely and that was another thing I've never done before. So, I've kept myself quite busy and couldn't find enough time to properly log some of my discoveries :)

Work at MaidSafe

One of the nice things about working at MaidSafe is that everything is open source. You can even go and checkout out what I've been doing today :) At MaidSafe I'm mainly working on the p2p networking library called Crust which puts into use a number of other libraries. I will mention only those that I've made a fair amount of contributions.

p2p

p2p is a Rust library that does TCP and UDP hole punching. Hole punching is a technique that makes direct connections possible between two peers that are behind routers with Network Address Translation. This topic deserves a blog post of it's own that I will probably write some time soon. p2p is a very important library for peer-to-peer connections and is integrated into Crust. I made sure the integration was smooth and was one of the library maintainers.

tokio-utp

tokio-utp is another Rust networking library. It implements uTP protocol in pure Rust and exposes Tokio/futures based API. uTP protocol adds reliability logic on top of UDP protocol. It also describes the expected congestion control mechanism that yields to other network traffic in the system. I took over the maintenance of this library from ex developers. I did a lot of investigation on how congestion control was implemented, I worked on graceful connection shutdown, improved test coverage and code quality in general.

rust-libutp

tokio-utp was written from scratch and at that time it wasn't as stable as people would like it to be. As a result, I wrote the wrappers for the libutp which is C implementation of uTP protocol. libutp is the mainstream implementation and is supposed to be robust and stable. That was the first time I wrote C bindings for Rust, hence learned something new. I have to say it was quite easy: Rust has this tool bindgen that automatically generates Rust wrappers for a given C header file. The generated wrappers are unsafe so I did have to provide safe API on top of. Anyway, work is still in progress there.

Crust

Most of my time I spent working on Crust library. It's a peer-to-peer communications library written in Rust. It supports multiple transport protocols (TCP and uTP at this moment), encryption, hole punching, etc. I did some work to integrate tokio and futures crates into Crust, greatly expanded automated test suite, implemented examples, expanded documentation and maintained library overall quality.

I also did some minor changes to MaidSafe encryption libray safe_crypto and carried safe_crypto integration into Crust.

netsim

Testing peer-to-peer networking code is hard, especially the hole punching implementation. As a result my collegue Andrew created a library that simulates computer networks with Rust - netsim. It runs completely in memory and gives you a full control over the simulated network: you can construct hierarchical networks, exchange IP packets, introduce packet loss and latency, simulate misc network address translation behaviors, etc. I mostly tested the library from the user perspective and gave my feedback. In addition, I did some minor contributions and since this is such an amazing tool I did a couple of presentations at our local events in Lithuania: no trolls allowed 2018 and Vilnius Rust meetup :)

Open Source Projects

Besides my daily job I usually tend to spend some time on my personal or other open source projects. A lot of times the work I do for the companies influences my interests after work too.

A year ago I did some UDP and TCP hole punching experiments using python. The code is here. I also wrote a command line utility to forward ports in your router: https://github.com/povilasb/pyigd which I actively use to this day.

At MaidSafe I work with Rust on a daily basis where we use a lot of open source libraries. During the last year I did some small contributions to some of them. I added boolean matchers to rust hamcrest library: https://github.com/ujh/hamcrest-rust/commits?author=povilasb . Unfortunately, the development of hamcrest-rust got frozen. But then an active fork emerged which accepted a small PR of mine. I made contains() matcher generic which allowed it to accept single element or vector. Hence assert_that!(vec![1, 2, 3], contains(2)) became possible. Another rust library I contributed to is rust-igd which implements IGD protocol. I added an asyncronous use example. Finally, I made a tiny PR into vim-toml which is TOML format highlighting for vim. Unfortunately the PR did not get merged yet.

Comments