Skip to content

Commit a032aaa

Browse files
committedMar 4, 2024
[doc] add doc about fubuki integration
1 parent 1ceb700 commit a032aaa

File tree

2 files changed

+193
-0
lines changed

2 files changed

+193
-0
lines changed
 

‎doc/switch-fubuki-integration.md

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Integrate virtual switch and fubuki
2+
3+
## Abstraction
4+
5+
`vproxy` provides a sound virtual switch implementation, which supports the TCP/IP stack;
6+
`fubuki` is a network mesh based on tun interfaces written in rust.
7+
8+
We can combine them by converting fubuki tun interfaces into rx/tx APIs and hooking them into vproxy virtual switch.
9+
10+
## Commands descriptions
11+
12+
After launching vproxy, we can get detailed into about the commands used in this article:
13+
14+
* `man switch`
15+
* `man vpc`
16+
* `man fubuki`
17+
* `man iface`
18+
* `man switch add`
19+
* `man vpc add-to`
20+
* `man fubuki add-to`
21+
* `man iface list-detail`
22+
* `man iface remove-from`
23+
24+
## Configuring
25+
26+
1. Launching vproxy
27+
28+
```
29+
make jar-with-lib
30+
java --enable-preview -Dvfd=posix -jar build/libs/vproxy.jar
31+
```
32+
33+
2. Creating virtual switch
34+
35+
```
36+
add switch sw0
37+
```
38+
39+
3. Creating virtual network
40+
41+
```
42+
add vpc 1 to switch sw0 v4network 10.99.88.0/24
43+
```
44+
45+
Descriptions:
46+
47+
* `add vpc 1` means creating vpc `1`, whose vni is 1
48+
* `to switch sw0` means it's added into `sw0`
49+
* `v4network $.$.$.$/$` means the v4 network range limit of this vpc
50+
51+
4. Creating fubuki interface
52+
53+
```
54+
add fubuki fbk0 to switch sw0 vni 1 mac 00:11:22:33:44:55 ip 10.99.88.199/24 address $.$.$.$:$ password $
55+
```
56+
57+
Descriptions:
58+
59+
* `add fubuki fbk0` means create a fubuki interface, named as `fbk0`
60+
* `to switch sw0` means it's added into `sw0`
61+
* `vni 1` means the interface by default belongs to the vpc whose vni is 1 (in other words, `vpc 1`)
62+
* `mac $:$:$:$:$:$` means the mac address allocated for the interface. Since fubuki runs in tun mode, the switch has to simulate the layer 2 frames
63+
* `ip $.$.$.$/$` means the ip address and mask for this interface to use. You may omit this option, in this case, fubuki will automatically allocate an ip instead
64+
* `address $.$.$.$:$` means the address and port of the remote fubuki server
65+
* `password $` means the password used by fubuki to communicate
66+
67+
## Viewing
68+
69+
```
70+
ll iface in switch sw0
71+
```
72+
73+
## Testing
74+
75+
Use a standard fubuki client and connect to the same server, then ping the ip address bond by `fbk0`
76+
77+
```
78+
PING 10.99.88.199 (10.99.88.199): 56 data bytes
79+
Request timeout for icmp_seq 0
80+
64 bytes from 10.99.88.199: icmp_seq=1 ttl=64 time=92.467 ms
81+
64 bytes from 10.99.88.199: icmp_seq=2 ttl=64 time=90.040 ms
82+
64 bytes from 10.99.88.199: icmp_seq=3 ttl=64 time=92.859 ms
83+
^C
84+
--- 10.99.88.199 ping statistics ---
85+
4 packets transmitted, 3 packets received, 25.0% packet loss
86+
round-trip min/avg/max/stddev = 90.040/91.789/92.859/1.247 ms
87+
```
88+
89+
Note: vproxy virtual switch must lookup the dst mac address, so the first responding packet cannot be transmitted.
90+
All other packets after the first one should be transmitted normally.
91+
92+
> For tun devices, arp/ns will be transformed into special icmp packets.
93+
94+
## Deleting
95+
96+
```
97+
remove iface fubuki:fbk0 from switch sw0
98+
```

‎doc_zh/switch-fubuki-integration.md

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# 虚拟交换机模块与fubuki的整合
2+
3+
## 概述
4+
5+
`vproxy`提供了一套较为完整的虚拟交换机实现,支持TCP/IP协议栈;`fubuki`是一个由rust编写的基于tun接口的网络mesh。
6+
将fubuki的tun接口修改为收发包API,并接入vproxy虚拟交换机,即可完成两者的结合。
7+
8+
## 命令说明
9+
10+
可以在启动vproxy后,使用如下命令查看本文档用到的命令细节:
11+
12+
* `man switch`
13+
* `man vpc`
14+
* `man fubuki`
15+
* `man iface`
16+
* `man switch add`
17+
* `man vpc add-to`
18+
* `man fubuki add-to`
19+
* `man iface list-detail`
20+
* `man iface remove-from`
21+
22+
## 配置
23+
24+
1. 启动vproxy
25+
26+
```
27+
make jar-with-lib
28+
java --enable-preview -Dvfd=posix -jar build/libs/vproxy.jar
29+
```
30+
31+
2. 创建虚拟交换机
32+
33+
```
34+
add switch sw0
35+
```
36+
37+
3. 创建虚拟网络
38+
39+
```
40+
add vpc 1 to switch sw0 v4network 10.99.88.0/24
41+
```
42+
43+
命令解释:
44+
45+
* `add vpc 1` 表示创建`1`号vpc,其vni即为1
46+
* `to switch sw0` 表示加入`sw0`
47+
* `v4network $.$.$.$/$` 表示该vpc的v4的网段限制
48+
49+
4. 创建fubuki接口
50+
51+
```
52+
add fubuki fbk0 to switch sw0 vni 1 mac 00:11:22:33:44:55 ip 10.99.88.199/24 address $.$.$.$:$ password $
53+
```
54+
55+
命令解释:
56+
57+
* `add fubuki fbk0` 表示创建一个fubuki网口,名为`fbk0`
58+
* `to switch sw0` 表示加入`sw0`
59+
* `vni 1` 表示该网口默认属于vni为`1`的vpc,即`vpc 1`
60+
* `mac $:$:$:$:$:$` 表示为该网口分配的mac地址。由于fubuki是tun模式,所以需要交换机为其模拟二层报文
61+
* `ip $.$.$.$/$` 表示该网口使用的ip和掩码,可以不指定,不指定则由fubuki为其分配一个ip
62+
* `address $.$.$.$:$` 表示远端fubuki地址和端口
63+
* `password $` 表示fubuki通信使用的密码
64+
65+
## 查看
66+
67+
```
68+
ll iface in switch sw0
69+
```
70+
71+
## 测试
72+
73+
使用任意标准fubuki客户端连接到同一服务,然后ping `fbk0`所绑定的ip
74+
75+
```
76+
PING 10.99.88.199 (10.99.88.199): 56 data bytes
77+
Request timeout for icmp_seq 0
78+
64 bytes from 10.99.88.199: icmp_seq=1 ttl=64 time=92.467 ms
79+
64 bytes from 10.99.88.199: icmp_seq=2 ttl=64 time=90.040 ms
80+
64 bytes from 10.99.88.199: icmp_seq=3 ttl=64 time=92.859 ms
81+
^C
82+
--- 10.99.88.199 ping statistics ---
83+
4 packets transmitted, 3 packets received, 25.0% packet loss
84+
round-trip min/avg/max/stddev = 90.040/91.789/92.859/1.247 ms
85+
```
86+
87+
注意,因为vproxy虚拟交换机需要查询mac,所以第一个回包无法发送,后续报文均应当正常收发。
88+
89+
> 对于tun设备,arp/ns会被转换为特殊的icmp包。
90+
91+
## 删除
92+
93+
```
94+
remove iface fubuki:fbk0 from switch sw0
95+
```

0 commit comments

Comments
 (0)
Failed to load comments.