|
我的板子是Cyclone III FPGA Development Kit (3C120 board),参考http://rocketboards.org/foswiki/ ... ManualForCycloneIII,
nios2 linux能够启动,altera TSE工作正常,的确是工作在1000M full duplex模式,但是和PC Windows之间做测试时,发现网卡的速度奇慢无比,UDP的速度只有40~50Mbps。
有人能指点一下为何速度如此慢?
nios2 linux中我做udp测试的函数如下:
int udp_handshake( )
{
int ipLen,i,iRet;
unsigned short udp_marks[8];
int net_error;
net_error=0;
printf("now to handshake by udp\n");
m_udp_socket=socket(AF_INET,SOCK_DGRAM,0);
memset(&addrin,0, sizeof(struct sockaddr_in) );
addrin.sin_family=AF_INET;
addrin.sin_port = htons(3500);
memset(&addrin.sin_zero,0,8);
if(bind(m_udp_socket,(struct sockaddr *)&addrin, sizeof(struct sockaddr_in))) //int bind (int SOCKET, struct sockaddr *ADDR, socklen_t LENGTH)
{
printf("can't creat net interface.......\r\n");
close(m_udp_socket);
return 0;
}
ipLen=sizeof(struct sockaddr_in);
for(i=0;i<8;i++)
{
udp_marks=0;
}
iRet=recvfrom(m_udp_socket, (char * )udp_marks, 16, 0,(struct sockaddr *)&addrin, &ipLen); //first recv mark by blocking mode
printf("pc IP:%s port:%d\r\n",inet_ntoa(addrin.sin_addr),ntohs(addr in.sin_port) );
addrin.sin_port=htons(3500); ipLen=sizeof(struct sockaddr_in);
//test altera TSE speed with udp sending loop, data_length is from 1 to 32, so 1K to 32K data is sent by one sendto
for (i=0;i<send_loop;i++)
{
iRet=sendto(m_udp_socket, (char *)pData_buff, data_length*1024,0,(struct sockaddr *)&addrin,ipLen); //second send back handshake
if (iRet==-1)
{
net_error=1;
}
}
shutdown(m_udp_socket,2); close(m_udp_socket);
return 1;
} |
|