2020-9-25 UDP通信调整优化
今日目标:
- 利用Wireshark检测当前程序的丢包率。
- 利用网上的几种方法进行丢包率的优化改良。
- 总结ARM和FPGA通信的总线都有哪些。
- 构建与单片机通讯的并行总线接口。
1. 检测当前程序的丢包率
1.1 UDP丢包率的统计方法:
- FPGA端:发送一万个1500Byte的AA(10101010)数据包。
- 上位机端:利用Wireshark检测丢包率。
1.2 发送端程序
- 为方便上位机统计,程序设计了3S的初始化时间,初始化结束后开始运行。
always @(negedge clk_125M ) begin
if(init_delay == 29'd499_999_999)
init_delay <=29'd500_000_000;
else if(init_delay < 29'd499_999_999)
init_delay <= init_delay + 1'd1;
else
init_delay <= init_delay;
end
always @(negedge clk_125M) begin
if(init_delay == 29'd499_999_999)
init_flag <= 1'b1;
else
init_flag <= init_flag;
end
- 发送部分检测到初始化标志位后开始执行UDP发送程序
always@(negedge clk_125M)
begin
if(init_flag== 1'd1)
begin
case(STATE_UT)
reset:
begin
flag <= 8'd1;
preamble[0] <= 8'h55;
preamble[1] <= 8'h55;
preamble[2] <= 8'h55;
preamble[3] <= 8'h55;
preamble[4] <= 8'h55;
preamble[5] <= 8'h55;
preamble[6] <= 8'h55;
preamble[7] <= 8'hD5;
pc_mac[0] <= 8'hff;
pc_mac[1] <= 8'hff;
pc_mac[2] <= 8'hff;
pc_mac[3] <= 8'hff;
pc_mac[4] <= 8'hff;
pc_mac[5] <= 8'hff;
board_mac[0] <= 8'h00;
board_mac[1] <= 8'h0A;
board_mac[2] <= 8'h35;
board_mac[3] <= 8'h01;
board_mac[4] <= 8'hFE;
board_mac[5] <= 8'hC0;
type_IP[0] <= 8'h08;
type_IP[1] <= 8'h00;
TX_ER <= 1'd0;
TX_EN <= 1'd0;
crc_en <= 1'd0;
crc_reset <= 1'd0;
if( send_cnt < MAX_SEND_CNT) begin
if(time_cnt == 32'd1000) begin
STATE_UT <= IDEL;
send_cnt <= send_cnt