@@ -29,30 +29,37 @@ efficient application using real-time multiplayer game techniques. The project
2929showcases confident understanding of networking and concurrency concepts as
3030well as the use of Tokio async runtime.
3131
32+ This application was tested under ` tc-netem ` network emulator simulating
33+ harsh network environment and packet loss, as well as live being deployed on a
34+ remote [ Amazon EC2] ( https://aws.amazon.com/ec2/ ) virtual machine instance.
35+
3236Using conventional threads for concurrency and parallelism can be expensive due
3337to the cost of requesting threads from the operating system and additional heap
3438allocations (although thread pools mitigate this). Rust has language support
3539for asynchronous programming, but does not ship with built-in implementation of
3640an async runtime due to increase in compiled binary size. Instead it is opt-in
3741with the inclusion of crates like [ async-std] ( https://async.rs/ ) ,
38- [ Tokio] ( https://tokio.rs/ ) and [ smol] ( https://github.com/smol-rs/smol ) . Tokio
39- utilizes the concept of * green-threading* (concept similar to goroutines in the
40- Go programming language) and the asynchronous I/O capabilities of the operating
41- system (` epoll ` on Linux, ` IOCP ` on Windows and ` kqueue ` on macOS).
42+ [ Tokio] ( https://tokio.rs/ ) , [ mio] ( https://github.com/tokio-rs/mio ) and
43+ [ smol] ( https://github.com/smol-rs/smol ) . Tokio utilizes the concept of
44+ * green-threading* (concept similar to goroutines in the Go programming
45+ language) and the asynchronous I/O capabilities of the operating system
46+ (` epoll ` on Linux, ` IOCP ` on Windows and ` kqueue ` on macOS).
4247
4348Game programming provides a challenging environment to put these concepts into
4449practice due to them being classified as * soft real-time systems* , requiring
4550response within a time of generating a frame in 16.666 milliseconds (60
4651frames/second). Although TCP network protocol is used in conventional software
47- systems, the ` SYN/ACK ` handshake procedure introduces additional latency. Real-time
48- multiplayer game developers utilize UDP protocol for faster responses and make
49- their own custom-tailored reliability protocol on top of it.
52+ systems, the ` SYN/ACK ` handshake procedure introduces additional latency.
53+ Real-time multiplayer game developers utilize the UDP protocol for faster
54+ responses at the cost of guaranteed packet delivery, and they create their own
55+ custom-tailored reliability protocols on top of it.
5056
5157## Features
5258
5359- Client-server architecture for multiplayer networking. UDP socket
5460 communication for low-latency networking.
5561 - Health-check mechanism to detect lost network connections.
62+ - Reliability patterns to mitigate harsh network environments like UDP packet losses.
5663- Real-time multiplayer gameplay with smooth synchronization.
5764- Graphical client application with GUI menu
5865- Hardware-accelerated OpenGL rendering for 2D top-down perspective graphics.
@@ -74,19 +81,36 @@ Dependencies are automatically downloaded by `cargo`.
74811 . Make sure you have the latest stable version of Rust and ` cargo ` installed, following the instructions on
7582https://www.rust-lang.org/tools/install
7683
77- 2 . Clone the repository
84+ 2 . Clone the repository:
7885
7986 ``` sh
8087 git clone https://github.com/balintkissdev/multiplayer-game-demo-rust.git
8188 cd multiplayer-game-demo-rust
8289 ```
8390
84- 3 . Compile and execute the release build
91+ 3 . Compile and execute the release build:
8592
8693 ``` sh
8794 cargo run --release
8895 ```
8996
97+ ### Docker
98+
99+ The application can also be deployed as a Docker container, which will run in server-only mode.
100+
101+ 1 . Build the Docker image:
102+
103+ ``` sh
104+ docker build -t multiplayer-game-demo-rust .
105+ ```
106+
107+ 2 . Launch the Docker container. This starts with ` --server-only ` and ` --trace ` options by
108+ default. See [ Command line options] ( #command-line-options ) for more info.
109+
110+ ``` sh
111+ docker run -d -p 8080:8080 multiplayer-game-demo-rust
112+ ```
113+
90114## Usage
91115
92116You can test out the application on your local machine by executing multiple
0 commit comments