SSU: Increase max IPv6 MTU (proposal #127)

This commit is contained in:
zzz
2016-10-25 13:39:33 +00:00
parent 80966d60c1
commit d2f7b65282
4 changed files with 17 additions and 6 deletions

View File

@@ -551,7 +551,8 @@ class PacketBuilder {
// the packet could have been built before the current mtu got lowered, so
// compare to LARGE_MTU
if (off + (ipHeaderSize + UDP_HEADER_SIZE) > PeerState.LARGE_MTU) {
int maxMTU = peer.isIPv6() ? PeerState.MAX_IPV6_MTU : PeerState.LARGE_MTU;
if (off + (ipHeaderSize + UDP_HEADER_SIZE) > maxMTU) {
_log.error("Size is " + off + " for " + packet +
" data size " + dataSize +
" pkt size " + (off + (ipHeaderSize + UDP_HEADER_SIZE)) +

View File

@@ -253,7 +253,9 @@ class PeerState {
*/
private static final int MAX_SEND_MSGS_PENDING = 128;
/*
/**
* IPv4 Min MTU
*
* 596 gives us 588 IP byes, 568 UDP bytes, and with an SSU data message,
* 522 fragment bytes, which is enough to send a tunnel data message in 2
* packets. A tunnel data message sent over the wire is 1044 bytes, meaning
@@ -277,10 +279,12 @@ class PeerState {
* IPv6/UDP header is 48 bytes, so we want MTU % 16 == 0.
*/
public static final int MIN_IPV6_MTU = 1280;
public static final int MAX_IPV6_MTU = 1472; // TODO 1488
public static final int MAX_IPV6_MTU = 1488;
private static final int DEFAULT_MTU = MIN_MTU;
/*
/**
* IPv4 Max MTU
*
* based on measurements, 1350 fits nearly all reasonably small I2NP messages
* (larger I2NP messages may be up to 1900B-4500B, which isn't going to fit
* into a live network MTU anyway)
@@ -301,6 +305,12 @@ class PeerState {
*/
public static final int LARGE_MTU = 1484;
/**
* Max of IPv4 and IPv6 max MTUs
* @since 0.9.28
*/
public static final int MAX_MTU = Math.max(LARGE_MTU, MAX_IPV6_MTU);
private static final int MIN_RTO = 100 + ACKSender.ACK_FREQUENCY;
private static final int INIT_RTO = 3*1000;
public static final int INIT_RTT = INIT_RTO / 2;

View File

@@ -189,7 +189,7 @@ class UDPSender {
public void add(UDPPacket packet) {
if (packet == null || !_keepRunning) return;
int psz = packet.getPacket().getLength();
if (psz > PeerState.LARGE_MTU) {
if (psz > PeerState.MAX_MTU) {
_log.error("Dropping large UDP packet " + psz + " bytes: " + packet);
return;
}

View File

@@ -2143,7 +2143,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
mtu = _mtu;
}
}
if (mtu < PeerState.LARGE_MTU)
if (mtu != PeerState.LARGE_MTU)
options.setProperty(UDPAddress.PROP_MTU, Integer.toString(mtu));
if (directIncluded || introducersIncluded) {