Forum Discussion
Altera_Forum
Honored Contributor
21 years agolwIP UDP thoughut w/o an RTOS
Wanted to receive 1500 byte payload from 100 MAC (on Cyclone II) device, and using lwIP UDP no RTOS is required.
Can the UDP RX receive 80 Mbit/s? Where the UDP TX is minimal for data flow control only. The lwIP UDP RX just stripes off the header, and pass the data directly to an DMA. Any advise?14 Replies
- Altera_Forum
Honored Contributor
HI provintan,
I don't what speed can u reach (I haven't test it exactly yet), but I could suggest you some modifications: - implementing rx procedure through interupt, instead with polling as is in the web server example. - put interupt vector table in a TCM, along with interupt stack and interupt function - i'm designing a custom peripheral for checksum calculation - stand alone LWIP is faster (or better RX and TX speed are more balanced) I don't if this could help u.... bye - Altera_Forum
Honored Contributor
Hello provintan,
Yes it is possible to receive UDP packets with over 80 MBit/s. It seems that I’m working on a similar application like you. I got about 82 MBit/s UDP Rx. My system consists of: 1. Cyclone EP1C12 @ 50 MHz CPU clock 2. 32 MB SDRAM 3. 4 MB Flash 4. Davicom DM9000 Ethernet MAC/PHY (using the 16 bit bus) 5. some others stuff … For the first experiments I was using “lwip” but unfortunately “lwip” is very slow in handling large udp packets because “lwip” is copying fragmented packets some times around. For getting this speed some changes were needed in my system: 1. Because “lwip” is not very fast, it is better to write your own little udp stack. In my system lwip resides belong a little udp stack. For this I’m filtering incoming udp packets directly in the MAC driver (DM9000) and store the payload in the SDRAM via DMA. “lwip” will handle ARPs and the other network data like TCP. 2. It is necessary to get the data out of the SRAM of the MAC as fast as possible. If you are too slow the SRAM will overflow! Keep attention on the timing of the Ethernet MAC when using DMA (you have to slow down the DMA with the timing settings for the MAC). 3. Unfortunately I hadn’t enough IOs (240 PQFP) so I had to connect the DM9000 via a 16 bit bus with the Cyclone. This results in a lower bandwidth. To compensate this behaviour an own bridge connects the outside tri-state bus (DM9000, Flash, CompactFlash) with the Avalon bus. The bridge controls the timing and is doing dynamic bus sizing (32 bit to 16 bit) for read and write cycles. So you see it is possible. I hope my explanation helps you to get the desired speed out of your system. Good luck, niosIIuser - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by niosiiuser@Jul 22 2005, 02:21 AM hello provintan,yes it is possible to receive udp packets with over 80 mbit/s. it seems that i’m working on a similar application like you. i got about 82 mbit/s udp rx.
my system consists of:
1. cyclone ep1c12 @ 50 mhz cpu clock
2. 32 mb sdram
3. 4 mb flash
4. davicom dm9000 ethernet mac/phy (using the 16 bit bus)
5. some others stuff …
for the first experiments i was using “lwip” but unfortunately “lwip” is very slow in handling large udp packets because “lwip” is copying fragmented packets some times around. for getting this speed some changes were needed in my system:
1. because “lwip” is not very fast, it is better to write your own little udp stack. in my system lwip resides belong a little udp stack. for this i’m filtering incoming udp packets directly in the mac driver (dm9000) and store the payload in the sdram via dma. “lwip” will handle arps and the other network data like tcp.
2. it is necessary to get the data out of the sram of the mac as fast as possible. if you are too slow the sram will overflow! keep attention on the timing of the ethernet mac when using dma (you have to slow down the dma with the timing settings for the mac).
3. unfortunately i hadn’t enough ios (240 pqfp) so i had to connect the dm9000 via a 16 bit bus with the cyclone. this results in a lower bandwidth. to compensate this behaviour an own bridge connects the outside tri-state bus (dm9000, flash, compactflash) with the avalon bus. the bridge controls the timing and is doing dynamic bus sizing (32 bit to 16 bit) for read and write cycles.
so you see it is possible. i hope my explanation helps you to get the desired speed out of your system.
good luck,
niosiiuser
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=8541)
--- quote end ---
--- Quote End --- Sounds very good 80 MBit... could you show me how you receive those packets NIOSIIUSER?! I am trying to send packets from another application, but ethereal says it couldn't open destination port Cheers, Danny
- Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by dannyjacobs@Nov 7 2005, 03:48 PM sounds very good 80 mbit... could you show me how you receive those packets niosiiuser?! i am trying to send packets from another application, but ethereal says it couldn't open destination portcheers,
danny --- Quote End --- Hello Danny, What do you mean by „could you show me how you receive those packets“? Do you mean how I measured the speed? Regards, niosIIuser
- Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by niosiiuser+nov 7 2005, 11:21 am--><div class='quotetop'>quote (niosiiuser @ nov 7 2005, 11:21 am)</div>--- quote start ---
<!--quotebegin-dannyjacobs@Nov 7 2005, 03:48 PM sounds very good 80 mbit... could you show me how you receive those packets niosiiuser?! i am trying to send packets from another application, but ethereal says it couldn't open destination port
cheers,
danny --- Quote End --- Hello Danny, What do you mean by „could you show me how you receive those packets“? Do you mean how I measured the speed? Regards, niosIIuser <div align='right'><{post_snapback}> (index.php?act=findpost&pid=10825)</div> [/b] --- Quote End --- Hi niosIIuser, well I wrote a simple program to send UDP messages... That seems to work, but when I try to receive those messages it doesn't work. I tried to capture with etherreal what was going on, but for some reason the destination port is unreachable of my NIOS II dev kit. So I thought perhaps you could show me how you can receive UDP messages. I'm a newbie with NIOS II and as an interm they want me to capture data at high speed. So 80 Mbit/s is a very nice speed. That's the speed they want here. But still don't know how to receive any incoming messages. Cheers, Danny
- Altera_Forum
Honored Contributor
Hello Danny,
As I wrote above I don’t use lwip for receiving UDP packets in my application. If you start with Nios etc. you should use lwip first, because it’s a working system. When you have built a stable system you can add some hardware accelerations to achieve higher bandwidth. The following code shows a very small UDP receive routine. I used this one for testing purposes only. After you have sent 1024 packets to port 1409 there will be a message.
Regards, niosIIuser#include "lwip/debug.h"# include "lwip/stats.h"# include "lwip/udp.h" u32_t udp_packets; static void udp_test_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port) { /* printf("\nUDP packet received from: %d.%d.%d.%d : %d", (addr->addr)&0xFF, ((addr->addr)>>8)&0xFF, ((addr->addr)>>16)&0xFF, (addr->addr)>>24, port); */ udp_packets++; //printf("\nlen: %d, tot_len: %d", p->len, p->tot_len); if (udp_packets % 1024 == 0) printf("\n%d udp_packets received", udp_packets); pbuf_free(p); } /*-----------------------------------------------------------------------------------*/ void udp_test_init(void) { struct udp_pcb *pcb; printf("udp_init\n"); udp_packets = 0; pcb = udp_new(); udp_bind(pcb, IP_ADDR_ANY, 1409); udp_recv(pcb, udp_test_recv, NULL); } /*-----------------------------------------------------------------------------------*/ - Altera_Forum
Honored Contributor
Hi niosIIuser,
receiving wasn't a problem. The problem is to send something out. It doesn't seem to be working. Destination and port seem to be '0' according to etherreal. Cheers, Danny - Altera_Forum
Honored Contributor
Hell Danny,
take a look at the following code. After executing "udp_test_init" it should be possible to send UDP packets.
Regards, niosIIuserIP4_ADDR(&udpDestIpAddr, 192, 168, 2, 150); pbuflfsr = pbuf_alloc(PBUF_TRANSPORT,LFSR_LENGTH,PBUF_RAM); //Get a pbuf struct. ((u8_t *)(pbuflfsr->payload)) = LFSR_TOS; ((u8_t *)(pbuflfsr->payload)) = LFSR_VS; ((u8_t *)(pbuflfsr->payload)) = 0x00; ((u8_t *)(pbuflfsr->payload)) = 0x00; udp_sendto(pcb, pbuflfsr, &udpDestIpAddr, 1510); - Altera_Forum
Honored Contributor
Hi all,
what would be the maximum speed to send UDP packets? Right now I've reached 18 Mbit/s, but for some reason when I try to send a string all I receive on the PC's side is some ascii... I think sending data over 80Mbit/s should be possible or am I wrong?! I'm trying to send this: ****************************************************************** /* * * This file is for testing stand-alone (NO_SYS) LWIP * using a RAM-based simple file system * */ # include "system.h" # include "arch/init.h"# include "lwip/ip_addr.h"# include "lwip/tcpip.h"# include "lwip/netif.h"# include "netif/lan91c111if.h" # include "sys/alt_alarm.h"# define get_milliseconds() alt_nticks() /* ---------- IP oriented addresses for ethernet adapter ---------- */# define IPADDR0 169# define IPADDR1 254# define IPADDR2 0# define IPADDR3 2 # define NETMASK0 255# define NETMASK1 255# define NETMASK2 0# define NETMASK3 0 # define GWADDR0 169# define GWADDR1 254# define GWADDR2 0# define GWADDR3 3 int main(void) { //0.6.4 struct netif *netif; struct netif netif; struct ip_addr ipaddr, netmask, gw; struct ip_addr destIpAddr; struct udp_pcb* pcb; struct pbuf* p; unsigned char buffer[100] = "beetje flauw\n"; unsigned char *buffPtr; alt_avalon_lan91c111_if* dev_list_ptr = (alt_avalon_lan91c111_if*)alt_ethernet_device_list.next; buffPtr = mem_malloc(sizeof(buffer)); memcpy(buffPtr, buffer, sizeof(buffer)); //copy's from buffer to buffer /* * Initialize lwip */ lwip_init(); printf ("Setting IP address to: %d.%d.%d.%d\n", IPADDR0, IPADDR1, IPADDR2, IPADDR3); printf ("Setting netmask to: %d.%d.%d.%d\n", NETMASK0, NETMASK1, NETMASK2, NETMASK3); printf ("Setting gateway address to: %d.%d.%d.%d\n", GWADDR0, GWADDR1, GWADDR2, GWADDR3); IP4_ADDR(&ipaddr, IPADDR0, IPADDR1, IPADDR2, IPADDR3); IP4_ADDR(&netmask, NETMASK0, NETMASK1, NETMASK2, NETMASK3); IP4_ADDR(&gw, GWADDR0, GWADDR1, GWADDR2, GWADDR3); //0.6.4 netif = netif_add(&ipaddr, &netmask, &gw, netif_add(&netif, &ipaddr, &netmask, &gw, (void*)dev_list_ptr, lan91c111if_init, ip_input); //0.6.4 netif_set_default(&netif); netif_set_default(&netif); p = pbuf_alloc(PBUF_TRANSPORT,4096,PBUF_RAM); p->payload = (void*)buffPtr; IP4_ADDR(&destIpAddr, 169, 254, 0, 1); pcb = udp_new(); udp_connect(pcb, &destIpAddr, 666); //mem_free(buffPtr); udp_remove(pcb); while(1) { //0.6.4 lan91c111if_service(netif); lan91c111if_service(&netif); udp_send(pcb, p); // printf(buffer); } } ****************************************************************** this is the way I am trying to send it... but it doesn't reach the pc in the right way. I even wonder if am sending this string. Suggestions anyone? Thanx, Danny - Altera_Forum
Honored Contributor
Ok it worked http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/biggrin.gif
80 MBit/s is possible http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif my coach was very pleased!!! Thanx for all your help http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif Cheers, Danny