---
title: "W5500 FIN packet"
url: "https://maker.wiznet.io/forum/12658"
markdown_url: "https://maker.wiznet.io/forum/12658/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "Giorgi Kurtanidze"
created: "2018-01-15T17:48:17+09:00"
last_activity: "2018-01-18T19:34:21+09:00"
language: "en"
views: 1949
replies: 28
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5500 FIN packet

## Question

Asked by Giorgi Kurtanidze on 2018-01-15 in Ethernet Chips.

Hello all,

can i transfer data after receiving FIN packet(SOCKET_CLOSE_WAIT status, 0x1C)?
as i think w5500 will automatically send FIN-ACK packet after receiving FIN

thanks

## Replies

### Reply 1 by Eugeny, 2018-01-15

Technologically you can, but will other side be still listening?

Party sending FIN packet informs another party that former does not have anything more to say.

Thus if your application sees FIN state, it means that another device is done sending its data, and you must not expect anything from there. But it does not mean you can not send anything in the direction of that device. If that device is still listening, it will be acknowledging packets you send, but if that device is finished completely and closed all sockets and pursged its buffers, you will receive RST packet in response and W5500 will close the socket.

### Reply 2 by Giorgi Kurtanidze, 2018-01-16

i wrote w5500 driver, TCP client and server, it works perfectly, but sometimes connection process took too long time, debugging log shows that SYN packet is transmitted (0x15 status) ,
what might be ?

### Reply 3 by Eugeny, 2018-01-16 (in reply to reply 2)

Not enough information to tell you exactly; do you reuse same source port at W5500 side?

### Reply 4 by Giorgi Kurtanidze, 2018-01-16

yes , but after disconnecting,
here is log, frst is a ![Capture](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/3/3b032f83da214197f74388d3583c51b6c80a2f67.PNG)socket status, and second is command

### Reply 5 by Giorgi Kurtanidze, 2018-01-16

at first i am closing port(uninit all) than opening, and at last connecting , but sometimes timeout is generated by w5500

### Reply 6 by Eugeny, 2018-01-16

You must use different source ports if connecting to the same server with the same destination port # in less than several minutes.

Routers and target node may cache source port#/destination IP address/destination port# information and treat them as continuation as previous connection and do not respond with SYN and rather respond with RST.

### Reply 7 by Giorgi Kurtanidze, 2018-01-16

i am using source ports according IANA, from 49152 and above

TCP server destination port is 9999

### Reply 8 by Eugeny, 2018-01-16 (in reply to reply 7)

The point is that you use different port number every time you connect. So now you connected with local port # 49152, in 3 minutes you disconnected and in another minute you connect with local port # 49153 (for example).

### Reply 9 by Giorgi Kurtanidze, 2018-01-16

thanks, can i use random ports from 49152 - 65535?
as i guessed , i must use different port for each connection?

### Reply 10 by Eugeny, 2018-01-16 (in reply to reply 9)

Yes, you can use random port # in the range, just ensure your new generated random number is not the same as previous you were connected with. I think it should also be ok to use fixed 49152 after reset if you do not reset every minute.

### Reply 11 by Giorgi Kurtanidze, 2018-01-16

you meant RST packet?

### Reply 12 by Eugeny, 2018-01-16 (in reply to reply 11)

No, I mean you reset your device controlling W5500 (pressing reset button or power cycling it) so that W5500 appear on the network with port 49152 every minute for the same target host.

### Reply 13 by Giorgi Kurtanidze, 2018-01-16

for example , after resetting my device(w5500) i set src port 49152 , i received data from server, and server sent me FYN packet, i disconnect current connection. for new connection to the same server with same port and ip i must use 49153 or somethin, not 49152 , i will try that

### Reply 14 by Eugeny, 2018-01-16 (in reply to reply 13)

Right, it is advised doing this way to eliminate possible conflict with previous sessions. Try it and see if your board will still experience sticking in 0x15 state.

### Reply 15 by Giorgi Kurtanidze, 2018-01-16

Giorgi_Kurtanidze:

> 49152

unfortunately i have the same issue

((![Capture](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/b/b1d435965eff0f779aa47786100f6fa4ad16a7e2.PNG)

### Reply 16 by Eugeny, 2018-01-16 (in reply to reply 15)

Ok, so now time for Wireshark to see what is going on the network. SYN packet requires ACK packet, and looking at response (or prove the lack of such) may help. In your case, if it is possible, it would be good to install Wireshark on the server so that you can see activity at its interface related to this connection attempt.

First I would prove that server actually responds with SYN/ACK packet in case W5500 is hung in 0x15 state. If it does but W5500 is still in this state, it may happen that packet does not reach the chip.

### Reply 17 by Giorgi Kurtanidze, 2018-01-16

i also think so, that server is responded and packet is not delivered to chip,
but still i have not any idea how to solve, i can install Wireshark

### Reply 18 by Eugeny, 2018-01-16

Sometimes it happens here to me if there’re problems on the network. But route from my client to the server is relatively long, not sure about situation in your case. If it is short and under your control then you can perform exhaustive troubleshooting and get an idea what is wrong and how to fix or mitigate it.

### Reply 19 by Giorgi Kurtanidze, 2018-01-16

i tasted with google server, and it works , but with my server sometimes have connection issue, strange

### Reply 20 by Eugeny, 2018-01-16 (in reply to reply 19)

Giorgi_Kurtanidze:

> but with my server sometimes have connection issue, strange

If it is critical then you need further troubleshooting. It can be network issue, it can be network driver issue, issue with server setup etc. But deeper troubleshooting will need information like network topology, operating systems running, several tests like using Wireshark.

### Reply 21 by Giorgi Kurtanidze, 2018-01-16

tomorrow i will install Wireshark, :)) thanks again ))

### Reply 22 by Giorgi Kurtanidze, 2018-01-17

Hello, with remote server SYN packet is received by server, but in my side SYN-ACK packet is not recevied, in local network all is working perfectly, i think that is network issue

### Reply 23 by Giorgi Kurtanidze, 2018-01-18

Hello all, how can i make multiple connection on same port in server mode, if all sockets have the same port number, client request will get all sockets

### Reply 24 by Eugeny, 2018-01-18 (in reply to reply 23)

No, only one socket will be bound to the connection, but you can not know which one if you are listening with more than one socket.

### Reply 25 by Giorgi Kurtanidze, 2018-01-18

if it is so, i can check connection state and determine connected socket ))

### Reply 26 by Giorgi Kurtanidze, 2018-01-18 (in reply to reply 25)

for testing i opened 2 socket for listening, unfortunately client connected to both socket ((

[![Capture](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/e/efd62956fb928e2c8667f1da484fbcedf49ce5b9.PNG) Capture731×694 14.8 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/e/efd62956fb928e2c8667f1da484fbcedf49ce5b9.PNG)

### Reply 27 by Eugeny, 2018-01-18

Of course, first request went with getting web page contents, another went with favicon.ico which is automatically requested by the Chrome (or other browser).

### Reply 28 by Giorgi Kurtanidze, 2018-01-18

thank u very much ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12), i modified a little bit my code an it is working with 8 socket ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)

---

Source: https://maker.wiznet.io/forum/12658
