Author Topic: W5300 problem in sending TCP packets to PC  (Read 2656 times)

0 Members and 1 Guest are viewing this topic.

Offline javad2040Topic starter

  • Contributor
  • Posts: 28
  • Country: us
W5300 problem in sending TCP packets to PC
« on: August 24, 2017, 09:15:29 am »
Hi,
I have a Custom made FPGA board for W5300, I have inited all the things and my basic hardware is working fine,
I can get a ping from the board.

The problem is that I can not send any TCP packets to PC but I can receive TCP packets, I have done every thing that the data sheet says, I will stock in this state that
My Board will only send fixed numbers to the PC, I think I will stock in this stated that's mentioned in the Datasheet of W5300 in page 99

Do you have any Idea what might be wrong? have you seen something similar?

Regards
 

Offline Whales

  • Super Contributor
  • ***
  • Posts: 1899
  • Country: au
    • Halestrom
Re: W5300 problem in sending TCP packets to PC
« Reply #1 on: August 24, 2017, 10:22:34 pm »
To get TCP working there are so many complex layers that need to be working first.  Don't try and solve everything at once, try and isolate out some features so you are testing less at one time.

IP and netmasks on both devices?  Have you run a wireshark capture on the computer, set to promiscuous mode?

Can you get the board to output things other than TCP packets?  UDP?  ARP?  ICMP (eg does it reply to pings)?

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3717
  • Country: us
Re: W5300 problem in sending TCP packets to PC
« Reply #2 on: August 25, 2017, 06:23:16 am »
Quote
The problem is that I can not send any TCP packets to PC but I can receive TCP packets

It isn't at all clear what you mean by this.  TCP requires packets flowing in both directions for session establishment and for data transmission.  So if you can establish a connection, it means you have packets moving in both directions.  In this case, any problem you have is almost certainly that you are not sending the data to the W5300 chip properly (like you are writing to the wrong register).  If you mean that you mean that you can't establish a connection because your SYN never gets ACKed, then check IP settings on the wiznet chip and firewall settings on your PC.

Are you using the wiznet socket approximation library or rolling your own?  I strongly recommend the provided library if your microcontroller supports it.
 

Offline javad2040Topic starter

  • Contributor
  • Posts: 28
  • Country: us
Re: W5300 problem in sending TCP packets to PC
« Reply #3 on: August 25, 2017, 07:17:54 pm »
thank you for reply.
Since i use FPGA, the library for w5300 doesn't exist and i forced to write VHDL code for w5300. I set all register values and addresses correctly ex: MAC,IP,Gateway and Subnet values are set and pinging work correctly.
Also i can send Packets form PC to w5300 and FPGA, that they received correctly by FPGA, but the problem is that the PC can not receive the correct and same Packets that sent to FPGA.
I debug the received Packet by FPGA that is true but the received Packets by PC is dummy value that often is fixed value(191 29 191 29 ...).
I force to use TCP mode and other mode is not used in my project.
I guess the problem is related to Chip, since i use "How_to_Test_Internal_TX_RX_Memory" document that the testing of TX-FIFO is fails.
please help me to solve this problem.
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 26906
  • Country: nl
    • NCT Developments
Re: W5300 problem in sending TCP packets to PC
« Reply #4 on: August 25, 2017, 07:29:42 pm »
The first step is to use Wireshark to see what is going on on the network. Then use a logic analyser or oscilloscope to verify you are sending the correct data to the W5300. Debugging is all about dividing your system in smaller pieces and checking if each of them works properly by examining the data flowing between the pieces.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline ejeffrey

  • Super Contributor
  • ***
  • Posts: 3717
  • Country: us
Re: W5300 problem in sending TCP packets to PC
« Reply #5 on: August 26, 2017, 05:54:38 am »
Since i use FPGA, the library for w5300 doesn't exist and i forced to write VHDL code for w5300. I set all register values and addresses correctly ex: MAC,IP,Gateway and Subnet values are set and pinging work correctly.

Good.

Quote
Also i can send Packets form PC to w5300 and FPGA, that they received correctly by FPGA, but the problem is that the PC can not receive the correct and same Packets that sent to FPGA.

Just to clear up a misconception: TCP is a byte stream protocol, not packet based.  So IP packets are going back and forth in both directions to successfully transmit data in either direction, your problem seems to be with the higher level TCP data streams.

Quote
I debug the received Packet by FPGA that is true but the received Packets by PC is dummy value that often is fixed value(191 29 191 29 ...).

I don't understand what this means.  Are you not receiving data at all on the PC, or are you receiving incorrect data?  If you are receiving incorrect or corrupt data, how does that work?  Is it only when there should be real data, or do you get the dummy data even when the FPGA should be doing nothing?  Are you checking the return code from recv()?  Maybe the session has disconnected and the recv() call is failing.  Are you using non-blocking IO?

Quote
I force to use TCP mode and other mode is not used in my project.

It would still be good to write a test bitstream for the FPGA that sends UDP or RAW packets and see if you see them in wireshark and a simple receiver program on your PC.  It would also be good to write a dummy application on a PC that emulates (even in a very crude way) what you expect your FPGA + wiznet chip to do.  That will give you a way to test out your PC application separately from the implementation of networking on the FPGA.

I guess the problem is related to Chip, since i use "How_to_Test_Internal_TX_RX_Memory" document that the testing of TX-FIFO is fails.
please help me to solve this problem.
[/quote]
 

Offline javad2040Topic starter

  • Contributor
  • Posts: 28
  • Country: us
Re: W5300 problem in sending TCP packets to PC
« Reply #6 on: August 28, 2017, 06:32:58 pm »
Quote
Also i can send Packets form PC to w5300 and FPGA, that they received correctly by FPGA, but the problem is that the PC can not receive the correct and same Packets that sent to FPGA.
Quote
Just to clear up a misconception: TCP is a byte stream protocol, not packet based.  So IP packets are going back and forth in both directions to successfully transmit data in either direction, your problem seems to be with the higher level TCP data streams.

I use Visual Studio and C# for send(receive) data to(from) W5300 and FPGA. I use Network class and socket programming. also i use TCP protocol and byte array for sending and receiving data.

Quote
I debug the received Packet by FPGA that is true but the received Packets by PC is dummy value that often is fixed value(191 29 191 29 ...).

Quote
I don't understand what this means.  Are you not receiving data at all on the PC, or are you receiving incorrect data?  If you are receiving incorrect or corrupt data, how does that work?  Is it only when there should be real data, or do you get the dummy data even when the FPGA should be doing nothing?  Are you checking the return code from recv()?  Maybe the session has disconnected and the recv() call is failing.  Are you using non-blocking IO?

I receive data but data is incorrect and is fixed value. I check the chip after Send command, the session is established. I use both blocking and non-blocking IO that the result is same(in both manner the received data is faulty).

Quote
It would still be good to write a test bitstream for the FPGA that sends UDP or RAW packets and see if you see them in wireshark and a simple receiver program on your PC.  It would also be good to write a dummy application on a PC that emulates (even in a very crude way) what you expect your FPGA + wiznet chip to do.  That will give you a way to test out your PC application separately from the implementation of networking on the FPGA.
Since i forced to use TCP protocol for my project and also my time for deliver the project is limit ,implementation the other protocol is impossible and thank you for suggestion.   
I guess that the chip is corrupted and i decide to change it by another, probably my problem will solve.
 

Offline javad2040Topic starter

  • Contributor
  • Posts: 28
  • Country: us
Re: W5300 problem in sending TCP packets to PC
« Reply #7 on: September 05, 2017, 07:47:37 pm »
hi
fortunately my problem is solved. The problem is related to MTYPER reg that it wasn't correct value, i set it correctly and the problem solved but new problem is appears:
I send data to W5300 that it saved to FPGA and send it back to W5300 Correctly. But when read the data from W5300, the two first received data is zero or dummy value.
can everybody help me to solve it?
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf