Organization : The Linux Foundation
Open Source Project : The Zephyr RTOS Project
Mentors : Mr Christopher Friedt & Mr Robert Lubos
Contributor : Emna Rekik, Embedded Systems Engineer Student
The Internet of Things (IoT) seeks to integrate embedded devices into regular online communication using common protocols like HTTP for smoother connection and interaction. In the past, Zephyr maintained a forked version of Civetweb, a tiny HTTP server, as an external module. This approach required a lot of effort for the integration process and to keep it always synchronized with the upstream. The proposed solution is to create an in-tree HTTP server, as outlined in the RFC titled "Replacement of Civetweb". This proposal also addresses the challenges associated with HTTP/1 for embedded systems, given its text-based nature which consumes substantial RAM and buffer space. Notably, HTTP/2.0, being a binary protocol, is more efficient than its predecessor, HTTP/1. The RFC emphasizes the importance of supporting HTTP/2.0 because its design and features are well-suited for embedded systems. Its characteristics simplify parsing and reduce energy usage, both of which are essential for IoT devices.
The objective of our project is to implement an 'http_server' library, designed to simplify the creation of a basic HTTP 2.0 server, while retaining compatibility with HTTP/1.1. Key features will include support for in-memory compressed resources (CRiMe), REST API integration, JSON response format, and secure TLS communication. We aim to make our server customizable through Kconfig options. To ensure its performance and resilience, we will employ benchmarking tools such as Apache for HTTP/1.1 and h2load for HTTP/2.0. Additionally, users can customize the server using Kconfig configurable options.
From a user's perspective, this is a high-level interface for the server. A user/developer has the ability to set up and initiate the server, making it ready to accommodate incoming client connections and handle their requests. An integral part of this setup involves the user defining various HTTP services. Within each of these services, the user can specify distinct resources. These resources, often static in nature, ensure that clients receive consistent and defined data upon request.
graph TB
A[Client] -->|Connect, Send request, Receive response| J[Zephyr HTTP Server]
E[User/Developer] --> G((Kconfig))
E --> F((Start Server))
E --> H((Stop Server))
E -->|Define| K[HTTP SERVICE n]
E -->|Define| L[HTTP SERVICE 2]
E -->|Define| M[HTTP SERVICE 1]
J --> K
J --> L
J --> M
K --> O1[Resource n.1]
K --> O2[Resource n.2]
L --> P1[Resource 2.1]
M --> Q1[Resource 1.1]
subgraph Clients
A
end
subgraph Server Control
E
F
G
H
end
subgraph HTTP SERVICES
K
L
M
end
subgraph Resources of Service 1
O1
O2
end
subgraph Resources of Service 2
P1
end
subgraph Resources of Service n
Q1
end
Alongside our main Pull Request 'GSOC2023: net: http: culminating pull request' , we established an issue 'GSOC2023: net: http: project overview' to provide detailed insights into our server features. For every feature introduced, we also implemented a test function using the Ztest Framework to ensure its functionality met expectations.
- #59684: gsoc2023: net: http: Kconfig options
- #59690: gsoc2023: net: http: HTTP 1.1 backward compatibility
- #59670: gsoc2023: net: http: Verify HTTP 1.1 to 2.0 upgrade
- #59691: gsoc2023: net: http: HTTP Header Parsing
- #59693: gsoc2023: net: http: HTTP Header Compression
- #59694: gsoc2023: net: http: Verify HTTP 2.0 concurrent streams
- #59699: gsoc2023: net: http: Verify HTTP 2.0 stream functionality
- #59695: gsoc2023: net: http: Verify HTTP 2.0 framing
- #59696: gsoc2023: net: http: Verify HTTP 2.0 frame types
- #59697: gsoc2023: net: http: Data, Header, Continuation, Settings
- #59700: gsoc2023: net: http: Gzipped Compression
We've set up a basic demonstration of a REST API and introduced JSON support with a straightforward addition :
$ curl -X POST -H "Content-Type: application/json" -d '{"x": 10, "y": 20}' http://192.0.2.1:8080/add --output -
[{"x":10,"y":20,"result":30}]
$ curl -X POST -H "Content-Type: application/json" -d '{"x": 30, "y": 20}' http://192.0.2.1:8080/add --output -
[{"x":10,"y":20,"result":30}, {"x":30,"y":20,"result":50}]
This benchmark analysis involves making 1000 requests to both Civetweb and Zephyr HTTP Server on the Linux platform. The requests will be made using HTTP/1.1, as Civetweb does not support HTTP/2. Below is a quantitative representation of the data we have obtained:
This chart represents the distribution of request processing on zephyr RTOS:
This Gantt chart provides a visual representation of our project's timeline, highlighting the duration of each task. It offers an overview of the work completed during this period.
gantt
title Gantt Chart GSoC 2023 : Zephyr HTTP Server
dateFormat YYYY-MM-DD
section Milstone 0
Set up work environnement : 2023-06-01, 3d
Get Familiar with Zephyr RTOS : 2023-06-04, 3d
Set up Qemu networking : 2023-06-07, 3d
Familiarize with HTTP/2 protocol : 2023-06-10, 3d
Create pull request in Zephyr RTOS Repo : 2023-06-13, 3d
Set up CI environment : 2023-06-16, 3d
section Milestone 1&3
Basic server with poll :2023-06-22, 4d
Add IPv6 support :2023-06-26, 4d
Test for IPv4/IPv6 :2023-06-30, 4d
Test for server up :2023-07-04, 4d
Test for server shutdown :2023-07-08, 4d
Support Gzipped compression :2023-07-12, 4d
Test for Gzipped compression :2023-07-16, 4d
Support HTTP/1.1 compatibility :2023-07-20, 4d
Test for HTTP/1.1 compatibility :2023-07-24, 4d
Support HTTP/2 upgrade :2023-07-28, 4d
Test for HTTP/2 upgrade :2023-08-01, 3d
Support HTTP/2 concurrent streams :2023-08-04, 3d
Test for HTTP/2 concurrent streams:2023-08-07, 3d
Implement hpack library :2023-08-10, 4d
Test for hpack library :2023-08-14, 4d
Improve system design :2023-07-04, 47d
section Milestone 2&4
Support POST request :2023-08-18, 1d
Test for POST request :2023-08-19, 1d
Support JSON format :2023-08-20, 1d
Test for JSON format :2023-08-21, 1d
section Documentation
Create README.rst file :2023-07-12, 3d
Update README.rst file :2023-08-14, 3d
- Supporting multithreading for HTTP SERVICES
- Improving the REST API feature to ensure it's intuitive and user-friendly.
- Integrating TLS support for encrypted and secure data exchanges.
- Enhancing security measures to boost trust among users.
I would like to express my profound gratitude to my mentors, Mr Robert Lubos and Mr Christopher Friedt. Without their support, this work would not have been as rewarding. Throughout the coding phase, they provided me with consistent and invaluable guidance, enriching the process and greatly enhancing my skills. I also wish to extend my gratitude to Google Summer of Code (GSoC) Team for this precious opportunity. It has truly been one of the most significant and unique experiences I've ever had.