Sorry, you need to enable JavaScript to visit this website.

zedboard ethernet udp communication

Solved
6 posts / 0 new
Longin's picture
Longin
Junior(1)
zedboard ethernet udp communication

Hello
I´m just playing with ethernet with zedboard. I made simple design with only PS part of Zynq and reworked SDK lwip raw tcp echo example to udp. Everything works fine but I would like to ask some questions.
Performance:
I have measured transmit output with Jperf (GUI version of iperf utility). UDP payload size was 500B with achieved circa 400Mbit/s and for 1000B payload I got around 700Mbit/s bandwidth performance. Bigger payload per datagram is irrelevant for me because of app layer protocol what I'm gonna use.
In XAPP1026 document there is the chapter about measured performance (page 23 - lwip performance). As you can see...about 900Mbit/s can be achieved with raw TCP (!!!) on the board ZC702.
Did I overlook something? ZC702 have same cpu (666MHz) like zedboard and similar PHY ethernet chip (marvell).
Here is sample of my code:
void myudp_client_init(void)
{
    ip_addr_t DestIPaddr;
    err_t err;
    upcb = udp_new();
    if (upcb!=NULL)
    {
        IP4_ADDR( &DestIPaddr, DEST_IP_ADDR0, DEST_IP_ADDR1, DEST_IP_ADDR2, DEST_IP_ADDR3 );
        err= udp_connect(upcb, &DestIPaddr, UDP_SERVER_PORT);
        if (err == ERR_OK)
        {
            /* Set a receive callback */
            udp_recv(upcb, udp_receive_callback, NULL);
        }
    }
}

static void myudp_client_send(void)
{
    struct pbuf *p;
    static int counter = 0;
    sprintf((char*)data, "counter>%d", counter++);   //for evaluation of received datagrams
     p = pbuf_alloc(PBUF_TRANSPORT,PAYLOAD_SIZE, PBUF_POOL);
    if (p != NULL)
    {
        pbuf_take(p, (char*)data, PAYLOAD_SIZE);  //PAYLOAD_SIZE tried from 200B to 1000B
        udp_send(upcb, p);
        pbuf_free(p);
    }
}
I just call myudp_client_send() while button is pushed. Received datagrams are checked in Wireshark.
 
General question about lwip raw mode:
While I was reading various documentation and example codes of RAW mode for different platforms (Atmel, NXP, STM32...) I always find necessity of calling sys_check_timeouts function in while(1) next to variation of function ethernetif_input (it's called xemacif_input in Xilinx lwip port ). Why is it not in xilinx LWIP examples? Are timers timeouts handled implicitly?

narrucmot's picture
narrucmot
Moderator(1)
Hello,

Hello,

My experience with LwIP tells me that the BSP settings in the Xilinx SDK for the LwIP library have a significant influence on the bandwidth that can be achieved, especially the tcp_options -> tcp_mss setting.  The larger this number can be the greater the throughput that will be achieved, but I have found that the default (1460 bytes) is too big and thus has a big negative effect on throughput.  Below is some information and description on these BSP settings and the effect they have on throughput.  The design described is a MicroBlaze and EthernetLITE  design on the Avnet 7A50T Artix-7 board, but that is OK.  The BSP settings still apply to LwIP and GbE on Zynq.

Examine the Board Support Package Settings

Any software application built in the SDK requires a Support Package (BSP) on which individual projects can be built.   Multiple BSPs and multiple application projects can be held in a single SDK workspace.  The BSP required to run the lwIP applications was built when we created the software application, and it includes many settings that significantly impact Ethernet performance.  We will examine those settings in the steps below.

  1. Right click on the lwip_raw_apps_bsp in the Project Explorer pane and select Board Support Package Settings
  1. Notice that the lwip141 and xilmfs libraries are already selected in the BSP.  These were selected automatically when we create the lwip applications software project from the repository we added earlier.  Do not click OK yet.
  1. In the left panel, select lwip141 for the standalone OS to see the detailed parameters available for the lwIP library and click to expand the tree for the temac_adapter_options settings.
  1. To maximize Ethernet throughput it is necessary to increase the number of Tx and Rx descriptors to be used.  The optimal value for the number of n_tx_descriptors and n_rx_descriptors for this example design is 256.  We also need to set the phy_link_speed to CONFIG_LINKSPEED100.  Normally it would be desirable to leave this set for auto-negotiation, but this setting is PHY dependent and has only been tested with Marvell PHYs used on Xilinx development boards.  The maximum throughput of the axi_ethernetlite peripheral is 100Mbps, so we set the link speed to 100Mbps here.  This setting must be correct and must match the capabilities of the Ethernet MAC and PHY in order to transmit and receive packets.  Do not click OK yet.
  1. Click to expand the tree for the lwip_memory_options:
  1. Our webserver file system is essentially a RAMdisk because it resides in system DDR3 memory and serves a few files while also allowing us to monitor the status of board GPIO.  To maximize this file serving performance we need to set the number of memp_n_pbuf and memp_n_tcp_seg to 1024.  Notice the value of mem_size.  This is equivalent to the amount of heap space that we specified in the linker script.  Do not click OK yet.
  1. Click to expand the tree for the pbuf_options:
  1. Packet buffers (Pbufs) carry packets across various layers of the TCP/IP stack. To increase our Ethernet performance we need to increase the pbuf_pool_size to 1024Do not click OK yet.
  1. Click to expand the tree for the tcp_options settings:
  1. To maximize the use of the hardware Rx ping-pong buffers it is necessary to increase the size of the TCP window.  A standard Ethernet frame is 1518 bytes long, so each buffer can hold a single frame.  By default, the receive window is set at 2048 bytes, meaning only one frame can be in transit before an acknowledgement is sent to the host.  We can double the size of tcp_wnd to 4096 bytes to allow a second frame in transit, which will better utilize the available bandwidth.  Experiment with this parameter to see how higher and lower values affect the throughput on your system.  Do not click OK yet.
  1. To maximize the Tx throughput it is necessary to make the maximum segment size slightly smaller than the default.  The maximum segment size controls the amount of payload bytes per IP packet.  Ideally this value is as large as possible to maximize the transmit efficiency.  For this MicroBlaze system connected over Ethernet to a Windows host computer, the best transmit throughput was achieved with a tcp_mss value of 1458 bytes.  Experiment with this parameter to see how higher and lower values affect the throughput on your system.  Do not click OK yet.   
  1. Click to expand the tree for the dhcp_options settings:
  1. Even though this example design prescribes connecting the evaluation board directly to the host PC with a static IP address, the lwIP stack is capable of fetching its IP address from a DHCP server (probably an Ethernet router) on the network.  To enable this capability set lwip_dhcp to true.  If a DHCP server is not found when the lwIP stack initializes at power on, it will default to an IP address of 192.168.1.10.  This is the behavior seen in the demos described earlier in this tutorial.  Do not click OK yet.

Hopefully this is helpful for you.

--Tom

 

Hi, I could make my own code

Hi, I could make my own code of udp communication over zedboard, but there is problem with the receiving of user datagram... and i have took a buffer to copy the received payload into it and tried to print it over the console of sdk.But i could not print anything over the console.. and the problem is with the receiving of the data ...

JFoster's picture
JFoster
Moderator(55)
Hi,

Hi,

Have you tried the lwIP Demo Application template in SDK? Compare it to what you currently have.

--Josh

http://microzed.org/content/udp-frames-zedboard

Ya, I have already tried...

Ya, I have already tried... and when I construct my udp echo program in the same way.. iam not receiving any data.. because i copied the payload into a buffer and trying to print it over the console and couldnot find anything inside the buffer.
 

What changes has to be done to do udp !

Hi,
What is the main difference of using udp  and tcp  , in example templates of sdk , I could find only with tcp ip but not with udp . If you are using lwip with udp what kind of modifications are required in main.c and echo.c . It would be nice if you share the code here for understanding. I had already done an application using tcp available over there. Now when i select lwip echo server while creating a new application project and when i tick the udp as true in board support package for the corresponding application project, the lwip echo server project is opening only with tcp example and not with udp example. Before I start to build my own udp , would like to know what changes are to be done and what is the main difference between the both?