Icmp time exceeded on route when replying to modbus tcp

limboo13
Posts: 2
Joined: Mon Mar 06, 2023 9:56 am

Icmp time exceeded on route when replying to modbus tcp

Postby limboo13 » Mon Mar 06, 2023 10:02 am

Hi
I am using ESP32 with modbus tcp to connect from ESP32 as a slave to a master running on a device behind a router.
I am getting an error on the router with line icmp time exceeded when ESP32 is replying to the master. The packet routes just fine to the ESP32 and to the master but it gets dropped on the router in between on the way back. Is there any way to increase TTL for modbus ? It does not seem that the packet loops around because the destination ip is correct and the interface too. I am attaching the logs of the router in between the ESP32 and the modbus master. I am also running a websocket to a destination server which connects just fine.

Code: Select all

ip4_input: packet not for us.
ip4_forward: forwarding packet to 10.0.0.2
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x100000a (0xa28b, 0xa, 0x46be0000)
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x401a8c0 (0xbea28b, 0x1a8c0, 0x46000000)
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x100007f (0x8b, 0x7f, 0x46bea200)
ip4_input: packet not for us.
ip4_forward: forwarding packet to 139.162.190.70
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
ip4_output_if: st1
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        46     | (v, hl, tos, len)
+-------------------------------+
|     1315      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0xab11     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    1  |    4  | (src)
+-------------------------------+
|  139  |  162  |  190  |   70  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
151852 3 mongoose.c:4250:write_conn     1 0x38 snd 6/2048 rcv 0/2048 n=6 err=119
ip_input: iphdr->dest 0x401a8c0 netif->ip_addr 0x401a8c0 (0x1a8c0, 0x1a8c0, 0x4000000)
ip4_input: packet accepted on interface st
ip4_input:
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        42     | (v, hl, tos, len)
+-------------------------------+
|     4204      |010|       0   | (id, flags, offset)
+-------------------------------+
|   53  |    6  |    0x29cd     | (ttl, proto, chksum)
+-------------------------------+
|  139  |  162  |  190  |   70  | (src)
+-------------------------------+
|  192  |  168  |    1  |    4  | (dest)
+-------------------------------+
ip4_input: p->len 42 p->tot_len 42
tcp_recved: received 2 bytes, wnd 5744 (0).
151894 3 mongoose.c:4239:read_conn      1 0x38 snd 0/2048 rcv 0/2048 n=2 err=119
tcp_fasttmr: delayed ACK
ip4_output_if: st1
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        40     | (v, hl, tos, len)
+-------------------------------+
|     1316      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0xab16     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    1  |    4  | (src)
+-------------------------------+
|  139  |  162  |  190  |   70  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
ip_input: iphdr->dest 0x200000a netif->ip_addr 0x401a8c0 (0xa, 0x1a8c0, 0x2000000)
ip_input: iphdr->dest 0x200000a netif->ip_addr 0x100000a (0xa, 0xa, 0x2000000)
ip_input: iphdr->dest 0x200000a netif->ip_addr 0x100007f (0xa, 0x7f, 0x2000000)
ip4_input: packet not for us.
ip4_forward: forwarding packet to 10.0.0.2
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100000a (0xa8c0, 0xa, 0x1010000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x401a8c0 (0x1a8c0, 0x1a8c0, 0x1000000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100007f (0xc0, 0x7f, 0x101a800)
ip4_input: packet not for us.
icmp_time_exceeded from 10.0.0.2 to 192.168.1.1
ip4_output_if: ap2
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        56     | (v, hl, tos, len)
+-------------------------------+
|     1317      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    1  |    0xa29d     | (ttl, proto, chksum)
+-------------------------------+
|   10  |    0  |    0  |    1  | (src)
+-------------------------------+
|   10  |    0  |    0  |    2  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100000a (0xa8c0, 0xa, 0x1010000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x401a8c0 (0x1a8c0, 0x1a8c0, 0x1000000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100007f (0xc0, 0x7f, 0x101a800)
ip4_input: packet not for us.
icmp_time_exceeded from 10.0.0.2 to 192.168.1.1
ip4_output_if: ap2
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        56     | (v, hl, tos, len)
+-------------------------------+
|     1318      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    1  |    0xa29c     | (ttl, proto, chksum)
+-------------------------------+
|   10  |    0  |    0  |    1  | (src)
+-------------------------------+
|   10  |    0  |    0  |    2  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100000a (0xa8c0, 0xa, 0x1010000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x401a8c0 (0x1a8c0, 0x1a8c0, 0x1000000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100007f (0xc0, 0x7f, 0x101a800)
ip4_input: packet not for us.
icmp_time_exceeded from 10.0.0.2 to 192.168.1.1
ip4_output_if: ap2
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        56     | (v, hl, tos, len)
+-------------------------------+
|     1319      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    1  |    0xa29b     | (ttl, proto, chksum)
+-------------------------------+
|   10  |    0  |    0  |    1  | (src)
+-------------------------------+
|   10  |    0  |    0  |    2  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x100000a (0xa28b, 0xa, 0x46be0000)
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x401a8c0 (0xbea28b, 0x1a8c0, 0x46000000)
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x100007f (0x8b, 0x7f, 0x46bea200)
ip4_input: packet not for us.
[code]

tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application

User avatar
rudi ;-)
Posts: 1698
Joined: Fri Nov 13, 2015 3:25 pm

Re: Icmp time exceeded on route when replying to modbus tcp

Postby rudi ;-) » Wed Mar 08, 2023 11:17 am

limboo13 wrote:
Mon Mar 06, 2023 10:02 am
Hi
I am using ESP32 with modbus tcp to connect from ESP32 as a slave to a master running on a device behind a router.
I am getting an error on the router with line icmp time exceeded when ESP32 is replying to the master. The packet routes just fine to the ESP32 and to the master but it gets dropped on the router in between on the way back. Is there any way to increase TTL for modbus ? It does not seem that the packet loops around because the destination ip is correct and the interface too. I am attaching the logs of the router in between the ESP32 and the modbus master. I am also running a websocket to a destination server which connects just fine.

Code: Select all

ip4_input: packet not for us.
ip4_forward: forwarding packet to 10.0.0.2
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x100000a (0xa28b, 0xa, 0x46be0000)
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x401a8c0 (0xbea28b, 0x1a8c0, 0x46000000)
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x100007f (0x8b, 0x7f, 0x46bea200)
ip4_input: packet not for us.
ip4_forward: forwarding packet to 139.162.190.70
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
ip4_output_if: st1
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        46     | (v, hl, tos, len)
+-------------------------------+
|     1315      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0xab11     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    1  |    4  | (src)
+-------------------------------+
|  139  |  162  |  190  |   70  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
151852 3 mongoose.c:4250:write_conn     1 0x38 snd 6/2048 rcv 0/2048 n=6 err=119
ip_input: iphdr->dest 0x401a8c0 netif->ip_addr 0x401a8c0 (0x1a8c0, 0x1a8c0, 0x4000000)
ip4_input: packet accepted on interface st
ip4_input:
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        42     | (v, hl, tos, len)
+-------------------------------+
|     4204      |010|       0   | (id, flags, offset)
+-------------------------------+
|   53  |    6  |    0x29cd     | (ttl, proto, chksum)
+-------------------------------+
|  139  |  162  |  190  |   70  | (src)
+-------------------------------+
|  192  |  168  |    1  |    4  | (dest)
+-------------------------------+
ip4_input: p->len 42 p->tot_len 42
tcp_recved: received 2 bytes, wnd 5744 (0).
151894 3 mongoose.c:4239:read_conn      1 0x38 snd 0/2048 rcv 0/2048 n=2 err=119
tcp_fasttmr: delayed ACK
ip4_output_if: st1
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        40     | (v, hl, tos, len)
+-------------------------------+
|     1316      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    6  |    0xab16     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    1  |    4  | (src)
+-------------------------------+
|  139  |  162  |  190  |   70  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
ip_input: iphdr->dest 0x200000a netif->ip_addr 0x401a8c0 (0xa, 0x1a8c0, 0x2000000)
ip_input: iphdr->dest 0x200000a netif->ip_addr 0x100000a (0xa, 0xa, 0x2000000)
ip_input: iphdr->dest 0x200000a netif->ip_addr 0x100007f (0xa, 0x7f, 0x2000000)
ip4_input: packet not for us.
ip4_forward: forwarding packet to 10.0.0.2
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100000a (0xa8c0, 0xa, 0x1010000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x401a8c0 (0x1a8c0, 0x1a8c0, 0x1000000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100007f (0xc0, 0x7f, 0x101a800)
ip4_input: packet not for us.
icmp_time_exceeded from 10.0.0.2 to 192.168.1.1
ip4_output_if: ap2
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        56     | (v, hl, tos, len)
+-------------------------------+
|     1317      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    1  |    0xa29d     | (ttl, proto, chksum)
+-------------------------------+
|   10  |    0  |    0  |    1  | (src)
+-------------------------------+
|   10  |    0  |    0  |    2  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100000a (0xa8c0, 0xa, 0x1010000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x401a8c0 (0x1a8c0, 0x1a8c0, 0x1000000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100007f (0xc0, 0x7f, 0x101a800)
ip4_input: packet not for us.
icmp_time_exceeded from 10.0.0.2 to 192.168.1.1
ip4_output_if: ap2
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        56     | (v, hl, tos, len)
+-------------------------------+
|     1318      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    1  |    0xa29c     | (ttl, proto, chksum)
+-------------------------------+
|   10  |    0  |    0  |    1  | (src)
+-------------------------------+
|   10  |    0  |    0  |    2  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100000a (0xa8c0, 0xa, 0x1010000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x401a8c0 (0x1a8c0, 0x1a8c0, 0x1000000)
ip_input: iphdr->dest 0x101a8c0 netif->ip_addr 0x100007f (0xc0, 0x7f, 0x101a800)
ip4_input: packet not for us.
icmp_time_exceeded from 10.0.0.2 to 192.168.1.1
ip4_output_if: ap2
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        56     | (v, hl, tos, len)
+-------------------------------+
|     1319      |000|       0   | (id, flags, offset)
+-------------------------------+
|  255  |    1  |    0xa29b     | (ttl, proto, chksum)
+-------------------------------+
|   10  |    0  |    0  |    1  | (src)
+-------------------------------+
|   10  |    0  |    0  |    2  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x100000a (0xa28b, 0xa, 0x46be0000)
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x401a8c0 (0xbea28b, 0x1a8c0, 0x46000000)
ip_input: iphdr->dest 0x46bea28b netif->ip_addr 0x100007f (0x8b, 0x7f, 0x46bea200)
ip4_input: packet not for us.
[code]

tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application


It seems like the issue is with the router dropping the packet on the way back from the ESP32 to the master device. The error message suggests that the packet's TTL expired before reaching the destination. You can try increasing the TTL value of the packet, but it's not clear if that will solve the issue. It's possible that the router or firewall is blocking the packet. The logs suggest that the router is forwarding the packet to the correct destination, but the packet is still getting dropped. I recommend checking the router and firewall settings and make sure they allow the packet to pass through.


"AskRudi"
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪

limboo13
Posts: 2
Joined: Mon Mar 06, 2023 9:56 am

Re: Icmp time exceeded on route when replying to modbus tcp

Postby limboo13 » Wed Mar 08, 2023 8:54 pm

Hi Rudi
Thanks for replying.
Sorry my bad I forgot to mention that the router in between the route to the master is actually ESP32 too. I don't know if there is any firewall rules on ESP32. The ttl read from the ESP32 making the modbus response to the master is 255. Also the message that gets returned to the ESP32 making the modbus response is 'destination unreachable'. Which could mean that the ESP32 is just uncapable to route this modbus message. I am going to try earlier releases of IDF because I had some previous issues with upgrading to newer versions creating code compability issues. If anything comes to mind to try, please don't hesitate to reply.

Br.
Matt

Who is online

Users browsing this forum: No registered users and 194 guests