[Solved] No ARP ping packets transmitted from w5500 (TCP/IP works propertly)


#1

Hi,
I’ve used standart code from IPRAW ping example, changed only the way of debug output.
I use ping_auto(0,pingto); function, short init code is:

u8 pingto[]={10,10,10,4}; //PC IP
int8_t memsize[2][8] = {{2,2,2,2,2,2,2,2},{2,2,2,2,2,2,2,2}};

if(ctlwizchip(CW_INIT_WIZCHIP,(void*)memsize) == -1)
{ printf(“init fail”); while(1); }

for(i=0;i<_WIZCHIP_SOCK_NUM_;i++)
	{
		close(i);
		disconnect(i);
	}

network_init();

W5500 IP is 10.10.10.132. TCP/IP works propertly (I have web server on w5500).
Debug output is:

ping datum: 8,0,114,106,18,52,67,33,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,
Send Ping Request to Destination 10.10.10.4
ID:4660
SeqNum:17185
CheckSum:29290
Ping req timed out sn=0
ping datum: 8,0,114,104,18,53,67,34,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,
Send Ping Request to Destination 10.10.10.4
ID:4661
SeqNum:17186
CheckSum:29288
Ping req timed out sn=0
ping datum: 8,0,114,102,18,54,67,35,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,
Send Ping Request to Destination 10.10.10.4
ID:4662
SeqNum:17187
CheckSum:29286
Ping req timed out sn=0

ping datum is a byte representation of ping packet. W5500 “thought” that packet was sent, but WireShark shows nothing.


#2

ping_request function:

    uint8_t ping_request(uint8_t s, uint8_t *addr)
    {
      uint16_t i;

    	ping_reply_received = 0;
    	PingRequest.Type = PING_REQUEST;                   // Ping-Request
    	PingRequest.Code = CODE_ZERO;	                   // Always '0'
    	PingRequest.ID = htons(RandomID++);	       // set ping-request's ID to random integer value
    	PingRequest.SeqNum =htons(RandomSeqNum++);// set ping-request's sequence number to ramdom integer value
    	//size = 32;                                 // set Data size

    	/* Fill in Data[]  as size of BIF_LEN (Default = 32)*/
      	for(i = 0 ; i < BUF_LEN; i++)	                                
    			PingRequest.Data[i] = (i) % 8;		  //'0'~'8' number into ping-request's data 	
    	
    	 /* Do checksum of Ping Request */
    	PingRequest.CheckSum = 0;		               // value of checksum before calucating checksum of ping-request packet
    	PingRequest.CheckSum = htons(checksum((uint8_t*)&PingRequest,sizeof(PingRequest)));  // Calculate checksum
    	
         /* sendto ping_request to destination */
    	if (debug) debug_print_u8_arr("ping datum: ",(uint8_t *)&PingRequest,sizeof(PingRequest));
    	if(sendto(s,(uint8_t *)&PingRequest,sizeof(PingRequest),addr,3000)==0)  // Send Ping-Request to the specified peer.
    	  	{ if (debug) debug_print_par("Fail to send ping-reply packet sn=",s);} 			
    	else
      {
    	 	if (debug) 
    		{ debug_print_IP("Send Ping Request to Destination ",addr);
    			debug_print_par("ID:", htons(PingRequest.ID));
    			debug_print_par("SeqNum:", htons(PingRequest.SeqNum));
    			debug_print_par("CheckSum:", htons(PingRequest.CheckSum));
    		}
    	}
    	return 0;
    } // ping request

Please, notice to my mistake, if possible.


#3

Not clear what you are trying to achieve. Do you ping W550 and then your code answers or do you use W5500 code to ping other device?

This sounds strange and I have a suspicion that it is wireshark does not see the packet for some reason. To see it wirehsark must be installed on final network node, or on the bridge. ICMP packets are not broadcast, and hubs/routers will not route them to inappropriate locations/ports once knowing the right location of the destination.


#4

I use W5500 to ping another device, in my case, the PC where WireShark is installed. It can see the TCP communication with W5500, but does not see ping packets from it.

Ping is not is not disabled somewhere in network: I can ping W5500 from PC and ping PC from another devices.


#5

Ok, then I would say you have some W5500 configuration issue. Your code is fragmented, so hard ti find the cause. Do you use socket 0? Do you open socket 0 in IPRAW mode? I did not check, but are you sure that ICMP packet header is correct (however if not correct Wireshark would show it anyway as malformed packet). When W5500 performs send command, do its receive and send LEDs flash (so does it send physically?)


#6

Do you use socket 0? — YES
Do you open socket 0 in IPRAW mode? –YES with following code:
IINCHIP_WRITE(Sn_PROTO(s), IPPROTO_ICMP); // set ICMP Protocol
socket(s,Sn_MR_IPRAW,3000,0) -->>returned 0
When W5500 performs send command, do its receive and send LEDs flash — NO(!) (in TCP yes)

Socket switches to IPRAW, getSn_SR(0) returns 0x32

Sending packet sendto(s,(uint8_t *)&PingRequest,sizeof(PingRequest),addr,3000) returns 0


#7

What should I check next?


#8

Perform dump of the W5500 registers in the common register block and in socket 0. Looking into the values may give us idea what is wrong. But I think that the issue is more simple than this.

I never used this function, and you may check the following:

  1. does it really support sending in IPRAW mode? I think it should as algorithm should not differ except port definition which makes no sense in this mode, however it may happen that some additional actions are required for chip to actually send the data;
  2. value of s is still 0?
  3. (uint8_t *)&PingRequest returns correct pointer to the data?
  4. sizeof(PingRequest) returns value other than 0, and less or equal to size of TX buffer?
  5. addr is not 0.0.0.0?
  6. what should be the value of port # in case of IPRAW? You used 3000, can it cause issues?
  7. what Sn_IR register shows before and after (some time) calling sendto?

#9

I’ve just used mix of w5500 library files with different versions. Thanks and sorry for my inattention.