TCP Data Receive problem with W5100


#1

Hello
I have a W5100 Module with an SPI connection to Spartan 6. Device’s ping is done and i can connect to device and send a TCP packet to it(trough “packet sender” application). But INT pin doesn’t set to zero.

w5100 IP: 192.168.0.113
MAC: 10:00:00:00:00:00
Interrupt Mask Register :0x"EF"(let all INT’s)
S0_PORT:1000
and OPEN socket 0 and set it to LISTEN mode .
what’s the problem?

Wireshark capture:


#2

You seem to be closing socket (without disconnect) as soon as connection is established. RST is an indication of the closed socket at W5100 side.


#3

I don’t disconnect the connection at all. It seems when the PSH flag or in some case FNS flag in my TCP packet is set as 1*, the connection closed.

  • it’s automatically sent by packet sender.

#4

PSH flag received from remote device within the packet can not close socket on W5100. You close it yourself by your code/FPGA as soon as connection is established.


#5

The device is directly connected to my laptop.
I read that PSH is push flag and means that layer 4 should push the data to layer 5. that’s not true?
I have nothing to do with Socket 0 Command Register([0x0401) to close the connection.


#6

Push flag has nothing to do with INT pin. This is true.
You must dig into your W5100 driving code. As I asid I suspect you close socket immediately when it got to established state. It is true?


#7

I have 2 Line of code deal with 0x0401 address(S0_CR). All are set in initialize:
1- set it to 0x01 => open it
2- Set it to 0x02 => LISTEN mode
Is it false !?


#8

Looks like you follow chapter 5.2.1.1 steps (at least I hope so). Try socket status register instead of interrupt bits to see what socket status is at each point of time. It is impossible to tell you exactly what is going on because you did not provide detailed information on common and socket register settings. But there seem to be some configuration or logical mistake.


#9

As @Eugeny said, you have to follow chapter 5.2.1.1 step…

when connection operation occurs, Sn_SR value change from SOCK_INIT(0x13) to SOCK_ESTABLISHED(0x17).
You should check whether or not it’s Sn_IR is Sn_IR_CON(0x01).


#10

Hi again
I developed my code one good step and now i see CON INT and RECV INT.
After receiving an interrupt, I read S0_IR(just Socket_0 interrupt is masked) and then:
1- if connection interrupt=> wait for data RECV interrupt
2- if data RECV interrupt => Data Reading procedure and then go to RE_OPEN state
3- else => go to RE_OPEN state

RE_OPEN state: close socket(send X"10" to Sn_CR) and re-open it and set the listen Mode on and wait for new INT

I cant see the last ACK from W5100 and it is probably because of I can’t understand the Disconnecting protocol. can any one explain it in the Register_level(so that i can implement it on FPGA)?


#11

What you want to achieve in overall? What task 5100 is going to perform?

Remote device is not expected to send data in more than one packet? Why you close socket as soon as something is received? See my first question - what ar you doing with W5100?


#12

The ethernet connection is for sending command from PC to FPGA board. Every command is 6 Byte (in one PKT) and maybe send one command in an hour.


#13

In the first picture I seew packet containing 4 bytes from the PC.

Datasheet is very clear on what you must do and why. You even know the byte count to receive.

  1. You open socket in listening state.
  2. You get connection (0x17).
  3. You wait for data of either predefined length (6 bytes), or until PC disconnects (SR becomes something other than 0x17).
  4. You perform disconnect.
  5. You close socket, and go to step 1.

#14

you means this?
Set Sn_CR to DISCON(0x08)

and this means :
Set Sn_CR to CLOSE(0x10)
?

Do i need to check TIME OUT?
What means the state of “CLOSE?” on the flowchart?


#15

When SR is 0x00.

Yes, it is disconnect, You may choose not to wait until other party disconnects. Just perform DISCON, then, after CR changes to 0x00, perform CLOSE, and then perform OPEN, and then LISTEN. All new commands must be issued when CR is 0x00.


#16

According to flowchart and your phrase:
when SR is 0x00 then i should Re-close the socket by setting Sn_CR to 0x10?


#17

Can you pleae look into datasheet pages 29-31? There’s each state described in there.