Posix Port UDP Send Problem


My setup consist of 1 windows pc and 1 ubuntu pc with connecting a switch. My code works on ubuntu pc and I want to receive and send UDP packets by using TCP 4.1.0 Posix port. I could send an udp packet from ubuntu to windows but I could not receive any packet from Windows ( I sent by using Hercules). How can I receive udp packet from Windows?


How do you know the packet is being sent from Ubuntu? Do you see it on Wireshark, or some other way?

Please show the code you are using to receive the packet on Windows. Did you base the code on an existing demo from the FreeRTOS distribution?

Yes I saw on Wireshark. I want to receive packet on posix port and I send on windows by using hercules.

I have created a socket;


timeout = portMAX_DELAY;

freertos_sockaddr addr;
addr.sin_family = FREERTOS_AF_INET;
addr.sin_addr = FreeRTOS_inet_addr(ip);
addr.sin_port = FreeRTOS_htons(port);


and I waited a packet with


Can you check if you can receive these packets using a native Linux sockets application?

Yes I can receive these packets native linux sockets.
I solved my problem. I set xDefaultPartUDPPacketHeader.ucBytes array’s first 6 bytes with my mac address in main function. What is the proper way of set mac address? I had used pxLinux_FillInterfaceDescriptor() and FreeRTOS_FillEndPoint() functions but without set xDefaultPartUDPPacketHeader.ucBytes values, mac address is not set .

Ideally FreeRTOS_FillEndPoint() should set the MAC address of the endpoint.
Did you use pass the same MAC address that you passed to FreeRTOS_FillEndPoint as teh frist 6 bytes of xDefaultPartUDPPacketHeader.ucBytes?

Yes, I used same MAC

const uint8_t MAC[] = {0x10,0x11,0x12,0x13,0x14,0x15};
const uint8_t ucMACAddr[6] = {MAC[0],MAC[1],MAC[2],MAC[3],MAC[4],MAC[5]};

FreeRTOS_FillEndPoint(, , , , , , ucMACAddr);

xDefaultPartUDPPacketHeader.ucBytes[0] = MAC[0];
xDefaultPartUDPPacketHeader.ucBytes[0] = MAC[1];
xDefaultPartUDPPacketHeader.ucBytes[0] = MAC[2];
xDefaultPartUDPPacketHeader.ucBytes[0] = MAC[3];
xDefaultPartUDPPacketHeader.ucBytes[0] = MAC[4];
xDefaultPartUDPPacketHeader.ucBytes[0] = MAC[5];

Can you put a breakpoint at this line and see why the MAC address is not getting copied?

I saw my MAC address in this line and it made memcpy but it did not receive any packet.
When I set ipconfigHAS_DEBUG_PRINTF = 1,

pcap filter to compile: broadcast or multicast or ether host 0:0:0:0:0:0

is printed in console. If I set xDefaultPartUDPPacketHeader.ucBytes manually,

pcap filter to compile: broadcast or multicast or ether host 10:11:12:13:14:15

is printed.

A MAC address beginning with 01 is not a valid unicast MAC address (cf
MAC address - Wikipedia , maybe your switch gets confused with it. Try 0 as the first octet.

I changed my MAC address with 00:11:22:33:44:55 and 11:11:22:33:44:55 but both of them are still not working without set xDefaultPartUDPPacketHeader.ucBytes manually.

Hm. From my understanding, UDP is a layer 4 protocol, so you would normally not have to mess with MAC addresses at all on this level. Is your FreeRTOS DUT a DHCP client, or does it obtain its IP address statically? Is ICMP working ok from-to it?

Also, where it this xDefaultPartUDPPacketHeader defined?

I used static IP. ICMP is not working.

I set this in my main function.

I see that this PR removed xDefaultPartUDPPacketHeader. Can you please try using the latest main?

1 Like

When the problem occurred, I had used latest release v4.1.0. Now, I have tried latest main and it worked without make any changing. Will you release new release that include these changes?

Yes, these changes will be included in the next release. You can continue using main till then.

1 Like

Okay, thank you for your helping @aggarg