CUTE-WRV2.1+TCP core(COM5402)的TCP带宽测试
问题的提出
测试TCP的带宽,硬件平台CUTE-WRV2.1,固件版本WRPCV3.0+COM5402。
代码、工具及实现
1. 在固件中,增加模块,收到TCP数据包后不断地往外发数:
library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; use ieee.numeric_std.all; entity user_tcp_demo is port ( clk_i : in std_logic; rst_n_i: in std_logic; user_rx_data: in std_logic_vector(7 downto 0); user_rx_dvalid:in std_logic; user_tx_data: out std_logic_vector(7 downto 0); user_tx_dvalid:out std_logic; user_tx_cts: in std_logic; user_rx_rts: in std_logic ) ; end entity ; -- user_tcp_demo architecture behavioral of user_tcp_demo is signal user_data:std_logic_vector(7 downto 0); signal user_dvalid:std_logic; type t_tx_state is(T_IDLE,T_START,T_DATA,T_WAIT); signal tx_state : t_tx_state; begin user_tx_dvalid <= user_dvalid; user_tx_data <= user_data; U_tcp_tx_demo : process( clk_i ) begin if rising_edge(clk_i) then if rst_n_i = '0' then user_dvalid <= '0'; user_data <= (others=>'0'); tx_state <= T_IDLE; else case( tx_state ) is when T_IDLE => user_dvalid <= '0'; user_data <= (others=>'0'); if user_rx_dvalid = '1' then tx_state<= T_START; end if ; when T_START => user_dvalid <= '1'; user_data <= user_rx_data; tx_state <= T_DATA; when T_DATA => user_dvalid <= '1'; user_data <= user_data + 1; if user_tx_cts = '0' then tx_state<= T_WAIT; end if ; when T_WAIT => user_dvalid <= '0'; user_data <= (others=>'0'); if user_tx_cts = '1' then tx_state<= T_DATA; end if; if user_rx_dvalid = '1' then tx_state <= T_IDLE; end if ; when others => user_dvalid <= '0'; user_data <= (others=>'0'); tx_state <= T_IDLE; end case ; end if ; end if ; end process ; -- U_tcp_tx_demo end behavioral;
2. PC上使用python脚本主动建立TCP连接,然后接收数据. TCP端口号为8000
# Echo client program import socket HOST = '192.168.0.99' # The remote host PORT = 8000 # The same port as used by the server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) while True: s.sendall(b'Hello, world') data = s.recv(1024) # print(repr(data)) s.close()
3. PC上使用speedometer或者来记录带宽
sudo speedometer -r eth2 -t eth2
sudo iftop -i eth2
测试结果
PC透过WR交换机和CUTEWR通讯的带宽:
Speedometer报告的结果为28.2MB/s
iftop报告的结果为220Mb/s