2023年10月17日 星期二

Install Cisco TRex / 安裝Cisco TRex

This article includes English and Chinese.
本文包含英文及中文

Cisco TRex is a low-cost traffic generator.
This is a guide to install Cisco TRex in Ubuntu Desktop 22.04.
Cisco TRex是一個低成本的流量製造機
這篇文章將介紹如何在Ubuntu Desktop 22.04的環境下安裝Cisco TRex

1. Install Ubuntu Desktop 22.04
After installation completed, open Terminal
1. 安裝Ubuntu Desktop 22.04
安裝完成後,開啟終端機


2. Install OpenSSH Server
2. 安裝OpenSSH Server
$ sudo su
# apt-get install openssh-server

3. Connect Ubuntu via SSH / Download & Extract Cisco TRex
3. 使用SSH連線Ubuntu / 下載並解壓縮Cisco TRex
# mkdir -p /opt/trex
# cd /opt/trex
# wget --no-check-certificate https://trex-tgn.cisco.com/trex/release/latest
# tar -zxvf latest
# cd <version>

4. Install Python
Although python is installed by default, you'll get error message when starting Cisco TRex
So we need to install python manually
4. 安裝Python
雖然預設就有安裝Python,但執行Cisco TRex時會顯示以下錯誤
故仍需要手動安裝Python
# apt install python3.10 python3.10-venv
After installation, you can use below command to check NICs.
安裝完成後,可使用以下指令確認網路卡
# ./dpdk_setup_ports.py -s
# ./dpdk_setup_ports.py -t

5. Use interactive UI to configure a L2 environment for looping test
After Configuration, connect 2 ports you've configured.
5. 使用互動式介面做初步設定一個L2環境來做迴路測試
設定完成後,將設定的兩個port連線
# ./dpdk_setup_ports.py -i
(1) Do you want to use MAC based config? => y
詢問是否使用MAC來進行設定
(2) Enter list of interface separated by space => Input the ID in the list, in this example, enter "0 1"
輸入要使用的介面ID,本例中輸入"0 1"
(3) & (4) use default MAC
使用預設MAC (網卡本身的MAC)即可
(5) Print preview of generated config? => y to check config.
You can also use command "cat /etc/trex_cfg.yaml" to check config after save the config.
檢查設定檔案,存檔後路徑為/etc/trex_cfg.yaml
(6) Save the config to file? => y
存檔

6. Start Cisco TRex
啟動Cisco TRex
# ./t-rex-64 -i

7. Create another session to start Cisco TRex Console
另外開一個session來啟動Cisco TRex Console
# cd /opt/trex/<version>
# ./trex-console

8. Start a test, and use tui to check test status
進行測試,並使用tui來確認測試狀況
trex> start -f stl/imix.py -m 1mbps --port 0
trex> tui


9. To use multi-cores, start TRex with "-c <core>"
A 8 core VM is quite enough for a 8Gbps bi-directional test.
若要使用多核心,在啟動TRex的時候加入"-c <核心數>"參數
一個8核心的VM跑雙向8Gbps的流量測試只占用很少的CPU資源
Start TRex with 6 core: / 使用6核心啟動TRex
# ./t-rex-64 -i -c 6
Test with 8Gbps (in TRex console): / 8Gbps流量測試(在TRex console中使用的指令)
trex> start -f stl/imix.py -m 8000mbps --port 0 --port 1