# VPP & DPDK
###### tags: `VPP` `DPDK`
{%hackmd theme-dark %}
## Server Hardware
* Dell PowerEdge R240 1U * 2
* Laptop * 1
## Hardware Info
```bash
$lshw -class network -businfo //check PCI
```
## VPP
```bash
$vppctl
set int state ($device_name) up
set int ip address ($device_name) ($ip)/($mask)
set interface ip table <interface> <table-id>
show int
show int address
show hard-ware interface
```
* SetUp sample code
```python=
from framework import VppTestCase
class PGinterface(VppTestCase):
def setUpClass(cls):
super(PGinterface, cls).setUpClass()
def tearDownClass(cls):
super(PGinterface, cls).tearDownClass()
def setUp(self):
super(PGinterface, self).setUp()
if __name__ == '__main__':
test = PGinterface()
test.setUpClass()
test.setUp()
```
* Create PGinterface sample code
```python=
class PGinterface(VppTestCase):
...
def setUp(self):
super(PGinterface, self).setUp()
# create 4 pg interfaces
self.create_pg_interfaces(range(2))
# setup interfaces
# assign them different tables
table_id = 0
self.tables = []
for i in self.pg_interfaces:
i.admin_up()
if table_id != 0:
tbl = VppIpTable(self, table_id)
tbl.add_vpp_config()
self.tables.append(tbl)
tbl = VppIpTable(self, table_id, is_ip6=1)
tbl.add_vpp_config()
self.tables.append(tbl)
i.set_table_ip4(table_id)
i.set_table_ip6(table_id)
i.config_ip4()
i.config_ip6()
table_id += 1
```
* sample
```cpp
```
VPP沒提供的功能就要用DPDK寫出plugins
## DPDK
```bash
$cd /home/$(whoami)/dpdk-($version_dir)/($dpdk-build)
$modprobe uio
$insmod kmod/igb_uio.ko
$cat /proc/meminfo | grep Huge
```
## iperf3
```bash
$iperf3 -s //server
$iperf3 -c ($ip) //client (default TCP)
```
## tmux
```bash
# 新增
$ tmux
# OR
$ tmux new -s <your_session_name>
# session 列表
$ tmux ls
# 重新連線 session
$ tmux a -t 0
# OR
$ tmux a -t <session_name>
# 刪除 session
$ tmux kill-session -t 0
# OR
$ tmux kill-session -t <session_name>
# OR
$ tmux kill-session -a # 全部
# 刪除 tmux server
$ tmux kill-server
# 重新命名 session
$ tmux rename-session -t 0 <new_session_name>
# 快捷鍵/視窗管理
# C-b ? Help
# C-b c 新增視窗
# C-b, 視窗命名
# C-b w 視窗列表
# C-b f 尋找視窗
# C-b & 刪除視窗
# C-b % 垂直分割區塊
# C-b “ 水平分割區塊
# C-b <方向鍵>
# C-b p 上一個視窗
# C-b n 下一個視窗
# C-b <number> 依照編號直接切換(編號顯示於狀態列)
# C-b d 離開 session
# C-b x 關閉 Pane
# C-d 關閉 Pane
# C-b z 讓一個 Pane 變成全螢幕,在輸入一次則回到剛剛的尺寸
```
## Experiment
```bash
$iperf3 -s //server
$iperf3 -u -c 192.168.2.200 -l 64 -b 0M -t 300 //client
VPP Forwarding 22.5 MB/s Lost 51 % (UDP)
```
```bash
$iperf3 -s //server
$iperf3 -c 192.168.2.200 //client
VPP Forwarding 81.25 MB/s (TCP)
```
## Reference
[VPP簡易建置](https://my.oschina.net/u/914655?tab=newest&catalogId=7042935&fbclid=IwAR0IrKr2oFw6vWN8cTJqzroy_Wly4nPXethKGQv-rtNxuYPK90sMJKpB-Os)
[VPP拉基官方文件](https://my-vpp-docs.readthedocs.io/en/latest/index.html)
[VPP ppt](https://docs.google.com/presentation/d/12dbV5a4bLGBwzI8xpVNfMURfHM5J2Oyfdt81q1RjDFk/edit?usp=sharing)
[VPP官方python api](https://docs.fd.io/vpp/20.05/vpp_make_test/html/)
[VPP python api report](https://hackmd.io/@jT29vQ4-SxmlBU5UMj1TGA/vpp_python_api)
[VPP startup.conf](https://rtoax.blog.csdn.net/article/details/108056964)
[VPP 生態](https://blog.csdn.net/rong_toa/article/details/109520900#%E4%B8%8B%E8%BD%BDRPM%2FDEB%E5%8C%85)
[VPP主結構function](https://www.cnblogs.com/lulu1997/p/10511749.html)
[VPP主結構ppt](https://drive.google.com/file/d/0B0ZT6l65-x47NVU3MUU1QmZudEE/view?spm=a2c6h.12873639.0.0.5448699a8jxiAj)
[VPP 架構](https://g.yuque.com/zzqcn/opensource/cfa4gg)
[DPDK官方文件](http://doc.dpdk.org/guides/index.html)
[DPDK結構](https://www.codenong.com/cs106434033/)
[DPDK分析](https://segmentfault.com/a/1190000016267105)
[DPDK圖文教學](https://segmentfault.com/a/1190000018156393)
[DPDK l3fwd report](https://hackmd.io/@Rsysz/l3fwd)
[DPDK主結構function](https://blog.csdn.net/sjin_1314/article/details/104800370?utm_medium=distribute.pc_relevant.none-task-blog-title-11&spm=1001.2101.3001.4242)
[ARP](http://godleon.blogspot.com/2007/06/tcpip-ip-network-layer-ip-network-layer.html)
[從DPDK到OpenFlow](http://reader.epubee.com/books/mobile/13/13f3ca762059f7c5f4d57bb1b755d2f2)
[Buildroot架構](https://hugh712.gitbooks.io/buildroot/content/)
[Snort3.0.1](https://snort-org-site.s3.amazonaws.com/production/document_files/files/000/000/251/original/Snort_3_on_Ubuntu.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIXACIED2SPMSC7GA%2F20201124%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201124T155331Z&X-Amz-Expires=172800&X-Amz-SignedHeaders=host&X-Amz-Signature=9445fc6cace516e1bfa5e334856fc88aafa41a018aefd34984f49afe08a0eddb)
[Ubuntu基礎技巧](https://samwhelp.github.io/book-ubuntu-basic-skill/book/content/manual/index.html)
[git更新至最新版本](https://fred-zone.blogspot.com/2015/09/git-fork.html)
```graphviz
graph VPP{
node[shape=record]
VPP_1 [label = "192.168.10.6", shape = plaintext]
VPP [label="VPP"]
VPP_2 [label = "192.168.11.6", shape = plaintext]
H1_ip [label = "192.168.10.5", shape = plaintext]
Host1 [label="Host1"]
Host2 [label="Host2"]
H2_ip [label = "192.168.11.5", shape = plaintext]
{rank = same VPP_1 VPP_2 VPP}
//{rank = same H1_ip Host1}
//{rank = same H2_ip Host2}
VPP -- Host1
VPP -- Host2
}
```