-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't delay ACKs for significant window updates #935
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
mod utils; | ||
|
||
use log::debug; | ||
|
||
use smoltcp::iface::{Config, Interface, SocketSet}; | ||
use smoltcp::phy::{Device, Loopback, Medium}; | ||
use smoltcp::socket::tcp; | ||
use smoltcp::time::Instant; | ||
use smoltcp::wire::{EthernetAddress, IpAddress, IpCidr}; | ||
|
||
fn main() { | ||
let device = Loopback::new(Medium::Ethernet); | ||
|
||
let mut device = { | ||
utils::setup_logging("info"); | ||
|
||
let (mut opts, mut free) = utils::create_options(); | ||
utils::add_middleware_options(&mut opts, &mut free); | ||
|
||
let mut matches = utils::parse_options(&opts, free); | ||
utils::parse_middleware_options(&mut matches, device, /*loopback=*/ true) | ||
}; | ||
|
||
// Create interface | ||
let config = match device.capabilities().medium { | ||
Medium::Ethernet => { | ||
Config::new(EthernetAddress([0x02, 0x00, 0x00, 0x00, 0x00, 0x01]).into()) | ||
} | ||
Medium::Ip => Config::new(smoltcp::wire::HardwareAddress::Ip), | ||
Medium::Ieee802154 => todo!(), | ||
}; | ||
|
||
let mut iface = Interface::new(config, &mut device, Instant::now()); | ||
iface.update_ip_addrs(|ip_addrs| { | ||
ip_addrs | ||
.push(IpCidr::new(IpAddress::v4(127, 0, 0, 1), 8)) | ||
.unwrap(); | ||
}); | ||
|
||
// Create sockets | ||
let server_socket = { | ||
let tcp_rx_buffer = tcp::SocketBuffer::new(vec![0; 65536]); | ||
let tcp_tx_buffer = tcp::SocketBuffer::new(vec![0; 65536]); | ||
tcp::Socket::new(tcp_rx_buffer, tcp_tx_buffer) | ||
}; | ||
|
||
let client_socket = { | ||
let tcp_rx_buffer = tcp::SocketBuffer::new(vec![0; 65536]); | ||
let tcp_tx_buffer = tcp::SocketBuffer::new(vec![0; 65536]); | ||
tcp::Socket::new(tcp_rx_buffer, tcp_tx_buffer) | ||
}; | ||
|
||
let mut sockets: [_; 2] = Default::default(); | ||
let mut sockets = SocketSet::new(&mut sockets[..]); | ||
let server_handle = sockets.add(server_socket); | ||
let client_handle = sockets.add(client_socket); | ||
|
||
let start_time = Instant::now(); | ||
|
||
let mut did_listen = false; | ||
let mut did_connect = false; | ||
let mut processed = 0; | ||
while processed < 1024 * 1024 * 1024 { | ||
iface.poll(Instant::now(), &mut device, &mut sockets); | ||
|
||
let socket = sockets.get_mut::<tcp::Socket>(server_handle); | ||
if !socket.is_active() && !socket.is_listening() && !did_listen { | ||
debug!("listening"); | ||
socket.listen(1234).unwrap(); | ||
did_listen = true; | ||
} | ||
|
||
while socket.can_recv() { | ||
let received = socket.recv(|buffer| (buffer.len(), buffer.len())).unwrap(); | ||
debug!("got {:?}", received,); | ||
processed += received; | ||
} | ||
|
||
let socket = sockets.get_mut::<tcp::Socket>(client_handle); | ||
let cx = iface.context(); | ||
if !socket.is_open() && !did_connect { | ||
debug!("connecting"); | ||
socket | ||
.connect(cx, (IpAddress::v4(127, 0, 0, 1), 1234), 65000) | ||
.unwrap(); | ||
did_connect = true; | ||
} | ||
|
||
while socket.can_send() { | ||
debug!("sending"); | ||
socket.send(|buffer| (buffer.len(), ())).unwrap(); | ||
} | ||
} | ||
|
||
let duration = Instant::now() - start_time; | ||
println!( | ||
"done in {} s, bandwidth is {} Gbps", | ||
duration.total_millis() as f64 / 1000.0, | ||
(processed as u64 * 8 / duration.total_millis()) as f64 / 1000000.0 | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment here explaining the calculation (the definition of "significantly" from the PR body)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I've added as the doc comments, see https://github.com/smoltcp-rs/smoltcp/compare/ca9749d3e8c8a075568e0506ccc008d63cf7ea0f..fe179c918415d6c251384b24fdd6204060265431.