Author Topic: Ethernet Buffer Size  (Read 9870 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Ethernet Buffer Size
« on: June 25, 2009, 10:12:09 AM »
Hi Mark,
  I have an application that uses TCP, and UDP communication. I receive 4 packets of data of size 305 bytes, right after each other, and can have this for TCP and UDP.

I have the following defines:
#define NUMBER_OF_TX_BUFFERS_IN_ETHERNET_DEVICE         2                // allocate 2 buffers for transmission
#define NUMBER_OF_RX_BUFFERS_IN_ETHERNET_DEVICE         6                // allocate 6 (full) buffers for reception

What size are these buffers?

Also, In my listner routine as follows:
int fnUDP(USOCKET SocketNr, unsigned char ucEvent, unsigned char *ucIP, unsigned short usPortNr, unsigned char *data, unsigned short usLength)

I parse the data of the packet received. Am I better copying the data straight away to another buffer before parsing? Before the listner routine is called, is the frame copied to a buffer and the pointer (*data in my case) pointing to the buffer?

Regards
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: Ethernet Buffer Size
« Reply #1 on: June 25, 2009, 11:56:41 AM »
Hi Neil

The size of each Ethernet frame buffer is defined by LAN_BUFFER_SIZE. It is set to 1536, whereby Freescale recommend 1518 or 1522 when VLAN is used. This means that it is a little larger than absolutely necessary (I don't know why it is 18 bytes longer than necessary but I expect that it can be slightly reduced without any negative effects - I expect that the Ethernet header and CRC was counted twice at some time...).

Your listener receive a pointer to the data in the input LAN buffer. This means that data has not been copied and also there should be no reason for you to copy data when parsing, except if you want to retain the data for more work outside of the listener call back routine.

Regards

Mark