FreeRTOS plus TCP DHCP problem

Hello, I’ve been adding FreeRTOS + TCP to my FreeRTOS project. I was able to get everything working in a test environment using a laptop as a DHCP server. I was able to run an FTP server and I tested a UDP connection. I am now trying to connect to a larger university network and I am not getting any reply when I send a DHCP discover message. I’m not sure what the difference could be, I cannot access any network traces as I don’t have access. Another note about my setup. When debugging initially, I found I needed to set ipconfigPACKETFILLERSIZE to 0 in order to read the correct IP address. Other then that everything is from the example: FreeRTOSPlusTCPandFAT_ATSAME4E More details: Using a SAME70 Xplained board Using FreeRTOS Kernel V10.0.0 Using FreeRTOS+TCP Labs Build 160919 I’m using a unique MAC address from an on board chip so I don’t think the MAC address is the problem. Any suggestions what I could do to get this running would be greatly appreciated. I’m happy to provide more detail if needed. Thanks, Liam

FreeRTOS plus TCP DHCP problem

Check your discover packet, is the UDP checksum present? I found that I had to set checksum options to 0 for my LPC17xx port. If there is no checksum, then some ( most? ) DHCP servers will ignore the packet.
~~~ /* The checksums will be checked and calculated by the STM32F4x ETH peripheral. */

define ipconfigDRIVERINCLUDEDTXIPCHECKSUM ( 0 )

define ipconfigDRIVERINCLUDEDRXIPCHECKSUM ( 0 )

~~~

FreeRTOS plus TCP DHCP problem

Thanks for the suggestion! I did initially have a problem with the checksum when testing with DHCP server running on a laptop, that has been fixed now tho. Still not getting any DHCP reply when connecting to the university network. Any other suggestions?

FreeRTOS plus TCP DHCP problem

Is everyone allowed to connect to that network and get a DHCP address? It would be interesting to see a DHCP conversation that is successful and compare it with the embedded request. On AWS/FreeRTOS Github, you’ll find an easy-to-use demo project under pc. If you are able to run that on the campus, you can see with WireShark the DHCP conversation.

FreeRTOS plus TCP DHCP problem

Yes everyone is allowed to connect to the network and get a DHCP address. I was able to run that demo project. There was still no response. I have attached two captures with the different requests. It looks like there are some different options.

FreeRTOS plus TCP DHCP problem

The only surprising thing that I see is the padding byte in the end, in FreeRTOS_xxx.pcapng It has a ( random ) value of 0x38, where I would expect 0x00. The driver sends one byte too many, please change the following line in FreeRTOS_dhcp.c : ~~~ – if( FreeRTOSsendto( xDHCPData.xDHCPSocket, pucUDPPayloadBuffer, ( sizeof( DHCPMessaget ) + xOptionsLength ), FREERTOSZEROCOPY, &xAddress, sizeof( xAddress ) ) == 0 ) + if( FreeRTOSsendto( xDHCPData.xDHCPSocket, pucUDPPayloadBuffer, ( sizeof( DHCPMessaget ) + xOptionsLength – 1 ), FREERTOSZEROCOPY, &xAddress, sizeof( xAddress ) ) == 0 ) ~~~ This line occurs two times, in prvSendDHCPRequest(), and in prvSendDHCPDiscover(). Please change them both. The driver sends 1 byte too many because the first option byte is counted twice: both in the struct DHCPMessage_t, as well as in the const arrays ( ucDHCPRequestOptions and ucDHCPDiscoverOptions ). Beside the above, when you use a fixed IP-address, can you communicate to other devices / laptops?

FreeRTOS plus TCP DHCP problem

I turned the above change into a pull-request on github, because I believe that the length of the packet is 1 byte too long. I am not sure if this solves you problem, I hope so.

FreeRTOS plus TCP DHCP problem

That did remove the last (random) byte, now there is no padding. I have since contacted the administrators for the network and it was rejecting the mac address. I have this figured out now and can get a DHCP IP address. Thanks for your help Hein, it’s much appreciated! -Liam

FreeRTOS plus TCP DHCP problem

I have since contacted the administrators for the network and it was rejecting the mac address
I am always curious to learn: what was the reason that a DHCP server would reject some MAC address?
Thanks for your help Hein, it’s much appreciated!
You’re welcome, that is what the forum is for 🙂

FreeRTOS plus TCP DHCP problem

They didn’t give me a reason the MAC address was being rejected. I’m not sure what was going on.