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

Reduce MTU on all batXX devices #80

Closed
lemoer opened this issue Sep 10, 2020 · 5 comments
Closed

Reduce MTU on all batXX devices #80

lemoer opened this issue Sep 10, 2020 · 5 comments

Comments

@lemoer
Copy link
Contributor

lemoer commented Sep 10, 2020

Auch wenn wir die MTU auf den fastd interfaces begrenzen, weiß der TCP-Layer auf höheren nicht inhärent davon, da batman das ganze für die höheren Layer wieder transparent macht. Normal nutzen wir da Clamping auf die Path MTU.

Leider klappt das ganze nicht, wenn unsere MTU auf den batXX devices zu groß ist:

root@FFH-Burg-LTE:~# tcpdump -n -i br-wan
01:29:13.408378 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.408439 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.408518 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.408585 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.408658 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.408765 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.408813 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.408881 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.408949 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.409021 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.409095 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.409167 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820
01:29:13.409240 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 820

Wenn ich nun auf dem Supernode folgendes ausführe ip link set mtu 1362 dev bat18:

01:30:30.790167 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 1424
01:30:30.790285 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 1424
01:30:30.792173 IP 192.168.8.101.49374 > 185.197.132.140.10018: UDP, length 151
01:30:30.792774 IP 192.168.8.101.49374 > 185.197.132.140.10018: UDP, length 114
01:30:30.798168 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 1424
01:30:30.798282 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 1424
01:30:30.799151 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 1424
01:30:30.799264 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 1424
01:30:30.802419 IP 192.168.8.101.49374 > 185.197.132.140.10018: UDP, length 114
01:30:30.810157 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 1424
01:30:30.810270 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 1424
01:30:30.811113 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 1424
01:30:30.812167 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 1424
01:30:30.812281 IP 185.197.132.140.10018 > 192.168.8.101.49374: UDP, length 1424

-> keine Fragmentierung mehr!

Im Speedtest bringt das bei mir hier gerade etwa +50% Speed. Das mag aber von Anschluss zu Anschluss unterschiedlich sein.

Die MTU sollte so korrekt berechnet sein: 1362 = 1394 - 32 (siehe hier, "usable client mtu": Link). Wir sollten also auf allen Bat-Devices die MTU 1362 ausrollen.

@lemoer
Copy link
Contributor Author

lemoer commented Sep 13, 2020

Hmmm. Ok es schaut so aus, als ob das auf diese Weise doch keine gute Idee wäre, weil viele (ahnungslose) ISPs in der Welt die "ICMP-Packet too big"-Pakete aussperren.

Wir können das also nur darüber fixen indem wir die MSS auf einen festen Wert setzen. In der MSS sind noch IP und TCP-Header enthalten. Die MSS ist also nochmal 40 bytes (IPv4) bzw 60 bytes (IPv6) kleiner als die MTU.

IPv4:

outerface eth0 proto tcp tcp-flags (SYN RST) SYN TCPMSS set-mss 1322;

IPv6:

outerface eth0 proto tcp tcp-flags (SYN RST) SYN TCPMSS set-mss 1302;

Leider funktioniert das nur in der FORWARD chain, sodass unsere internen IPerf-Server bspw. das nicht mitbekommen.

@1977er
Copy link
Member

1977er commented Sep 13, 2020

Könnte man argumentieren, dass sie zumindest bei IPv6 sich sowieso in den Fuß schießen, wenn sie das tun?

@lemoer
Copy link
Contributor Author

lemoer commented Sep 14, 2020 via email

@lemoer
Copy link
Contributor Author

lemoer commented Jan 6, 2021

For doc purposes, to test if any packet size is causing errors.

for mtu in $(seq 1300 1500); do printf "%d: " "$mtu"; ping6 -M do -s $((mtu-48)) \
     -c 1 fdca:ffee:8::7001 2>&1 | grep loss; done
1300: 1 packets transmitted, 1 received, 0% packet loss, time 0ms
1301: 1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
1302: 1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
1303: 1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
...

@lemoer lemoer mentioned this issue Jan 6, 2021
14 tasks
CodeFetch added a commit that referenced this issue Jan 17, 2021
This commit creates a dummy interface with the "bottleneck" MTU
among our VPN path (currently batadv - see issue #80).
Furthermore it creates an iptables DNAT rule which changes the
destination IP address of incoming QUIC (UDP 443) packets which
exceed the bottleneck MTU to a special IPv4 continuity address
which is part of the subnet of the dummy interface.
When an oversized QUIC packet arrives, it will thus be routed
to the dummy interface which in turn generates an ICMP destination
unreachable (fragmentation needed) packet as the packet does
not fit the MTU of the dummy interface.
The QUIC servers will react to the ICMP packet by changing the
PMTU of their UDP sockets according to the maximum MTU advertised
in the ICMP message, which is the dummy interface's MTU.
CodeFetch added a commit that referenced this issue Jan 17, 2021
This commit creates a dummy interface with the "bottleneck" MTU
among our VPN path (currently batadv - see issue #80).
Furthermore it creates an iptables DNAT rule which changes the
destination IP address of incoming QUIC (UDP 443) packets which
exceed the bottleneck MTU to a special IPv4 continuity address
which is part of the subnet of the dummy interface.
When an oversized QUIC packet arrives, it will thus be routed
to the dummy interface which in turn generates an ICMP destination
unreachable (fragmentation needed) packet as the packet does
not fit the MTU of the dummy interface.
The QUIC servers will react to the ICMP packet by changing the
PMTU of their UDP sockets according to the maximum MTU advertised
in the ICMP message, which is the dummy interface's MTU.
CodeFetch added a commit that referenced this issue Jan 17, 2021
This commit creates a dummy interface with the "bottleneck" MTU
among our VPN path (currently batadv - see issue #80).
Furthermore it creates an iptables DNAT rule which changes the
destination IP address of incoming QUIC (UDP 443) packets which
exceed the bottleneck MTU to a special IPv4 continuity address
which is part of the subnet of the dummy interface.
When an oversized QUIC packet arrives, it will thus be routed
to the dummy interface which in turn generates an ICMP destination
unreachable (fragmentation needed) packet as the packet does
not fit the MTU of the dummy interface.
The QUIC servers will react to the ICMP packet by changing the
PMTU of their UDP sockets according to the maximum MTU advertised
in the ICMP message, which is the dummy interface's MTU.
CodeFetch added a commit that referenced this issue Jan 18, 2021
This commit creates a dummy interface with the "bottleneck" MTU
among our VPN path (currently batadv - see issue #80).
Furthermore it creates an iptables DNAT rule which changes the
destination IP address of incoming QUIC (UDP 443) packets which
exceed the bottleneck MTU to a special IPv4 continuity address
which is part of the subnet of the dummy interface.
When an oversized QUIC packet arrives, it will thus be routed
to the dummy interface which in turn generates an ICMP destination
unreachable (fragmentation needed) packet as the packet does
not fit the MTU of the dummy interface.
The QUIC servers will react to the ICMP packet by changing the
PMTU of their UDP sockets according to the maximum MTU advertised
in the ICMP message, which is the dummy interface's MTU.
@CodeFetch
Copy link
Contributor

Duplicate of #64

@CodeFetch CodeFetch marked this as a duplicate of #64 Feb 12, 2021
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

3 participants