UDP Receive

We are receiving data using the loopback_udp function shown in W5300_Drv_AVR_V1.2.2.
If the amount of data sent from the PC is about 500 bytes, it will be received without any problem. If it exceeds 1KB, it will not be received.
I do not go into the example source below if ((len = getSn_RX_RSR (s))> 0) conditional statement.
Whether to increase buffer size … However, loopback_tcps seems to be receiving no problem, and it does not seem to be that …
Please advise … T.T

void loopback_udp(SOCKET s, uint16 port, uint8* buf, uint16 mode)
{
uint32 len;
uint8 destip[4];
uint16 destport;

switch(getSn_SSR(s))
{
case SOCK_UDP:
if ((len=getSn_RX_RSR(s)) > 0)
{
len = recvfrom(s,buf,len,destip,&destport);
if (len !=sendto(s,buf,len,destip,destport))
{
--------------------
}
}
break;
case SOCK_CLOSED:
close(s);
socket(s,Sn_MR_UDP,port,mode);
break;
default:
break;
}
}

What is the RX buffer size for the socket you use? With TCP network devices can negotiate buffer size, with UDP if packet does not fit into the buffer, I am afraid it will be discarded. Thus might be that you set RX buffer size to 1 KB. Increase buffer size and see.

Hello,

The current buffer size is set to 8KB.

As a result of testing with the default source, we receive up to 1472 bytes.

W5300_Drv_AVR_V1.2.2 By default, it seems to be set to 8KB. Is there anything I’m misunderstanding?

I can not go to the next because of this part. Please give me some advice. T.T

In w5300.c, the sysinit function is using the built-in default source and is set to 8KB in main.c as above. Of course, MAX_SOCK_NUM is set to 8 in iinchip_conf.h.

uint8 rx_mem_conf[8] = {8,8,8,8,8,8,8,8}; // for setting RMSR regsiter

if(!sysinit(tx_mem_conf,rx_mem_conf))

{

  •    printf*("MEMORY CONFIG ERR.\r\n");
    
      while(1);
    

}

uint8 sysinit(uint8* tx_size, uint8* rx_size)

{

uint16 i;

uint16 ssum=0,rsum=0;

uint mem_cfg = 0;

for(i=0; i < MAX_SOCK_NUM; i++)

{

  if(tx_size[i] > 64)

  {

  #ifdef __DEF_IINCHIP_DBG__

     *printf*("Illegal Channel(%d) TX Memory Size.\r\n",i);

  #endif

     return 0;

  }

  if(rx_size[i] > 64)

  {

  #ifdef __DEF_IINCHIP_DBG__

     *printf*("Illegal Channel(%d) RX Memory Size.\r\n",i);

  #endif

     return 0;

  }

  ssum += (uint16)tx_size[i];

  rsum += (uint16)rx_size[i];

  TXMEM_SIZE[i] = ((uint32)tx_size[i]) << 10;

  RXMEM_SIZE[i] = ((uint32)rx_size[i]) << 10;

}

if( (ssum % 8) || ((ssum + rsum) != 128) )

{

#ifdef DEF_IINCHIP_DBG

  *printf*("Illegal Memory Allocation\r\n");

#endif

  return 0;

}

IINCHIP_WRITE(TMSR0,tx_size[0]);

IINCHIP_WRITE(TMSR1,tx_size[1]);

IINCHIP_WRITE(TMSR2,tx_size[2]);

IINCHIP_WRITE(TMSR3,tx_size[3]);

IINCHIP_WRITE(TMSR4,tx_size[4]);

IINCHIP_WRITE(TMSR5,tx_size[5]);

IINCHIP_WRITE(TMSR6,tx_size[6]);

IINCHIP_WRITE(TMSR7,tx_size[7]);

IINCHIP_WRITE(RMSR0,rx_size[0]);

IINCHIP_WRITE(RMSR1,rx_size[1]);

IINCHIP_WRITE(RMSR2,rx_size[2]);

IINCHIP_WRITE(RMSR3,rx_size[3]);

IINCHIP_WRITE(RMSR4,rx_size[4]);

IINCHIP_WRITE(RMSR5,rx_size[5]);

IINCHIP_WRITE(RMSR6,rx_size[6]);

IINCHIP_WRITE(RMSR7,rx_size[7]);

for(i=0; i <ssum/8 ; i++)

{

  mem_cfg <<= 1;

  mem_cfg |= 1;

}

IINCHIP_WRITE(MTYPER,(uint8)(mem_cfg >> 8));

IINCHIP_WRITE(MTYPER1,(uint8)(mem_cfg & 0xff));

#ifdef DEF_IINCHIP_DBG

  *printf*("Total TX Memory Size = %dKB\r\n",ssum);

  *printf*("Total RX Memory Size = %dKB\r\n",rsum);

  *printf*("Ch : TX SIZE : RECV SIZE\r\n");

  *printf*("%02d : %07dKB : %07dKB \r\n", 0, IINCHIP_READ(TMSR0),IINCHIP_READ(RMSR0));

  *printf*("%02d : %07dKB : %07dKB \r\n", 1, IINCHIP_READ(TMSR1),IINCHIP_READ(RMSR1));

  *printf*("%02d : %07dKB : %07dKB \r\n", 2, IINCHIP_READ(TMSR2),IINCHIP_READ(RMSR2));

  *printf*("%02d : %07dKB : %07dKB \r\n", 3, IINCHIP_READ(TMSR3),IINCHIP_READ(RMSR3));

  *printf*("%02d : %07dKB : %07dKB \r\n", 4, IINCHIP_READ(TMSR4),IINCHIP_READ(RMSR4));

  *printf*("%02d : %07dKB : %07dKB \r\n", 5, IINCHIP_READ(TMSR5),IINCHIP_READ(RMSR5));

  *printf*("%02d : %07dKB : %07dKB \r\n", 6, IINCHIP_READ(TMSR6),IINCHIP_READ(RMSR6));

  *printf*("%02d : %07dKB : %07dKB \r\n", 7, IINCHIP_READ(TMSR7),IINCHIP_READ(RMSR7));

  *printf*("\r\nMTYPER=%02x%02x\r\n",IINCHIP_READ(MTYPER0),IINCHIP_READ(MTYPER1));

#endif

return 1;

}