Changing one port from TCP to UDP without resting the WIZNET

Dear WIZNET support,

We have problem with W3150A+:

  1.   Configured one port to be UDP, that send NTP request and receive it correct– working good.
  2.   After socket initialization to the same port configured to TCP as Server, the PC (client) communicate with this port, the PC read data from that port – working good. 
  3.   After socket initialization to the same port configured to UDP again, try sending NTP request, it is not sending good.

Before the 1st NTP request the WIZNET sent ARP, and received the HW address 3c:1e:04:08:12:09
The PC (TCP client) HW address was 00:23:ae:3b:58:c1.
Before the 2nd NTP request the WIZNET do not sent ARP, and the NTP sent to the HW address of the PC (00:23:ae:3b:58:c1), not 3c:1e:04:08:12:09.

The socket initialization changed to your recommendation :

uint8 socket(SOCKET s, uint8 protocol, uint16 port, uint8 flag)
    uint8 ret;
    uint8 mac[6]) = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
     if ((protocol == Sn_MR_TCP) || (protocol == Sn_MR_UDP) || (protocol == Sn_MR_IPRAW) || (protocol == Sn_MR_MACRAW) || (protocol == Sn_MR_PPPOE))
             while((IINCHIP_READ(Sn_TX_WR(s))) != ( IINCHIP_READ(Sn_TX_RD(s)))); // wait until Sn_TX_RD and Sn_TX_WR are same close(s);
             IINCHIP_WRITE(Sn_MR(s),protocol | flag);
             if (port != 0)
                      IINCHIP_WRITE(Sn_PORT0(s),(uint8)((port & 0xff00) >> 8));
                      IINCHIP_WRITE((Sn_PORT0(s) + 1),(uint8)(port & 0x00ff));
                    local_port++; // if don't set the source port, set local_port number.
                    IINCHIP_WRITE(Sn_PORT0(s),(uint8)((local_port & 0xff00) >> 8));
                    IINCHIP_WRITE((Sn_PORT0(s) + 1),(uint8)(local_port & 0x00ff));
           setSn_DHAR (s, mac); // Reset DHAR
           IINCHIP_WRITE(Sn_CR(s),Sn_CR_OPEN); // run sockinit Sn_CR
           /* +200804[woong]:wait to process the command... */
           while( IINCHIP_READ(Sn_CR(s)) );
             /* ------- */
            ret = 1;
             ret = 0;
       return ret;

Thanks in advance

Ronit, I assume you close the socket between reusing it? And then set socket’s option register to UDP, and open the socket?

I closed the socket, set it to UDP and open again.
Before the NTP request in UDP, the WIZNET did not send ARP.
There is any thing I can do to make the WIZNET to send ARP.
I tried to clear the Sn_DHAR, by writing to it 0xFF, but it did not force the WIZNET to send ARP.

I do not have a solution to this issue (probably you found it already?), let me suggest the following:

  • I assume you reset DIPR and DPORT before opening UDP second time to the proper NTP server and port values?
  • when you are about to open UDP second time, set DHAR to the NTP server 3c:1e:04:08:12:09, as you already know it. This may not be a solution, but workaround to the problem. Try setting it before you open socket, see if it works properly, or after you open socket, and see if it works properly (NTP packet goes to correct network node). I hope it will work in one of these tests;
  • not a good idea, but worth considering - perform soft reset of the chip, and reconfigure it from the scratch. Hopefully its internal ARP cache will got cleared.
1 Like