Forum Discussion
DE2_UDP example for download here free (feedbacks are wellcomed)
Hi all.
My goal is to get about 3Mbytes/sec data transfer rate from my DE2 board to PC. Here in this example I get about 1.2 Mbytes/sec. I'll accept comments about, how to speed up this, as well as suggests to improve the code, and some feedback from people that have interest in this theme. Could be in this thread or private. You can download the full project from: http://www.btxsistemas.com.ar/net2.zip I've used Quartus II 7.2 full suite. And the Wireshark software (http://www.wireshark.org/) like a net sniffer, but also, I've included in the main project folder, a UDP reciever to test the comunication between the DE2 board and the PC, if you wont to download the wireshark. Don't forget to specify your IP address and your MAC address in the NIOS hello_word "C" code to get it work properly. The main project is a modification of the DE2_NET demostration code that comes with the DE2 board. Have fun, and I'll be waiting for some comments.94 Replies
- Altera_Forum
Honored Contributor
I've never tried it connected to the network, only directly to a PC so I'm not sure. Not sure what you mean by getting it onto the PC after pinging it... Do you mean like recording the data coming from the DE2?
- Altera_Forum
Honored Contributor
hello sir,
i meant, that i will connect DE2 to the network and when i ping it from a PC connected to the same network and i have to get the packets.. its like i want to send a request to the DE2 to send the packets.. - Altera_Forum
Honored Contributor
Ah, I see. Yeah I don't know how you would go about fixing that. It sounds like it's probably a network issue. I'm sorry but that kind of work is beyond the scope of what I did and I did my work... almost two years ago now.
- Altera_Forum
Honored Contributor
--- Quote Start --- Hi, I was success to make it transfer a character from DE2 board to PC, and I got correct a character on PC side. But when I transferred the character back from PC to DE2 board, I could not make it correctly. I always got the same data for different character data. Could anyone please help me with my code Here is my files/* * network.h * */ # ifndef NETWORK_H_# define NETWORK_H_ /* Assign IP: 192.168.1.44 IP Address for the DE2 */# define Src_IP1 0xC0# define Src_IP2 0xA8# define Src_IP3 0x01# define Src_IP4 0x2C /* Assign IP: 192.168.1.30 IP Address for the PC */# define Dest_IP1 0xC0# define Dest_IP2 0xA8# define Dest_IP3 0x01# define Dest_IP4 0x1E /* DE2 MAC Address */# define Src_MAC1 0x01# define Src_MAC2 0x60# define Src_MAC3 0x6E# define Src_MAC4 0x11# define Src_MAC5 0x02# define Src_MAC6 0x0F /* PC MAC Address */# define Dest_MAC1 0x00# define Dest_MAC2 0x16# define Dest_MAC3 0xD4# define Dest_MAC4 0xBB# define Dest_MAC5 0xCA# define Dest_MAC6 0x91 # define payload 1 /* Send and receive one character */ /* Total Packet Length * Frame Header, IP Header, UDP Header, Payload * */# define Packet_Len (payload + 0x2B) # define UDP_Len (payload + 8)# define UDP_Len_H ((UDP_Len & 0xFF00)>>8)# define UDP_Len_L (UDP_Len & 0x00FF) # define IP_Len (payload + 8 + 20)# define IP_Len_H ((IP_Len & 0xFF00)>>8)# define IP_Len_L (IP_Len & 0x00FF) # define IP_Csum1 (0x0000C511 + (Src_IP1<<8)+Src_IP2+(Src_IP3<<8)+Src_IP4+(Dest_IP1<<8)+Dest_IP2+(Dest_IP3<<8)+(Dest_IP4)+(IP_Len_H<<8) + IP_Len_L)# define IP_Csum2 ((IP_Csum1&0x0000FFFF)+(IP_Csum1>>16))# define IP_Csum3 (0x0000FFFF - IP_Csum2)# define IP_Csum4 ((IP_Csum3 & 0xFF00)>>8)# define IP_Csum5 ((IP_Csum3 & 0x00FF)) # endif /* NETWORK_H_ */
Here is my receiving data (always the same for different character data) Receive Packet Length = 64 0x01,0x60,0x6E,0x11,0x02,0x0F,0x00,0x16, 0xD4,0xBB,0xCA,0x91,0x08,0x00,0x45,0x00, 0x00,0x2D,0x10,0xC7,0x00,0x00,0x80,0x11, 0xA6,0x5E,0xC0,0xA8,0x01,0x1E,0xC0,0xA8, 0x01,0x2C,0x04,0x00,0x04,0x00,0x00,0x19, 0x88,0xAE,0x2F,0x31,0x39,0x32,0x2E,0x31, 0x36,0x38,0x2E,0x31,0x2E,0x34,0x34,0x20, 0x3A,0x20,0x54,0x00,0x2A,0x58,0x79,0x24, Receive message: / --- Quote End --- I have compiled above code and check with de2 board char A is transmitting to PC but there is a error massege display "Error receiving packet" i have tried lot of ways but couldnt find any way to get receiving data from PC. Can anyone help me to receive UDP data from PC thankyou./* * main.c * */# include "basic_io.h"# include "network.h"# include "LCD.h"# include "DM9000A.C"# include "DM9000A.H"# include <string.h># include <ctype.h> unsigned char PC_MAC_ADDR = { 0x00, 0x16, 0xD4, 0xBB, 0xCA, 0x91 }; unsigned char DE2_MAC_ADDR = { 0x01, 0x60, 0x6E, 0x11, 0x02, 0x0F }; unsigned int receive_status, receive_len, i, packet_num; unsigned char receive_buffer; # define UDP_PACKET_PAYLOAD_OFFSET 42 unsigned char ARP_Packet = { /* Ethernet MAC header 14 bytes, * first 6 bytes for Destination MAC address * second 6 bytes for SOURCE MAC address * last 2 bytes for Ethernet types (ARP = 0806) */ Dest_MAC1, Dest_MAC2, Dest_MAC3, Dest_MAC4, Dest_MAC5, Dest_MAC6, Src_MAC1, Src_MAC2, Src_MAC3, Src_MAC4, Src_MAC5, Src_MAC6, 0x08, 0x06, /* ARP Header, * */ 0x00, 0x01, // Hardware Ethernet 0x0001 0x08, 0x00, // Protocol IP 0x0800 0x06, // Hardware size 6 0x04, // Protocol size 4 0x00, 0x02, // Reply Src_MAC1, Src_MAC2, Src_MAC3, Src_MAC4, Src_MAC5, Src_MAC6, Src_IP1, Src_IP2, Src_IP3, Src_IP4, Dest_MAC1, Dest_MAC2, Dest_MAC3, Dest_MAC4, Dest_MAC5, Dest_MAC6, Dest_IP1, Dest_IP2, Dest_IP3, Dest_IP4 }; unsigned char UDP_Packet = { /* Ethernet MAC header 14 bytes, * first 6 bytes for Destination MAC address * second 6 bytes for SOURCE MAC address * last 2 bytes for Ethernet types (IP = 0800) */ Dest_MAC1, Dest_MAC2, Dest_MAC3, Dest_MAC4, Dest_MAC5, Dest_MAC6, Src_MAC1, Src_MAC2, Src_MAC3, Src_MAC4, Src_MAC5, Src_MAC6, 0x08, 0x00, /* IP Header, 20 bytes * 4 bits for version * 4 bits for header length * 8 bits for type of service * 16 bits for total length of packet * 16 bits for identification * 3 bits for flag, 13 bits for fragment offset * 8 bits for time to live * 8 bit for protocol * 16 bit for header checksum * 32 bits for source IP * 32 bits for destination IP */ 0x45, 0x00, IP_Len_H, IP_Len_L, 0x00, 0x00, 0x00, 0x00, 0x80, 0x11, // UDP Type IP_Csum4, IP_Csum5, Src_IP1, Src_IP2, Src_IP3, Src_IP4, Dest_IP1, Dest_IP2, Dest_IP3, Dest_IP4, 0x04, 0x00, 0x04, 0x00, // Port 1024 UDP_Len_H, UDP_Len_L, 0x00, 0x00, /* UDP data, * Data take one byte. */ 0x41 // Character A }; void ethernet_interrupt_handler() { int i = 0; unsigned char mac_addr; receive_status = ReceivePacket(receive_buffer, &receive_len); if (receive_status == DMFE_SUCCESS) { /* Display the whole packet receive */ printf("\n\nReceive Packet Length = %d", receive_len); for(i = 0; i < receive_len;i++) { if (i%8==0) printf("\n"); printf("0x%.2X,", receive_buffer); } printf("\n"); /* Get the source address from the packet */ for(i = 6 ; i < 12; i++) { mac_addr = receive_buffer; } /* Compare the mac address to the PC MAC address */ if (memcmp(mac_addr, PC_MAC_ADDR, 6) == 0) { if (receive_len >= 14) { // A real Ethernet packet if (receive_buffer == 8 && receive_buffer == 6){ // An ARP Packet TransmitPacket(ARP_Packet, sizeof(ARP_Packet)); /* Clear the DM9000A ISR: PRS, PTS, ROS, ROOS 4 bits, by RW/C1 */ iow(ISR, 0x3F); /* Re-enable DM9000A interrupts */ iow(IMR, INTR_set); //DM9000_init(SRC_MAC_ADDR); } else { if (receive_buffer == 8 && receive_buffer == 0 && receive_len >= 34) { // An IP packet if (receive_buffer == 0x11) { // A UDP packet if (receive_len >= UDP_PACKET_PAYLOAD_OFFSET) { char request = (receive_buffer + UDP_PACKET_PAYLOAD_OFFSET); printf("Receive message: %c\n",request); } } else { printf("Received non-UDP packet\n"); } } else { printf("Received non-IP packet\n"); } } } else { printf("Malformed Ethernet packet\n"); } } } else { printf("Error receiving packet\n"); } /* Clear the DM9000A ISR: PRS, PTS, ROS, ROOS 4 bits, by RW/C1 */ iow(ISR, 0x3F); /* Re-enable DM9000A interrupts */ iow(IMR, INTR_set); //DM9000_init(SRC_MAC_ADDR); } int main() { LCD_Init(); LCD_Show_Text("TEAM-SYNTHESIS"); LCD_Line2(); LCD_Show_Text("Ethernet Testing"); printf("Network Transfer: Team-Synthesis (c) 2011.\n"); DM9000_init(); // Initialize the DM9000A. alt_irq_register( DM9000A_IRQ, NULL, (void*)ethernet_interrupt_handler ); while (1) { TransmitPacket(UDP_Packet,sizeof(UDP_Packet)); usleep(500000); } return 0; } - Altera_Forum
Honored Contributor
--- Quote Start --- I have compiled above code and check with de2 board char A is transmitting to PC but there is a error massege display "Error receiving packet" i have tried lot of ways but couldnt find any way to get receiving data from PC. Can anyone help me to receive UDP data from PC thankyou. --- Quote End --- Okay, I don't have a DE2 anymore but the first thing you're probably going to want to do is figure out what exactly that response you're getting is. I can tell you this much so far: 0x01,0x60,0x6e,0x11,0x02,0x0fde2 mac address 0x00,0x16,0xd4,0xbb,0xca,0x91
pc mac address 0x08,0x00
protocol ip 0x0800 0x45,0x00 ??? 0x00,0x2d
ip_len_h? 0x10,0xc7 ip_len_l? 0x00,0x00 ??? 0x80, 0x11 udp type 0xa6,0x5e ??? 0xc0,0xa8,0x01,0x1e pc ip 0xc0,0xa8,0x01,0x2c, de2 ip 0x04,0x00,0x04,0x00, port 1024 0x00,0x19, udp_len_h? 0x88,0xae, udp_len_l? 0x2f, ??? 0x31,0x39,0x32,0x2e,0x31,0x36,0x38,0x2e 0x31,0x2e,0x34,0x34 de2 ip in ascii 0x20,0x3a,0x20,0x54,0x00,0x2a,0x58,0x79,0x24 ???
does this make sense? should any of these be changed or would you know what some of those question marks should be?
- Altera_Forum
Honored Contributor
- Altera_Forum
Honored Contributor
TO_BE_DONE
- Altera_Forum
Honored Contributor
I compiled this code to DE2 its successfully sends data DE2 to PC but when we send data PC to Board it didn't receive data it receives one or two packets and then stops need a big help its urgently thankyou
- Altera_Forum
Honored Contributor
I also have this problem i need to big help if any one have UDP Receiving code mail me thankyou [email protected]
- Altera_Forum
Honored Contributor
--- Quote Start --- Hi all. My goal is to get about 3Mbytes/sec data transfer rate from my DE2 board to PC. Here in this example I get about 1.2 Mbytes/sec. I'll accept comments about, how to speed up this, as well as suggests to improve the code, and some feedback from people that have interest in this theme. Could be in this thread or private. You can download the full project from: http://www.btxsistemas.com.ar/net2.zip I've used Quartus II 7.2 full suite. And the Wireshark software (http://www.wireshark.org/) like a net sniffer, but also, I've included in the main project folder, a UDP reciever to test the comunication between the DE2 board and the PC, if you wont to download the wireshark. Don't forget to specify your IP address and your MAC address in the NIOS hello_word "C" code to get it work properly. The main project is a modification of the DE2_NET demostration code that comes with the DE2 board. Have fun, and I'll be waiting for some comments. --- Quote End --- Dear Sir, For my finale year project i am streaming audio data via UDP using DE2-70 board. i have successfully finished transmitting part but for the receiving part i have failed i've spend more that one month to do it but still iam stuck with this i need big help sir if you have source code for receiving part email me thankyou [email protected]