Why has my device has started failing to connect 90% of the time despite nothing having changed?
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by Eugeny ·
I do believe you must have started with looking at the networking logs rather than digging the device. Set up machine as a bridge or within the same LAN (but be sure it gets all the packets going to and from W5500) and see what is going on with the communication. Capture device must be as close to W5500 as possible. Share here the log if it is not confidential.
Network settings outside of the W5500 may have been changed. Depending on what is on the packet path and on the target device (location) W5500 tries to connect to. Logs must show what is going on (or what is NOT going on).
RE: RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by RJS ·
Thanks for the answer. I have a few questions though, sorry if they’re pretty basic.
What is the “machine” and “capture device” here? What logs should I share? Thanks again.
RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by Eugeny ·
Machine is any PC or anything else having Wireshark installed.
Capture device is this machine in the explanation above, which captures the traffic into the buffer and then you save this buffer into the log file (logs).
You put this machine (PC) in between W5500 and W5500’s outer world, bridging these PC’s connections (so that traffic goes through PC in both directions, and it can intercept the traffic). Install Wireshark onto this machine (PC) and run Wireshark to capture the traffic under consideration. Then save captured traffic into .pcapng file for analysis. If you have necessary knowledge, look into these logs, maybe you will immediately see something wrong. and will fix it.
RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by RJS ·
I’ve not used wireshark before, so I’ve tried a few tutorials but I’m having some trouble with a lot of the terminology. They all seem to assume a lot of knowledge I don’t have. I’m not sure how to set things up so the traffic goes through the PC. Please could you explain in more detail, or perhaps point me towards a tutorial that explains how to use wireshark for this specific setup? Is there anything I need other than the faulty device, a PC with wireshark, and an ethernet cable? In the meantime I’ll continue to try to understand on my own.
Thank you again, I’m extremely grateful for your help.
RE: RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by Eugeny ·
The first two in the search list:
Help to set up a “pass through bridge” sniffer
Capture network traffic with Wireshark
Perform Wireshark installation first, play with it, see how data is being captured and look into the packet details (even if you do not fully understand what is in there
).
And after you are more or less experiences making Wireshark capture, play bridging or network sharing.
RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by RJS ·
I understand the basics of how to use wireshark in general, which seems to be what the second link explains. What I’m struggling with is how to set everything else up so that I can use wireshark to capture the relevant traffic. I don’t know what the physical setup should be. Maybe the first link explains this, but to me it seems to have skipped this step as the person who asked the question already understood it. In any case, I got as far as
but I only have one ethernet port. I do have a VAR11N-300 repeater/bridge, can that be used in place of a usb ethernet dongle? Or can I just use wifi? What should the PC be connected to via the ethernet cable(s) - one to the router and one to the board with the W5500 that I am debugging? Or does the board need to be connected to the router?
I tried reading this for example: Ethernet · Wiki · Wireshark Foundation / Wireshark · GitLab
but found it impossible to follow.
RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by Eugeny ·
You are right, the PC must have at least 2 LAN adapters. What type - clearly wired RJ-45 for W5500, other end does not matter (wired or WiFi or whatever). PC must be on the way of the packets - one of its network interfaces is connected to W5500, and another to the network W5500 usually was connected to. If it will be slightly clearer, PC is a “man in the middle” which will monitor and log everything going through it.
RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by RJS ·
Managed to get it working, thanks. What should I be looking for? Looks like the relevant packets are TCP/HTTP? I can see that when it fails to connect I get a few “Bad TCP” packets, and when it succeeds I get a lot of TCP/HTTP packets.
When it fails I get a (not Bad) TCP packet with info:
49155 → 80 [SYN] Seq=0 Win=2048 Len=0 MSS=1460followed by several Bad TCP packets with info either:
[TCP Retransmission] [TCP Port numbers reused] 49155 → 80 [SYN] Seq=0 Win=2048 Len=0 MSS=1460or
[TCP Port numbers reused] 49155 → 80 [SYN] Seq=0 Win=2048 Len=0 MSS=1460When it works I get several which look similar to the Bad TCP packets:
80 → 49155 [SYN, ACK] Seq=0 Ack=1 Win=26883 Len=0 MSS=145249155 → 80 [ACK] Seq=1 Ack=1 Win=2048 Len=049155 → 80 [PSH, ACK] Seq=1 Ack=1 Win=2048 Len=470 [TCP segment of a reassembled PDU]Is that at all useful or do I need to be looking in the more detailed logs for each packet? I’d rather avoid sending the entire log, just to be safe.
RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by Eugeny ·
Your problem is you reusing same local port number every time. You must use different local port for every connection (e.g. +1 every time for new connection). I do not know why it was working before, but in some cases it will not work because networking equipment will think that current packet is continuation of the previous TCP session with the same port number.
RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by RJS ·
There are 8 sockets right? Should I just loop through all 8 every time until I get a connection?
RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by Eugeny ·
No, you must, when you open next TCP connection, use different local port number. Use some global value between 1000-60000 and perform +1 to this global variable after you use it to open new socket.
If you always use same port number (in your case 49155) for TCP, networking nodes may have difficulties identifying what socket (data stream) specific packet relates to. I am sure they can, but not all the nodes are that intelligent. Reusing same port number for subsequent connections is also a bad idea because next packet may be thought relating to connection which was already closed. Therefore, the rule is to use unique port numbers for any open socket and ensure reuse of just used port number to as distant time as possible (so that caches expire, and networking equipment ‘forgot’ about previous connection with the same port number).
Do you use W5500 in server mode or client mode? You ‘get’ connection when you are in server mode, you ‘make’ connection when you are in client mode.
In client mode you may say ‘get connected’ (which is applicable for server mode too).
RE: Why has my device has started failing to connect 90% of the time despite nothing having changed?
by RJS ·
I see, is that just something you should know in general (regardless of hardware/libraries used) before you start?
In the code in my original post, sock->port in
connect()is 80, not 49155. Am I looking in the wrong place? I haven’t found anywhere else that the code where 49155 could be used as a port yet. The port that is used is determined by:params->port = (params->useHTTPS)?443:80;which from a quick google seems to make sense.
When does a new port number need to be used - or to put it another way: when is a new TCP connection opened? Does it happen constantly, or only on startup, or any time connection is lost and has to be remade? Or none of those?
Sorry for the confusion, I used “get” in the colloquial/non-technical sense. I was just being imprecise with my language, I should have used “make”.