diff --git a/linux/README.md b/linux/README.md index 1fcb4c4..5ff62e9 100644 --- a/linux/README.md +++ b/linux/README.md @@ -19,10 +19,14 @@ IP address and switch the interface on. For example: /root/esptun tun0 /dev/ttyS1 "accesspointname" "secretpassword" 192.168.122.21 23232 + /sbin/ip link set dev tun0 mtu 1472 /sbin/ip addr add 10.0.1.2/24 dev tun0 /sbin/ip link set tun0 up /sbin/ip route add default via 10.0.1.1 dev tun0 +(setting the MTU to `1500-20-8` the typical network MTU minus IP and UDP header overhead, because +otherwise the ESP's network stack will drop the oversized packets) + Host side --------- @@ -30,7 +34,8 @@ On the other endpoint the tunnel is expected to be a host running `socat` or sim the tunnel. For example: sudo socat UDP:192.168.2.127:23232,bind=192.168.122.21:23232 \ - TUN:10.0.1.1/24,tun-name=tundudp,iff-no-pi,tun-type=tun,su=$USER,iff-up + TUN:10.0.1.1/24,tun-name=tundudp,iff-no-pi,tun-type=tun,su=$USER,iff-up & + sudo ip link set dev tundudp mtu 1472 Optionally, enable forwarding and masquerading: diff --git a/linux/esptun.c b/linux/esptun.c index 681f740..7285b39 100644 --- a/linux/esptun.c +++ b/linux/esptun.c @@ -395,12 +395,12 @@ static bool esp_read_responses(int fd, bool early_terminate) } /** Send a packet to ESP interface. */ -static void esp_tx_packet(int fd, const uint8_t *esp_buffer, size_t size) { +static void esp_tx_packet(int fd, const uint8_t *buffer, size_t size) { write_all(fd, S("AT+CIPSEND=")); write_uint(fd, size); write_all(fd, S("\r\n")); if (esp_read_responses(fd, false)) { - write_all(fd, esp_buffer, size); + write_all(fd, buffer, size); esp_read_responses(fd, false); } }