ithewei / libhv

🔥 比libevent/libuv/asio更易用的网络库。A c/c++ network library for developing TCP/UDP/SSL/HTTP/WebSocket/MQTT client/server.
https://github.com/ithewei/libhv/wiki
BSD 3-Clause "New" or "Revised" License
6.83k stars 1.24k forks source link

Cannot receive data after set jumbo frame on ubuntu #566

Closed WorstCodeWay closed 5 months ago

WorstCodeWay commented 5 months ago

Hi, I meet a problem after setting jumbo frames on ubuntu(server end-point) by

sudo ifconfig eth0 down
sudo ip link set eth0 mtu 9000
sudo ifconfig eth0 up

I cannot receive packets(maybe a larger packet, like 5000 bytes, I'm not sure). But my client can connect to that tcp-server on ubuntu.

PS:

  1. My tcp client is on windows and tcp server is on ubuntu
  2. I can capture that packet from Wireshark. and its total size is 5603

What am I missing?

ithewei commented 5 months ago

Answer from GPT:

Based on the commands you mentioned, it seems like you have correctly configured jumbo frames by increasing the Maximum Transmission Unit (MTU) of your network interface to 9000 bytes. However, there are a few additional considerations to keep in mind when working with jumbo frames:

Verify Jumbo Frame Support: Ensure that all devices in the network path, including your Windows client, Ubuntu server, and any intermediate network switches or routers, support jumbo frames. If any device in the path does not support jumbo frames, it can cause issues with packet transmission.
Consistent MTU Configuration: It's crucial to configure the MTU consistently on both ends of the communication. In your case, you've adjusted the MTU on the Ubuntu server, but you also need to verify and adjust the MTU on your Windows client to match the server's MTU.
Path MTU Discovery: Path MTU Discovery (PMTUD) allows devices to dynamically determine the maximum MTU size for a given network path. It relies on ICMP "Packet Too Big" messages to adjust the MTU as needed. Ensure that PMTUD is enabled on both the Ubuntu server and the Windows client. You can enable PMTUD on Ubuntu using the following command:
sudo sysctl net.ipv4.ip_no_pmtu_disc=0
For the Windows client, PMTUD is typically enabled by default, but you can verify it in the Windows registry.
Firewall Configuration: Check if any firewalls or security software on the Ubuntu server or the Windows client are blocking packets of larger sizes. Adjust the firewall settings accordingly to allow jumbo frames.
By ensuring jumbo frame support throughout the network path, configuring consistent MTU on both ends, enabling PMTUD, and checking firewall settings, you can troubleshoot and resolve any issues that may be preventing the successful transmission of jumbo frames.
WorstCodeWay commented 5 months ago

Answer from GPT:

Based on the commands you mentioned, it seems like you have correctly configured jumbo frames by increasing the Maximum Transmission Unit (MTU) of your network interface to 9000 bytes. However, there are a few additional considerations to keep in mind when working with jumbo frames:

Verify Jumbo Frame Support: Ensure that all devices in the network path, including your Windows client, Ubuntu server, and any intermediate network switches or routers, support jumbo frames. If any device in the path does not support jumbo frames, it can cause issues with packet transmission.
Consistent MTU Configuration: It's crucial to configure the MTU consistently on both ends of the communication. In your case, you've adjusted the MTU on the Ubuntu server, but you also need to verify and adjust the MTU on your Windows client to match the server's MTU.
Path MTU Discovery: Path MTU Discovery (PMTUD) allows devices to dynamically determine the maximum MTU size for a given network path. It relies on ICMP "Packet Too Big" messages to adjust the MTU as needed. Ensure that PMTUD is enabled on both the Ubuntu server and the Windows client. You can enable PMTUD on Ubuntu using the following command:
sudo sysctl net.ipv4.ip_no_pmtu_disc=0
For the Windows client, PMTUD is typically enabled by default, but you can verify it in the Windows registry.
Firewall Configuration: Check if any firewalls or security software on the Ubuntu server or the Windows client are blocking packets of larger sizes. Adjust the firewall settings accordingly to allow jumbo frames.
By ensuring jumbo frame support throughout the network path, configuring consistent MTU on both ends, enabling PMTUD, and checking firewall settings, you can troubleshoot and resolve any issues that may be preventing the successful transmission of jumbo frames.

Thanks for your reply. I can confirm this problem has nothing to do with libhv because neither of other tcp test tools can receive messages, and the captured packet is marked as [BAD TCP] by Wireshark.

So close this issue as it should be opened elsewhere.