@@ -29,30 +29,37 @@ efficient application using real-time multiplayer game techniques. The project
29
29
showcases confident understanding of networking and concurrency concepts as
30
30
well as the use of Tokio async runtime.
31
31
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
+
32
36
Using conventional threads for concurrency and parallelism can be expensive due
33
37
to the cost of requesting threads from the operating system and additional heap
34
38
allocations (although thread pools mitigate this). Rust has language support
35
39
for asynchronous programming, but does not ship with built-in implementation of
36
40
an async runtime due to increase in compiled binary size. Instead it is opt-in
37
41
with 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).
42
47
43
48
Game programming provides a challenging environment to put these concepts into
44
49
practice due to them being classified as * soft real-time systems* , requiring
45
50
response within a time of generating a frame in 16.666 milliseconds (60
46
51
frames/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.
50
56
51
57
## Features
52
58
53
59
- Client-server architecture for multiplayer networking. UDP socket
54
60
communication for low-latency networking.
55
61
- Health-check mechanism to detect lost network connections.
62
+ - Reliability patterns to mitigate harsh network environments like UDP packet losses.
56
63
- Real-time multiplayer gameplay with smooth synchronization.
57
64
- Graphical client application with GUI menu
58
65
- Hardware-accelerated OpenGL rendering for 2D top-down perspective graphics.
@@ -74,19 +81,36 @@ Dependencies are automatically downloaded by `cargo`.
74
81
1 . Make sure you have the latest stable version of Rust and ` cargo ` installed, following the instructions on
75
82
https://www.rust-lang.org/tools/install
76
83
77
- 2 . Clone the repository
84
+ 2 . Clone the repository:
78
85
79
86
``` sh
80
87
git clone https://github.com/balintkissdev/multiplayer-game-demo-rust.git
81
88
cd multiplayer-game-demo-rust
82
89
```
83
90
84
- 3 . Compile and execute the release build
91
+ 3 . Compile and execute the release build:
85
92
86
93
``` sh
87
94
cargo run --release
88
95
```
89
96
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
+
90
114
## Usage
91
115
92
116
You can test out the application on your local machine by executing multiple
0 commit comments