ubuntu安装TRex
<h1 id="软件下载地址">软件下载地址</h1><p>vm 15<br>
https://my.vmware.com/en/web/vmware/downloads/details?downloadGroup=WKST-1556-WIN&productId=799&rPId=47851</p>
<p>ubuntu 16 TLS<br>
桌面版和服务器版各有各的好处,这里使用的是服务器版<br>
https://ubuntu.com/download</p>
<p>trex latest<br>
https://trex-tgn.cisco.com/trex/release/</p>
<h1 id="vm安装ubuntu">vm安装ubuntu</h1>
<p><img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200723220649994-1743846529.png" alt="" loading="lazy"><br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200723220713316-58427372.png" alt="" loading="lazy"><br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200723220730811-1941262315.png" alt="" loading="lazy"></p>
<p>这里要注意一下版本问题,看下载的是64位还是32位的ubuntu, 看情况选择,这里下载的是64位的<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200723220832966-1118578500.png" alt="" loading="lazy"></p>
<p>然后一直下一步,选择内存<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200723221332284-1566520449.png" alt="" loading="lazy"><br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200723221412733-92274969.png" alt="" loading="lazy"></p>
<p>一直下一步,直到结束<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200723221523499-421244828.png" alt="" loading="lazy"></p>
<p>点击编辑虚拟机设置<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200723221555088-621346295.png" alt="" loading="lazy"></p>
<p>选择下载的Ubuntu镜像<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200723221735100-663329995.png" alt="" loading="lazy"></p>
<p>点击开启此虚拟机</p>
<h1 id="启动系统">启动系统</h1>
<p>一直默认选择就好了<br>
选择语言<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725100220093-212988392.png" alt="" loading="lazy"><br>
安装系统<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725100306180-335097588.png" alt="" loading="lazy"><br>
语言选择英文就好<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725100803768-1503406812.png" alt="" loading="lazy"></p>
<p>给服务器起个名字,默认即可<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725101312569-326801870.png" alt="" loading="lazy"></p>
<p>新建用户<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725101801888-588681861.png" alt="" loading="lazy"><br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725101826441-1862886922.png" alt="" loading="lazy"><br>
设置密码<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725101919067-1669626548.png" alt="" loading="lazy"><br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725101953997-965171930.png" alt="" loading="lazy"></p>
<p>设置的密码太简单了,这个虚拟机只是自己练习用,选择yes就行了<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725102016719-1372399548.png" alt="" loading="lazy"></p>
<p>对文件夹进行加密,yes or no 都无所谓<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725102251155-1273525960.png" alt="" loading="lazy"></p>
<p>设置时区,yes就行<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725102444602-442248235.png" alt="" loading="lazy"></p>
<p>磁盘配置,默认就好了<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725102902513-2139236704.png" alt="" loading="lazy"><br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725102921743-1699752396.png" alt="" loading="lazy"><br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725102952582-1407929952.png" alt="" loading="lazy"></p>
<p>配置代理,不用管,继续即可<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725103208674-368030964.png" alt="" loading="lazy"></p>
<p>可以先去喝杯茶</p>
<hr>
<p>选择需要安装的软件,空格选择, openSSH 必选,方便远程连接, 其他的无所谓,可以后期再安装<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725104746922-187371801.png" alt="" loading="lazy"></p>
<p>boot loader, 选择yes<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725105706052-1311391774.png" alt="" loading="lazy"></p>
<p>安装结束<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725110206558-781977174.png" alt="" loading="lazy"></p>
<h1 id="trex-安装">TRex 安装</h1>
<p>先登录虚拟机,查看一下虚拟机的ip地址,以便远程连接<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725110951809-2135716833.png" alt="" loading="lazy"></p>
<pre><code class="language-shell">mkdir trex
cd trex
wget --no-check-certificate https://trex-tgn.cisco.com/trex/release/latest
tar -zxvf latest
</code></pre>
<p>下载特别慢,可以在window上下载,然后上传到虚拟机上面<br>
<img src="https://img2020.cnblogs.com/blog/1403732/202007/1403732-20200725112839509-1121471653.png" alt="" loading="lazy"></p>
<h2 id="查看网卡">查看网卡</h2>
<pre><code class="language-shell">hl@ubuntu:~/trex$ ll
total 670888
drwxrwxr-x3 hl hl 4096 Jul 25 11:27 ./
drwxr-xr-x4 hl hl 4096 Jul 25 11:17 ../
-rw-rw-r--1 hl hl 686970880 Jul 25 11:26 latest
drwxr-xr-x 17 hl hl 4096 May8 00:17 v2.81/
hl@ubuntu:~/trex$ cd v2.81/
hl@ubuntu:~/trex/v2.81$ sudo ./dpdk_setup_ports.py -s
password for hl:
Network devices using DPDK-compatible driver
============================================
<none>
Network devices using kernel driver
===================================
0000:02:01.0 '82545EM Gigabit Ethernet Controller (Copper)' if=ens33 drv=e1000 unused=igb_uio,vfio-pci,uio_pci_generic *Active*
Other network devices
=====================
<none>
hl@ubuntu:~/trex/v2.81$
</code></pre>
<h2 id="添加网卡">添加网卡</h2>
<p>右键虚拟机 -> 设置;<br>
添加 -> 网络适配器(NAT);<br>
确定即可</p>
<p>再次查看网卡,就有了刚才添加的两个网卡</p>
<pre><code class="language-shell">hl@ubuntu:~/trex/v2.81$ sudo ./dpdk_setup_ports.py -s
Network devices using DPDK-compatible driver
============================================
<none>
Network devices using kernel driver
===================================
0000:02:01.0 '82545EM Gigabit Ethernet Controller (Copper)' if=ens33 drv=e1000 unused=igb_uio,vfio-pci,uio_pci_generic *Active*
0000:02:06.0 '82545EM Gigabit Ethernet Controller (Copper)' if=ens38 drv=e1000 unused=igb_uio,vfio-pci,uio_pci_generic
0000:02:07.0 '82545EM Gigabit Ethernet Controller (Copper)' if=ens39 drv=e1000 unused=igb_uio,vfio-pci,uio_pci_generic
Other network devices
=====================
<none>
hl@ubuntu:~/trex/v2.81$
</code></pre>
<h1 id="换国内源">换国内源</h1>
<pre><code class="language-shell">sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vim /etc/apt/sources.list
# 添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
sudo apt update
sudo apt upgrade
</code></pre>
<h2 id="其它国内源">其它国内源</h2>
<pre><code class="language-shell">
# 中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# 163源
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
# 清华源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
</code></pre>
<h1 id="安装插件">安装插件</h1>
<pre><code class="language-shell"># gcc
sudo apt install build-essential
sudo apt install make
sudo apt-get install libnuma-dev
</code></pre>
<h1 id="dpdk-安装">dpdk 安装</h1>
<pre><code class="language-shell">wget http://fast.dpdk.org/rel/dpdk-18.11.9.tar.xz
tar xvJf dpdk-18.11.9.tar.xz
cd dpdk-stable-18.11.9/
# 加载uio驱动
modprobe uio
# 配置dpdk
sudo ./usertools/dpdk-setup.sh
选择 x86_64-native-linuxapp-gcc
Insert IGB UIO module
Insert VFIO module
Insert KNI module
</code></pre>
<h1 id="运行测试">运行测试</h1>
<p>在上面的三个网卡中, Active 端口作为管理端口,管理端口不能被绑定到trex,否则不能管理linx, 其它三个网卡可以绑定<br>
trex默认端口起动配置文件是 <code>/etc/trex_cfg.yaml</code></p>
<pre><code class="language-shell">sudo cp cfg/simple_cfg.yaml/etc/trex_cfg.yaml
sudo vim /etc/trex_cfg.yaml
- port_limit : 2 #端口数量限制
version : 2 #trex 版本
#List of interfaces. Change to suit your setup. Use ./dpdk_setup_ports.py -s to see available options
interfaces : ["03:00.0","03:00.1"] #对应绑定网卡的pci号
port_info :# Port IPs. Change to suit your needs. In case of loopback, you can leave as is.
- ip : 1.1.1.1 #本端eth1的虚接口地址
default_gw : 2.2.2.2 #对端DUT接口地址
- ip : 2.2.2.2 #本端eth2的虚接口地址
default_gw : 1.1.1.1 #对端DUT接口地址
</code></pre>
<h2 id="启动stateless服务器">启动stateless服务器</h2>
<pre><code class="language-shell">~/trex/v2.81$ sudo ./t-rex-64 -i
</code></pre>
<p>另外在起一个窗口</p>
<pre><code class="language-shell">~/trex/v2.81$ sudo ./trex-console
</code></pre><br><br>
来源:https://www.cnblogs.com/hanyanling/p/13364204.html
頁:
[1]