Fix ping latency

This commit is contained in:
Gartox
2023-09-04 11:37:43 +02:00
parent 0b2b4e41c3
commit 270419f82c
2 changed files with 3 additions and 6 deletions
+1 -6
View File
@@ -42,11 +42,6 @@ impl Router {
pub const MTU: usize = 1486;
pub fn poll(&mut self, now: Instant) {
self.dispatch_outgoing(now);
self.process_incoming(now);
}
fn process_incoming(&mut self, now: Instant) {
for dev in self.devices.borrow_mut().iter_mut() {
if self.rx_buffer.is_full() {
break;
@@ -69,7 +64,7 @@ impl Router {
}
}
fn dispatch_outgoing(&mut self, now: Instant) {
pub fn dispatch(&mut self, now: Instant) {
while let Ok(((), packet)) = self.tx_buffer.dequeue() {
if let Ok(mut packet) = smoltcp::wire::Ipv4Packet::new_checked(packet) {
let dst_addr = IpAddress::Ipv4(packet.dst_addr());
+2
View File
@@ -259,6 +259,8 @@ impl Smolnetd {
// TODO: Check what if the bool returned by poll can be useful
iface.poll(timestamp, &mut self.router_device, &mut socket_set);
self.router_device.get_mut().dispatch(timestamp);
match iface.poll_delay(timestamp, &socket_set) {
Some(delay) if delay == Duration::ZERO => {}
Some(delay) => break ::std::cmp::min(MAX_DURATION, delay),