Skip to content

Commit

Permalink
Server load balance, multithread support. Initial flow control.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjakstas committed Apr 22, 2023
1 parent 702989c commit c27ce4c
Show file tree
Hide file tree
Showing 24 changed files with 1,659 additions and 802 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@

All visible changes will be documented here. This project adheres to Semantic Versioning.

## [Unreleased]
## [0.2.0] - 2023-04-22

- Default retry timeout in milli seconds
### Added

- Server load balance connections
- Server use multi threads by default
- Secure server directory so that files do not escape provided directory
- Retry window size from last acknoledged
- Initial flow control

### Changed

- Default retry timeout from seconds to milliseconds
- Default retry timeout from 1000ms to 80ms

## [0.1.0] - 2023-02-15

Expand Down
15 changes: 13 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tftp"
version = "0.1.0"
version = "0.2.0"
edition = "2021"

[profile.release]
Expand Down Expand Up @@ -28,9 +28,10 @@ rand = "0.8"
vfs = "0.9"

[features]
default = ["std", "alloc", "encryption"]
default = ["std", "alloc", "encryption", "multi_thread"]
std = ["x25519-dalek?/std"]
alloc = ["chacha20poly1305?/alloc"]
encryption = ["x25519-dalek", "chacha20poly1305", "base64"]
seek = []
stack_large_window = []
stack_large_window = []
multi_thread = []
113 changes: 56 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ encrypt traffic or data.
Install deb

```
wget https://github.com/songokas/tftp/releases/download/v0.1.0/tftp_0.1.0_amd64.deb \
&& sudo apt install ./tftp_0.1.0_amd64.deb
wget https://github.com/songokas/tftp/releases/download/v0.2.0/tftp_0.2.0_amd64.deb \
&& sudo apt install ./tftp_0.2.0_amd64.deb
```

Download binary
Expand Down Expand Up @@ -118,64 +118,63 @@ echo "hello" | tftp send 127.0.0.1:9000 /dev/stdin --allow-server-port-change
### Stats

```
Send 100Mb
+-----------------------------------------------------------------------------------------------------------+
18 |-+ + + + + + + +-|
| |
| x |
| |
16 |-+ +-|
| |
| |
14 |-+ +-|
| |
| |
12 |-+ +-|
Time | |
| |
10 |-+x +-|
| |
| |
8 |-+ +-|
| x |
| |
6 |-+ x +-|
| x x |
| + x x x + + x + + + x |
4 +-----------------------------------------------------------------------------------------------------------+
0 10 20 30 40 50 60
WindowSize
Send 100Mb
+----------------------------------------------------------------------------------+
18 |-+ + + + + + + +-|
| |
| x |
| |
16 |-+ +-|
| |
| |
14 |-+ +-|
| |
| |
12 |-+ +-|
Time | |
| |
10 |-+x +-|
| |
| |
8 |-+ +-|
| x |
| |
6 |-+ x +-|
| x x |
| + x x x + + x + + + x |
4 +----------------------------------------------------------------------------------+
0 10 20 30 40 50 60
WindowSize
Receive 100Mb
+-----------------------------------------------------------------------------------------------------------+
18 |-+ + + + + + + +-|
| |
| x |
16 |-+ +-|
| |
14 |-+ +-|
| |
| |
12 |-+ +-|
| |
| x |
Time 10 |-+ +-|
| |
| |
8 |-+ +-|
| |
6 |-+ x +-|
| |
| x x |
4 |-+ x x x x +-|
| x x |
| + + + + + + |
2 +-----------------------------------------------------------------------------------------------------------+
0 10 20 30 40 50 60
WindowSize
Receive 100Mb
+----------------------------------------------------------------------------------+
18 |-+ + + + + + + +-|
| |
| x |
16 |-+ +-|
| |
14 |-+ +-|
| |
| |
12 |-+ +-|
| |
| x |
Time 10 |-+ +-|
| |
| |
8 |-+ +-|
| |
6 |-+ x +-|
| |
| x x |
4 |-+ x x x x +-|
| x x |
| + + + + + + |
2 +----------------------------------------------------------------------------------+
0 10 20 30 40 50 60
WinddowSize
```

Expand Down
6 changes: 4 additions & 2 deletions binary/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tftp-binary"
version = "0.1.0"
version = "0.2.0"
edition = "2021"

authors = ["Tomas Jakstas <[email protected]>"]
Expand All @@ -21,18 +21,20 @@ tftp = { path = "..", default-features = false}
rand = { version = "0.8", optional = false, default-features = false, features = ["getrandom"]}
# std compile time requirement
polling = "2"
socket2 = { version = "~0.5.1", features = ["all"] }

[dev-dependencies]
rand = "0.8"
env_logger = "0.10"

[features]
default = ["std", "alloc", "encryption"]
default = ["std", "alloc", "encryption", "multi_thread"]
std = ["tftp/std", "polling/std"]
alloc = ["tftp/alloc"]
encryption = ["tftp/encryption"]
seek = ["tftp/seek"]
stack_large_window = ["tftp/stack_large_window"]
multi_thread = ["tftp/multi_thread"]

[[bin]]
name = "tftp"
Expand Down
3 changes: 3 additions & 0 deletions binary/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ pub enum Commands {

#[arg(long, default_value_t = 1 as u64, value_parser = clap::value_parser!(u64).range(1..=(MAX_BLOCKS_READER as u64)))]
max_blocks_in_queue: u64,

#[arg(long, default_value_t = true)]
ignore_rate_control: bool,
},

Receive {
Expand Down
4 changes: 2 additions & 2 deletions binary/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn create_reader(path: &FilePath) -> BoxedResult<(Option<u64>, StdCompatFile
let file_size = file.metadata().map_err(from_io_err)?.len();
#[cfg(not(feature = "std"))]
let file = StdCompatFile(file);
Ok(((file_size > 0).then(|| file_size), file))
Ok(((file_size > 0).then_some(file_size), file))
}

pub fn create_server_reader(
Expand Down Expand Up @@ -230,6 +230,6 @@ impl tftp::std_compat::io::BufRead for StdBufReader {
pub fn std_into_path(path: PathBuf) -> FilePath {
let mut f = FilePath::new();
// TODO alloc in stack
let _result = f.push_str(&path.to_string_lossy().to_string());
f.push_str(&path.to_string_lossy());
f
}
Loading

0 comments on commit c27ce4c

Please sign in to comment.