Skip to content

Instantly share code, notes, and snippets.

@Emna-Rekik
Last active February 9, 2024 06:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Emna-Rekik/658bcd3efabc6961d48f800d58fe9161 to your computer and use it in GitHub Desktop.
Save Emna-Rekik/658bcd3efabc6961d48f800d58fe9161 to your computer and use it in GitHub Desktop.
GSoC 2023 - Final Submission Report

logos




GSoC'23 : Zephyr HTTP Server with The Linux Foundation




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


Description

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.

Project objective

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.

Server architecture

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

Server features

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.

Performance & Stress Testing:

  • #59567: gsoc2023: net: http: performance analysis
  • #59681: gsoc2023: net: http: Stress tests

Server Customization:

  • #59684: gsoc2023: net: http: Kconfig options

HTTP Protocol Compatibility:

  • #59690: gsoc2023: net: http: HTTP 1.1 backward compatibility

HTTP/2.0 Prototype:

  • #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

Compressed resources support:

  • #59700: gsoc2023: net: http: Gzipped Compression

REST API and JSON support:

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}]

Performance Benchmark Analysis: Civetweb and Zephyr HTTP Server

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:

quantitative  graph

This chart represents the distribution of request processing on zephyr RTOS:

Project Overview: Visual Timeline through Gantt Chart

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

What's left to do

  • 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.

Acknowledgement

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment