|
2 | 2 | A multi-threaded TCP/HTTP server built in Rust, following the implementation patterns from The Rust Programming Language (Chapter 20). |
3 | 3 |
|
4 | 4 | ## Motivation |
5 | | -I am an Aerospace Engineer, and Embedded Software developer. |
6 | | -While I am comfortable with real-time constraints, memory-mapped I/O, and hardware protocols like SPI/I2C, I knew nothing about Computer next works. |
| 5 | +I am an Aerospace Engineer, and Embedded Software developer, who aims to pursue a masters in CS. |
| 6 | +While I am comfortable with real-time constraints, memory-mapped I/O, and hardware protocols, I knew nothing about Computer networks. |
| 7 | +In RED, IST's rocketry team, my focus is the Embedded Software running on our flight computer. The GroundStation, which hosts a web-server for a dashboard to monitor the mission is equally important. |
| 8 | +Becoming The Software Team leader, I found necessary to also learn more about Computer networks in order to have a better vision of how to implement the GroudStation backend. |
7 | 9 |
|
8 | | -This project serves as way to learn a little about computer networks, while also practing my rust Programming skills :). |
| 10 | +This project serves as way to learn a little about computer networks, while also practising my rust Programming skills :). |
| 11 | + |
| 12 | +## The concepts explored |
| 13 | + |
| 14 | +1. **TCP/IP Stack** |
| 15 | + 1. TCP Handshake: Implementing the logic that manages reliable, ordered data delivery. |
| 16 | + 2. The 5-Tuple: Understanding how the OS identifies unique connections via Source/Dest IP, Ports, and Protocol. |
| 17 | + |
| 18 | +2. **HTTP/1.1 Protocol** |
| 19 | + 1. I Implemented a manual parser for HTTP requests. This taught me that web communication is essentially just a specific "packet format" (headers vs. body) delimited by `\r\n\r\n`. |
| 20 | + 2. Header Precision: Learning the hard way that a single typo (like Content-lenght vs Content-Length) can break the entire "telemetry" stream to the browser. |
| 21 | + 3. Status Codes: Mapping server states to standard HTTP responses (200 OK, 404 Not Found). |
| 22 | + |
| 23 | +3. **Concurrent Architecture (Thread Pooling)** |
| 24 | + 1. This server, uses a Thread Pool to handle simultaneous requests. |
| 25 | + 2. The |
| 26 | +```Rust |
| 27 | + Arc<Mutex<mpsc::Receiver>> |
| 28 | +``` Combining Atomic Reference Counting and Mutual Exclusion to safely distribute jobs accros worker threads without data races. I found this to be particular different from C( the lang i usually use at RED), especially the fact that the Mutex is automaticaly "Unlocked", whereas in C, i have to manualy unlock the mutex. |
| 29 | + 3. Using closures (`FnOnce`) and `Box` to pass tasks efficiently. |
| 30 | + |
| 31 | +## The Project Structure (As of now ...) |
| 32 | + |
| 33 | +1. `main.rs`: The entry point. Handles the TCP Listener and CLI input for pool sizing. |
| 34 | + |
| 35 | +2. `lib.rs`: The "Engine." Contains the ThreadPool and Worker implementations. |
| 36 | + |
| 37 | +3. html/: The payload directory containing the web assets. |
| 38 | + |
| 39 | +## If you want to run this |
| 40 | + |
| 41 | +### Prerequisites |
| 42 | + |
| 43 | + 1. Rust (2021 onwards) |
| 44 | + 2. Git |
| 45 | + |
| 46 | +### Instalation and Execution |
| 47 | + |
| 48 | +1. **Clone the repo** : |
| 49 | +```Bash |
| 50 | +git clone https://github.com/sofiavldd2005/web_server_made_rusty.git |
| 51 | +cd web_server_made_rusty |
| 52 | +``` |
| 53 | +2. **Run**: `cargo run` |
| 54 | + |
| 55 | +3. Configure the thread pool : give a number of threads |
| 56 | + |
| 57 | +4. As of now, go to your browser and navigate to `http://127.0.0.1:7878` |
| 58 | + |
| 59 | +This project is inspired by the final project in "The Rust Programming Language" book, customized to explore the intersection of aerospace logic and web networking. |
| 60 | +More is comming to improve starting from this projet. |
0 commit comments