# FreeRTOS plus TCP DHCP problem

**URL:** <https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709>\
**Category:** Kernel\
**Created:** [March 6, 2019, 8:05pm UTC](https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709 "2019-03-06T20:05:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 6, 2019, 8:05pm UTC](https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709/1 "2019-03-06T20:05:49Z")

</div>

**[liammc](https://sourceforge.net/u/liammc/)** wrote on [Wednesday, March 06, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/54ab111544/#f7b3):

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 ipconfigPACKET\_FILLER\_SIZE to 0 in order to read the correct IP address.  
Other then that everything is from the example: FreeRTOS\_Plus\_TCP\_and\_FAT\_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

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 7, 2019, 6:13pm UTC](https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709/2 "2019-03-07T18:13:56Z")

</div>

**[alager12345](https://sourceforge.net/u/alager12345/)** wrote on [Thursday, March 07, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/54ab111544/#df57):

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.

```auto
/* The checksums will be checked and calculated by the STM32F4x ETH peripheral. */
#define ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM ( 0 )
#define ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM ( 0 )

```

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 8, 2019, 2:23pm UTC](https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709/3 "2019-03-08T14:23:36Z")

</div>

**[liammc](https://sourceforge.net/u/liammc/)** wrote on [Friday, March 08, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/54ab111544/#7501):

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?

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [March 9, 2019, 8:59am UTC](https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709/4 "2019-03-09T08:59:28Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Saturday, March 09, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/54ab111544/#16e9):

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.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 11, 2019, 7:00pm UTC](https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709/5 "2019-03-11T19:00:02Z")

</div>

**[liammc](https://sourceforge.net/u/liammc/)** wrote on [Monday, March 11, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/54ab111544/#248c):

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.

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [March 12, 2019, 8:50am UTC](https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709/6 "2019-03-12T08:50:33Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Tuesday, March 12, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/54ab111544/#4d23):

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` :

```auto
- if( FreeRTOS_sendto( xDHCPData.xDHCPSocket, pucUDPPayloadBuffer, ( sizeof( DHCPMessage_t ) + xOptionsLength ), FREERTOS_ZERO_COPY, &xAddress, sizeof( xAddress ) ) == 0 )
+ if( FreeRTOS_sendto( xDHCPData.xDHCPSocket, pucUDPPayloadBuffer, ( sizeof( DHCPMessage_t ) + xOptionsLength - 1 ), FREERTOS_ZERO_COPY, &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?

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [March 12, 2019, 2:19pm UTC](https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709/7 "2019-03-12T14:19:44Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Tuesday, March 12, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/54ab111544/#37f2):

I turned the above change into a [pull-request on github](https://github.com/aws/amazon-freertos/pull/379), 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.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 12, 2019, 2:49pm UTC](https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709/8 "2019-03-12T14:49:15Z")

</div>

**[liammc](https://sourceforge.net/u/liammc/)** wrote on [Tuesday, March 12, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/54ab111544/#5098):

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

---

<div class="post-metadata">

**Author:** ![htibosch](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/htibosch/32/62_2.png) [@htibosch](https://forums.freertos.org/u/htibosch)\
**Post date:** [March 12, 2019, 2:56pm UTC](https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709/9 "2019-03-12T14:56:53Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Tuesday, March 12, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/54ab111544/#7926):

> 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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [March 12, 2019, 3:00pm UTC](https://forums.freertos.org/t/freertos-plus-tcp-dhcp-problem/7709/10 "2019-03-12T15:00:28Z")

</div>

**[liammc](https://sourceforge.net/u/liammc/)** wrote on [Tuesday, March 12, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/54ab111544/#a88d):

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