# How to define the frame size in FreeRTOS+TCP?

**URL:** <https://forums.freertos.org/t/how-to-define-the-frame-size-in-freertos-tcp/7877>\
**Category:** Kernel\
**Created:** [May 24, 2019, 1:51pm UTC](https://forums.freertos.org/t/how-to-define-the-frame-size-in-freertos-tcp/7877 "2019-05-24T13:51:18Z")\
**Posts on this page:** 3\
**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:** [May 24, 2019, 1:51pm UTC](https://forums.freertos.org/t/how-to-define-the-frame-size-in-freertos-tcp/7877/1 "2019-05-24T13:51:18Z")

</div>

**[edeviser](https://sourceforge.net/u/edeviser/)** wrote on [Friday, May 24, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/60e9ef1774/#9d3e):

I am running FreeRTOS+TCP and I would like to decrease the MTU.

Inside the `stm32f4x7_eth_conf.h` i find this:

```auto
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */

```

`ETH_MAX_PACKET_SIZE` is defined in `stm32f4x7_eth.h` to 1536.

Further more in `FreeRTOSIPConfig.h` i found this:

```auto
#define ipconfigNETWORK_MTU 1500

```

What is the difference between `ETH_RX_BUF_SIZE` and `ipconfigNETWORK_MTU`?  
Where should I reduce the frame size?

---

<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:** [May 24, 2019, 3:16pm UTC](https://forums.freertos.org/t/how-to-define-the-frame-size-in-freertos-tcp/7877/2 "2019-05-24T15:16:54Z")

</div>

**[heinbali01](https://sourceforge.net/u/heinbali01/)** wrote on [Friday, May 24, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/60e9ef1774/#6ae8):

> I am running FreeRTOS+TCP and I would like to decrease the MTU.

When you are running low on RAM, it is indeed a good idea to decrease MTU.  
But please make sure that the peripheral knows that you can not handle packets longer than a certain MTU.

The MTU does not include the size of the Ethernet header, which is 14 bytes long.  
So an MTU 0f 1000 bytes will need 1000+14 = 1014 bytes. Sometimes the peripheral will also write a 4-byte Frame Check Sequence into the DMA buffer, so that would make it 1018 bytes.

[Here](https://en.wikipedia.org/wiki/Frame_check_sequence#/media/File:Ethernet_Frame.png) is a very clear picture of a complete Ethernet packet.

> ETH\_MAX\_PACKET\_SIZE is defined in stm32f4x7\_eth.h to 1536.

The size of ‘1536’ is favourite because it is super well aligned: it is divisible by 32. Which is important when the DMA buffers are cached. A cache line is often 32 bytes long.

> Further more in FreeRTOSIPConfig.h i found this:  
> `#define ipconfigNETWORK_MTU 1500`

Normally 1500 is the maximum MTU on a LAN. There is a possibility to send Jumbo packets, which may become much longer. Generally, on the Internet, the supported MTU is only 1400 bytes. FreeRTOS+TCP will decrease the MSS (Maximum Segment Size) when the peer is located on the Internet.

> What is the difference between ETH\_RX\_BUF\_SIZE and ipconfigNETWORK\_MTU?

That should be clear by now: MTU is the nett packet size, without the Ethernet header and FCS. `ETH_RX_BUF_SIZE` is used to define the size of the DMA buffers.

> Where should I reduce the frame size?

So in 3 places:

- Adapt `ipconfigNETWORK_MTU`
- Adapt `ETH_MAX_PACKET_SIZE`
- Inform the peripheral about the maximum Maximum transmission unit

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [May 27, 2019, 7:05am UTC](https://forums.freertos.org/t/how-to-define-the-frame-size-in-freertos-tcp/7877/3 "2019-05-27T07:05:06Z")

</div>

**[edeviser](https://sourceforge.net/u/edeviser/)** wrote on [Monday, May 27, 2019](https://sourceforge.net/p/freertos/discussion/382005/thread/60e9ef1774/#f61b):

Hello Hein!

Great to hear from you and thank you for your advices and explanations! I going to test this out, soon!
