Skip to content
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

"Not enough space, dropping packet" #79

Closed
Bjarkil opened this issue Jan 21, 2018 · 7 comments
Closed

"Not enough space, dropping packet" #79

Bjarkil opened this issue Jan 21, 2018 · 7 comments

Comments

@Bjarkil
Copy link

Bjarkil commented Jan 21, 2018

I'll just get straight to the point.
For the past couple of weeks using this app, I have noticed that uploading files can be quite tricky.
When I am sending video files over gnirehtet, ranging from 5 to 50 MB, the packets are oftentimes dropped.
This results in stagnation of the upload or just a very slow upload.

In this file I have copied the cmd lines while trying to upload a video file of 42.14MB: upload attempt.txt.
In this example I have manually stopped the client right after the upload stagnated.
As you can see in the timestamps, I could not get more than (at maximum) 10 seconds of continuous upload. The effective transfer of the file in this, albeit short, time frame was just ~0.8Mbps, whilst I have a 4Mbps upload connection.

If there is more information you might require, I am more than willing to give it to you to solve this problem.

@rom1v
Copy link
Collaborator

rom1v commented Jan 21, 2018

Hi, thank you for your report.

It seems the network socket does not consume the stream received from the device quickly enough. But I guess the device TCP peer should slow down after a packet loss, to avoid congestion, which it apparently does not do.

Maybe the client-to-network buffer is too small, you could try to increase its size:

diff --git a/relay-rust/src/relay/tcp_connection.rs b/relay-rust/src/relay/tcp_connection.rs
index 94993936..108df459 100644
--- a/relay-rust/src/relay/tcp_connection.rs
+++ b/relay-rust/src/relay/tcp_connection.rs
@@ -151,7 +151,7 @@ impl TcpConnection {
             stream: stream,
             interests: interests,
             token: Token(0), // default value, will be set afterwards
-            client_to_network: StreamBuffer::new(4 * MAX_PACKET_LENGTH),
+            client_to_network: StreamBuffer::new(32 * MAX_PACKET_LENGTH),
             network_to_client: packetizer,
             packet_for_client_length: None,
             closed: false,

If it just delays the problem, then this is not the root cause.

According to the ignored packet TCP numbers, the packets are quite small (536 bytes), which is odd (the MTU is set to 16384). Maybe this floods the poll which may not send packets to network fast enough.

How much goes gnirehtet consume CPU when uploading a file? What is the device? What is the computer OS (linux, windows, mac)?

@Bjarkil
Copy link
Author

Bjarkil commented Jan 21, 2018

I am using a Xiaomi Mi A1 (although I had the same issue on my LG Nexus 5) connected to a PC running Windows 10 to send video files over KakaoTalk, but I have the same problem in other apps too.
My CPU usage is about 0.5%, it's really not intensive by any measure...

To be quite honest I don't know much about programming, so modifying the code of the program and recompiling will be quite a challenge to me. I have implemented the change you have suggested (I think?) but I am absolutely clueless as to what to do next, something like compiling the code? I haven't a clue...

Regardless, thank you for the timely reply!

@Bjarkil
Copy link
Author

Bjarkil commented Jan 30, 2018

Hello again.
I have managed to build a new rust server, but the problem persists.
errorlog30012018.txt
This is the output I get when I try to upload larger files.
This is with a server where client_to_network: StreamBuffer::new(16 * MAX_PACKET_LENGTH), the problem also persists when client_to_network: StreamBuffer::new(32 * MAX_PACKET_LENGTH) or 64.

@rom1v
Copy link
Collaborator

rom1v commented Jan 30, 2018

@Bjarkil Thank you for your tests, that's interesting. IMO the device TCP peer should slow down after a packet lost.

Do you have the same problem on other devices?

@rom1v
Copy link
Collaborator

rom1v commented Feb 25, 2018

@Bjarkil Could you test whether this version fixes the problem, please?

rom1v added a commit that referenced this issue Mar 1, 2018
The TCP connection acked packets received from the device immediately
after it stored them into its buffers, but before they were written to
the network socket.

This made the client wrongly assume that the connection was super-fast,
so the upload bandwidth was totally uncorrelated to the network socket
bandwidth.

As a consequence, the client filled the buffers up to saturation,
leading to packet drops, that slowed down uploads dramatically.

To make the client adapt the bittrate according to the associated
network socket, do not ack the data immediately, but only once it is
actually written to the network socket.

See issues:
 - <#84>
 - <#79>
@rom1v
Copy link
Collaborator

rom1v commented Mar 1, 2018

Fixed on dev.

@rom1v rom1v closed this as completed Mar 1, 2018
@rom1v
Copy link
Collaborator

rom1v commented Mar 2, 2018

It's in the v2.2 release: https://github.com/Genymobile/gnirehtet/releases/tag/v2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants