Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
978 Views

Simple Socket Server question (data length in UDP packets)

Hello, 

 

Current Hardware used:  

Cyclone V GT Dev. Kit 

 

Background: 

I'm a 3rd year engineering student working as an intern. I am new to FPGA's, ethernet communications, and have little coding experience besides this project. Over the course of 5 weeks i have learned a lot, but i may say some terms wrong, so be easy on me :).  

 

Project description: 

I've been assigned to use the FPGA to multicast data over the ethernet. The data right now can be a simple message, i am not worried about format yet. 

 

Where I'm At: 

Using the Simple Socket Server template, I have created my own multicast task that creates a UDP socket server and sends packets containing data.  

 

The Problem: 

According to wireshark, the data in the packets sent is only 4 bytes in length, and always only the first 4 bytes of the message. So i wanted to send "0123456789abcdefghij" but it only sent "0123". This is the case no matter how long i make the message. Eventually, I will need the data to be 1040 bytes long. 

 

Question: 

Why is it only sending the first 4 bytes? What can i do to increase the amount of data in each packet sent?  

 

Attached: 

1. A picture of my multicast server task code. 

2. A picture of my wireshark info. The data is highlighted. 

 

Thank you for your time and your help with this question!
0 Kudos
5 Replies
Altera_Forum
Honored Contributor I
85 Views

Your problem is sizeof(message) is equal to 4. 

 

You probably want something like strlen(message) instead. 

 

char *message is a pointer, sizeof() = 4. 

char message[1024] is an array, sizeof() = 1024
Altera_Forum
Honored Contributor I
85 Views

I don't recall what the maximum length of a UDP message is, but it is less than 1024. Try 1000 or 768.

Altera_Forum
Honored Contributor I
85 Views

Ted, you are a genius! Your suggestion worked, and now my project is complete! Thanks so much! 

Galfonz, in my case I was able to send 1048 bytes of data, using Ted's method.
Altera_Forum
Honored Contributor I
85 Views

I think the maximum size is around 1500, but don't know the exact number.

Altera_Forum
Honored Contributor I
85 Views

Small clarification: the maximum size for a UDP datagram is 64K minus header overhead. 1500 is the default MTU for many/most (all?) Ethernet networks, and if you go over that, it's up to the IP protocol layer to break up the UDP datagram into multiple Ethernet frames. The catch is that both sender and receiver need to have IP stacks that can accept the datagram size you're sending. 

 

It is practical (and maybe today even common) to use Ethernet MTU greater than 1500 bytes. Search for "ethernet jumbo frames"; they work fine with the Altera TSE but I don't recall the scope of the changes to the InterNiche defaults to achieve this. 

 

All of the above is general network programming and configuration knowledge.  

 

The much more interesting FPGA related topics start with the UDP Offload Example: http://www.alterawiki.com/wiki/nios_ii_udp_offload_example 

It's pretty easy to take that example, increase the MTU, and achieve very high data rates with practically zero NIOS processing.
Reply