Using Rust to build a next-generation network
Ferrous Systems specialises in the Rust Programming Language. We’re perhaps best known for our Training Courses, and the sponsored work we do on open-source projects like rust-analyzer, but we also offer consulting services for commercial clients. Here, we can take our vast experience in writing real-world Rust applications and apply it to produce innovative solutions for our clients trickiest programming problems.
One such client is Graphiant1, a Silicon-valley based networking startup looking to revolutionise the Enterprise networking space, with their simple, fast and secure cloud-based WAN service. The Graphiant network relies on nodes running GraphNOS, a custom network operating system where almost all of the critical components are written in Rust. We started working with Graphiant back in 2021 when they were still in stealth-mode, helping them bring their use of Rust to the next-level, so they can continue to move at speed whilst rolling out their revolutionary new network.
Ferrous System’s real-world experience in building production-ready systems in Rust proved to be the ideal addition to our engineering team. They’ve really helped us take our Rust code to the next level.
– Paul Widdop, Director of Engineering, Graphiant
One of the GraphNOS components we helped design and deliver, was a small HTTP server for local admin access to the Edge Nodes. Unlike a typical HTTP server, this one is not optimised for performance - it’s optimised for reliability, maintainability and security. Using Rust, we were able to bring together best-in-class libraries from across the Rust networking ecosystem, and develop a service that was tailor made for their needs. Using crates like
serde, marshalling objects into and out of the REST interface was a breeze, giving us more time to concentrate on the trickier parts. These included integrating with the C API for their YANG-based system database, and providing dynamic reconfiguration of the HTTP network interface bindings - even with multiple worker threads running. We were also able to use Cargo’s build scripts to pre-process the Web UI into static objects compiled directly into the web server binary. This means that there’s literally no mechanism to escape the sandbox and get the server to serve up arbitrary files - our server just doesn’t know how to read files from disk, full stop!
Another GraphNOS component we delivered for Graphiant was a developer-friendly tool for system analysis and debugging - the GraphNOS Terminal Interface (or
GTI). Previously, developers could only view the system database through its native JSON export function, and the dense machine-optimised output meant it was easy for engineers to miss some critical property they were looking for. We quickly put together CLI tool which could pull sub-trees from the system database and display them to the user in a human-friendly tree format. Handling command-line arguments was trivial using
structopt, as was adding support for ANSI coloured text using
colored. You might expect this kind of rich ecosystem with a dynamic language like Python, but the advantage of Rust is that we get all that, and also get a single static binary that’s trivial to deploy onto our target systems. Plus, it has low start-up times, and processes huge outputs in next to no time, so engineers spend less time waiting and more time actually looking at data.
We were also asked to look at a really interesting part of the system, known as geolocation. Basically, the GraphNOS nodes need to give the control servers some sense of where they are on the planet, so customer traffic can be routed to the nearest Graphiant Core Node. Previously, the geolocation operations were performed at fixed intervals - functional, but not very efficient. We were able to develop a state machine which could track each WAN interface, and its link state, and perform geolocation only when required (along with retries, and so on). Normally such state machines can get quite complicated, but because Rust has sum-types (Rust’s
enum), each state only needs to hold context relevant to that particular state. There’s no forgetting to initialise some shared value on entry to a state, because we literally can’t construct the state object unless all the parameters are correctly specified. We also used git
mockall to automatically generate a testable ‘mock’ implementation of the abstraction layer we used to hide the real network (you can’t have unit tests sending actual geolocation requests, after all!). Being able to spend less time worrying about the safety of our code, meant we could spend more time on the unit test cases, finding more of those corner cases that are so hard to replicate during system test.
We could give many more examples, but that’s a flavour of what we’re able to bring to a talented Rust team - practical solutions to interesting problems, backed up by our real-world experience. We’ve really enjoyed working with Graphiant, and we’re excited about continuing our partnership through 2023 and beyond.
If you feel you could use our real-world expertise in using Rust to build better software, why not get in touch? You can also head over to Graphiant’s website to learn more about this Silicon Valley-based startup.
Graphiant has developed the Graphiant Network Edge, an “as-a-Service” solution that provides connectivity between the enterprise WAN, hybrid cloud, network edge, customers, and partners. Graphiant’s Network Edge combines MPLS-like performance (guaranteed delivery and privacy) and Internet-class agility to enable network architects to build enterprise-grade networks at the speed of business. ↩