AnsweredAssumed Answered

LwIP example sending UDP packets 50 bytes larger than expected

Question asked by zbrozek.sasha.001 on Apr 17, 2013
Latest reply on May 21, 2014 by gabrielli.christian
I'm using the STM32F4x7 + LwIP example code, modified to work with RMII and a LAN8720 PHY. I can send and receive Ethernet data - great!

Unfortunately whenever I send a UDP packet, it has 50 bytes more payload than I expect. My anticipated payload is there, unmolested, but the additional data is undesired.

01.struct udp_pcb* upcb = udp_new();
02.struct pbuf* p = pbuf_alloc(PBUF_TRANSPORT, sizeof(DataFrame), PBUF_RAM);
03.struct ip_addr destAddr;
04.DataFrame data;
06.IP4_ADDR(&destAddr, 192, 168, 1, 55);
07.printf("p->len: %u\r\n", p->len);
08.printf("p->tot_len: %u\r\n", p->tot_len);
09.printf("sizeof(DataFrame): %u\r\n", sizeof(DataFrame));
11.char* ptr = (char*)(&data);
12.for(int a = 0; a < sizeof(DataFrame); a++)
13.    ptr[a] = a;
15.memcpy(p->payload, &data, sizeof(DataFrame));
16.udp_sendto(upcb, p, &destAddr, 4444);

The result from printf is 460, 460, and 460. In Wireshark I see that my data is 510 bytes. I can increase or decrease the size of my DataFrame struct, but the payload is always exactly fifty bytes more.