WIZnet Developer Forum

How is ARP Timeout indicated?

I set up an UDP socket. With Wireshark I can see everthing works as expected.
even ARP works according the timeout and retry settings.
sending a message to a existing node it arrives. processing time only a few milli seconds.
adressing a not xisting Node does take even longer. the function call to sendto returns exactly after the timeout/retry period.
broadcast messages are also possible, without the need of a ARP interaction. great!

BUT, there is not flag indicating the timeout occured. I expected the Sn_IR register will set bit 3 (Sn_IR[3]), but i does not.
the find out whether a adressed node is existing can only be done by measuring the time until the function terminated?

do anybody know where I find the right flag?

According to datasheet (see page 39 in RCR explanation section) timeout should be set as you explain.
You must enable interrupts using SIMR and Sn_IMR. Do you do it?

Hi Eugeny
Thank you. RCR works very well. the timeout is exactly the value I gave the chip byy RTR and RCR.
I also played wir the Maskbits including SIR. I understand, if a IR Bit is set due to an event the mask bits enable the interrupt go through.
My problem is, that the Flags are never set. even if I am polling the register.
Again on the network side every is absolutely fine. only the “CPU side” is the issue.

Datasheets is a little confusing about the explanation of the interrupt registers.

Socket interrupt control:

  1. Sn_IR is the bitmap you read to check for specific event. Its bits will be set only if corresponding bit in Sn_IMR is set, otherwise bits are never set. For example, if Sn_IMR=0x17, then TIMEOUT bit will always be 0 in Sn_IR.
  2. Sn_IMR controls which bits in Sn_IR will be changing;

Common interrupt control:

  1. SIR bits are OR of all status bits for respective socket; thus its value will depend on setting of Sn_IMR (which bits are effective and will be changing) and Sn_IR (which bits are being ORed);
  2. SIMR controls which socket flags will trigger hardware interrupts.

Thus to be able to poll bit in Sn_IR you still need its corresponding Sn_IMR bit to be set; if you do not want these bits to generate hardware interrupt - you must set socket corresponding SIMR bit to 0.

I hope it is clearer now (for you and also for me). I also hope that I am correct :slight_smile:

Well, this is what I did; and as far as I can see, close to your explanation:
I am using the wiznet Library. I just renamed socket to wiz_socket as this may collide with Win32 implementation.
with the StartTime and EndTime I can measure a possible timeout.
Sn_IR always reads 0x00.
(code is running on WIn7. and 9HCS12X.)

	wiz_NetInfo	NetInfo = {
	{0x00,0x00,0xFE,0x77,0x72,0xD8},		//uint8_t mac[6];  ///< Source Mac Address
	{192,168,0,7},		//   uint8_t ip[4];   ///< Source IP Address
	{255,255,255,0},		//   uint8_t sn[4];   ///< Subnet Mask
	{192,168,0,1},		//   uint8_t gw[4];   ///< Gateway IP Address
	{192,168,0,1},		//   uint8_t dns[4];  ///< DNS server IP Address
	 1  	//dhcp_mode dhcp;  ///< 1 - Static, 2 - DHCP

uint8_t addr[4] = {

wizchip_setnetinfo( &NetInfo );
wiz_socket(0, Sn_MR_UDP, 10000, 0);

	setSn_IMR(0, 0xFF);
	printf("\nSn_IMR= %02X", getSn_IMR(0));		//reads : "1F"

	StartTime = GetTickCount();


	EndTime = GetTickCount();

	printf("\nSn_IR= %02X", getSn_IR(0));		//reads : "00"

	if ((EndTime-StartTime) > 1000) {
    	printf("\n\tERROR:  target does not respond", EndTime-StartTime);

Here’s what I found saying the following:

Success : The sent data size 
Fail :
SOCKERR_SOCKNUM - Invalid socket number 
SOCKERR_SOCKMODE - Invalid operation in the socket 
SOCKERR_SOCKSTATUS - Invalid socket status for socket operation 
SOCKERR_DATALEN - zero data length 
SOCKERR_IPINVALID - Wrong server IP address
SOCKERR_PORTZERO - Server port zero
SOCKERR_SOCKCLOSED - Socket unexpectedly closed 
SOCKERR_TIMEOUT - Timeout occurred 
SOCK_BUSY - Socket is busy.

As long as it may return error SOCKERR_TIMEOUT, I assume it checks for IR bits, and clears them, and that’s why you never see them set. I have no source for the sendto routine, check it yourself as you should have it.

You are absolutely right. the bit is read by the function sento. i can see the SOCKERR_TIMEOUT (-13) returned by the function. My fault.

you have been of great help, thanks a lot. I owe you something!

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.